Skip to contentSkip to conversation

jfs: fix im_l2nbperiext shift out of bounds

PATCH New Pedro Demarchi Gomes 1 participant 1 message Sep 25, 2025 JFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jfs: fix im_l2nbperiext shift out of bounds

When reading im_l2nbperiext from disk, check if its value is valid. Since im_l2nbperiext is the log2 of a 32 bit number, its maximum value is 31.

---
 fs/jfs/jfs_imap.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/jfs/jfs_imap.c +4 -0
index ecb8e05b8b84..6abeb78c9eb4 100644
@@ -124,6 +124,10 @@ int diMount(struct inode *ipimap)
 	atomic_set(&imap->im_numfree, le32_to_cpu(dinom_le->in_numfree));
 	imap->im_nbperiext = le32_to_cpu(dinom_le->in_nbperiext);
 	imap->im_l2nbperiext = le32_to_cpu(dinom_le->in_l2nbperiext);
+	if (imap->im_l2nbperiext > 31) {
+		jfs_err("diMount: invalid im_l2nbperiext");
+		return -EIO;
+	}
 	for (index = 0; index < MAXAG; index++) {
 		imap->im_agctl[index].inofree =
 		    le32_to_cpu(dinom_le->in_agctl[index].inofree);
Signature · 1 line
2.39.5