summaryrefslogtreecommitdiff
path: root/fs/jfs
diff options
context:
space:
mode:
authorGhanshyam Agrawal <ghanshyam1898@gmail.com>2024-10-01 11:35:47 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-12-14 20:03:52 +0100
commit8ff7579554571d92e3deab168f5a7d7b146ed368 (patch)
treebbabe338b27104816cf303bcd0f4057eb0a0c52d /fs/jfs
parent52756a57e978e2706543a254f88f266cc6702f36 (diff)
downloadlinux-8ff7579554571d92e3deab168f5a7d7b146ed368.tar.gz
linux-8ff7579554571d92e3deab168f5a7d7b146ed368.tar.bz2
linux-8ff7579554571d92e3deab168f5a7d7b146ed368.zip
jfs: fix array-index-out-of-bounds in jfs_readdir
[ Upstream commit 839f102efb168f02dfdd46717b7c6dddb26b015e ] The stbl might contain some invalid values. Added a check to return error code in that case. Reported-by: syzbot+0315f8fe99120601ba88@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=0315f8fe99120601ba88 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>
Diffstat (limited to 'fs/jfs')
-rw-r--r--fs/jfs/jfs_dtree.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index 69fd936fbdb3..8f85177f284b 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -2891,6 +2891,14 @@ int jfs_readdir(struct file *file, struct dir_context *ctx)
stbl = DT_GETSTBL(p);
for (i = index; i < p->header.nextindex; i++) {
+ if (stbl[i] < 0 || stbl[i] > 127) {
+ jfs_err("JFS: Invalid stbl[%d] = %d for inode %ld, block = %lld",
+ i, stbl[i], (long)ip->i_ino, (long long)bn);
+ free_page(dirent_buf);
+ DT_PUTPAGE(mp);
+ return -EIO;
+ }
+
d = (struct ldtentry *) & p->slot[stbl[i]];
if (((long) jfs_dirent + d->namlen + 1) >