Skip to content

Commit 839f102

Browse files
ghanshyam1898kleikamp
authored andcommitted
jfs: fix array-index-out-of-bounds in jfs_readdir
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>
1 parent a5f5e46 commit 839f102

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/jfs/jfs_dtree.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2891,6 +2891,14 @@ int jfs_readdir(struct file *file, struct dir_context *ctx)
28912891
stbl = DT_GETSTBL(p);
28922892

28932893
for (i = index; i < p->header.nextindex; i++) {
2894+
if (stbl[i] < 0 || stbl[i] > 127) {
2895+
jfs_err("JFS: Invalid stbl[%d] = %d for inode %ld, block = %lld",
2896+
i, stbl[i], (long)ip->i_ino, (long long)bn);
2897+
free_page(dirent_buf);
2898+
DT_PUTPAGE(mp);
2899+
return -EIO;
2900+
}
2901+
28942902
d = (struct ldtentry *) & p->slot[stbl[i]];
28952903

28962904
if (((long) jfs_dirent + d->namlen + 1) >

0 commit comments

Comments
 (0)