Commit 84c34df1 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle)
Browse files

XArray: Fix xas_create_range for ranges above 4 billion



The 'sibs' variable would be shifted as a 32-bit integer, so if 'shift'
is more than 32, this is undefined behaviour.  In practice, this doesn't
happen because the page cache is the only user and nobody uses 16TB pages.

Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
parent f78b8250
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -703,7 +703,7 @@ void xas_create_range(struct xa_state *xas)
	unsigned char shift = xas->xa_shift;
	unsigned char sibs = xas->xa_sibs;

	xas->xa_index |= ((sibs + 1) << shift) - 1;
	xas->xa_index |= ((sibs + 1UL) << shift) - 1;
	if (xas_is_node(xas) && xas->xa_node->shift == xas->xa_shift)
		xas->xa_offset |= sibs;
	xas->xa_shift = 0;