Skip to content

Commit 84c34df

Browse files
author
Matthew Wilcox (Oracle)
committed
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: Matthew Wilcox (Oracle) <[email protected]>
1 parent f78b825 commit 84c34df

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/xarray.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ void xas_create_range(struct xa_state *xas)
703703
unsigned char shift = xas->xa_shift;
704704
unsigned char sibs = xas->xa_sibs;
705705

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

0 commit comments

Comments
 (0)