Skip to contentSkip to conversation

jfs: UBSAN: shift-out-of-bounds in dbFindBits

PATCH Superseded Matt Jan 1 participant 1 message Oct 25, 2024 JFS filesystem

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Matt Jan

author
#0 lore raw

PATCH 1/1 jfs: UBSAN: shift-out-of-bounds in dbFindBits

The starting bit number of free bits should not be >= 32 as it is 0-indexed.Assert that the number of bits is < 32, or if it is 32, the input word must be 0.

---
 fs/jfs/jfs_dmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jfs/jfs_dmap.c +1 -1
index 974ecf5e0d95..b9eccf8900eb 100644
@@ -3015,7 +3015,7 @@ static int dbFindBits(u32 word, int l2nb)
 	/* get the number of bits.
 	 */
 	nb = 1 << l2nb;
-	assert(nb <= DBWORD);
+	assert(nb < DBWORD || (nb == DBWORD && !word));
 
 	/* complement the word so we can use a mask (i.e. 0s represent
 	 * free bits) and compute the mask.
Signature · 1 line
2.25.1