]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
XArray: Fix xas_create_range for ranges above 4 billion
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 13 Oct 2020 12:46:29 +0000 (08:46 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 13 Oct 2020 12:53:29 +0000 (08:53 -0400)
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) <willy@infradead.org>
lib/xarray.c

index 1fa5c5658e638352c9ba9f91d22431ef6d9f3e2f..2046d676ab413c743194fd7ad3b34fa1da934ad2 100644 (file)
@@ -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;