]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
jfs: array-index-out-of-bounds fix in dtReadFirst
authorGhanshyam Agrawal <ghanshyam1898@gmail.com>
Sat, 28 Sep 2024 08:37:22 +0000 (14:07 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 18:51:38 +0000 (19:51 +0100)
[ Upstream commit ca84a2c9be482836b86d780244f0357e5a778c46 ]

The value of stbl can be sometimes out of bounds due
to a bad filesystem. Added a check with appopriate return
of error code in that case.

Reported-by: syzbot+65fa06e29859e41a83f3@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=65fa06e29859e41a83f3
Signed-off-by: Ghanshyam Agrawal <ghanshyam1898@gmail.com>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/jfs/jfs_dtree.c

index a222a9d71887f564c61fd599c974207941a39493..8f7ce1bea44c5d6249e9e3f3e0d930d5b38dc375 100644 (file)
@@ -3382,6 +3382,13 @@ static int dtReadFirst(struct inode *ip, struct btstack * btstack)
 
                /* get the leftmost entry */
                stbl = DT_GETSTBL(p);
+
+               if (stbl[0] < 0 || stbl[0] > 127) {
+                       DT_PUTPAGE(mp);
+                       jfs_error(ip->i_sb, "stbl[0] out of bound\n");
+                       return -EIO;
+               }
+
                xd = (pxd_t *) & p->slot[stbl[0]];
 
                /* get the child page block address */