Skip to content

Commit

Permalink
XArray: Fix xas_create_range for ranges above 4 billion
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Matthew Wilcox (Oracle) committed Oct 13, 2020
1 parent f78b825 commit 84c34df
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/xarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 84c34df

Please sign in to comment.