jfs: UBSAN: shift-out-of-bounds in dbFindBits
PATCH 1/1 jfs: UBSAN: shift-out-of-bounds in dbFindBits
Fix issue with UBSAN throwing shift-out-of-bounds warning.
Reported-by [email protected]
Signed-off-by Remington Brasga <[email protected]>
---
When nb = 32, mask = mask >> nb or shorthand mask >>= nb throws shift-out-of-bounds warning.mask = (mask >> nb) removes that warning.
Link to the syzbot bug report: https://lore.kernel.org/all/[email protected]/T/
fs/jfs/jfs_dmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jfs/jfs_dmap.c +1 -1
@@ -3020,7 +3020,7 @@ static int dbFindBits(u32 word, int l2nb)/* scan the word for nb free bits at nb alignments. */ -for (bitno =0 ; mask !=0 ; bitno += nb, mask >>= nb) { +for (bitno =0 ; mask !=0 ; bitno += nb, mask = (mask >> nb)) {if ((mask & word) == mask)break ; }
Signature · 1 line
2.34.1
Quoted 8 lines · Remington Brasga
Fix issue with UBSAN throwing shift-out-of-bounds warning.
Reported-by [email protected]Signed-off-by Remington Brasga <[email protected]>---
When nb = 32,mask = mask >> nbor shorthandmask >>= nbthrows shift-out-of-bounds warning.mask = (mask >> nb)removes that warning.
Looks good. Applied.
Shaggy
Quoted 19 lines
Link to the syzbot bug report: https://lore.kernel.org/all/[email protected]/T/
fs/jfs/jfs_dmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/jfs/jfs_dmap.c +1
-1@@ -3020,7 +3020,7 @@ static int dbFindBits(u32 word, int l2nb)/* scan the word for nb free bits at nb alignments. */ -for (bitno =0 ; mask !=0 ; bitno += nb, mask >>= nb) { +for (bitno =0 ; mask !=0 ; bitno += nb, mask = (mask >> nb)) {if ((mask & word) == mask)break ; }