* [PATCH] jfs: fix array-index-out-of-bounds in jfs_readdir
@ 2024-10-01 6:05 Ghanshyam Agrawal
2024-10-29 22:07 ` Dave Kleikamp
0 siblings, 1 reply; 2+ messages in thread
From: Ghanshyam Agrawal @ 2024-10-01 6:05 UTC (permalink / raw)
To: shaggy, eadavis, osmtendev, ghandatmanas
Cc: Ghanshyam Agrawal, jfs-discussion, linux-kernel,
syzbot+0315f8fe99120601ba88
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>
---
fs/jfs/jfs_dtree.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index 5d3127ca68a4..c8f6e51ac047 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) {
+ DT_PUTPAGE(mp);
+ free_page(dirent_buf);
+ jfs_err("JFS: Invalid stbl[%d] = %d for inode %ld, block = %lld",
+ i, stbl[i], (long)ip->i_ino, (long long)bn);
+ return -EIO;
+ }
+
d = (struct ldtentry *) & p->slot[stbl[i]];
if (((long) jfs_dirent + d->namlen + 1) >
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] jfs: fix array-index-out-of-bounds in jfs_readdir
2024-10-01 6:05 [PATCH] jfs: fix array-index-out-of-bounds in jfs_readdir Ghanshyam Agrawal
@ 2024-10-29 22:07 ` Dave Kleikamp
0 siblings, 0 replies; 2+ messages in thread
From: Dave Kleikamp @ 2024-10-29 22:07 UTC (permalink / raw)
To: Ghanshyam Agrawal, eadavis, osmtendev, ghandatmanas
Cc: jfs-discussion, linux-kernel, syzbot+0315f8fe99120601ba88
On 10/1/24 1:05AM, Ghanshyam Agrawal wrote:
> 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>
> ---
> fs/jfs/jfs_dtree.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
> index 5d3127ca68a4..c8f6e51ac047 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) {
> + DT_PUTPAGE(mp);
> + free_page(dirent_buf);
> + jfs_err("JFS: Invalid stbl[%d] = %d for inode %ld, block = %lld",
> + i, stbl[i], (long)ip->i_ino, (long long)bn);
I'm moving the printing of the error message before the call to
DT_PUTPAGE() since stbl is part of the page's data. And I'm fixing the
indent.
> + return -EIO;
> + }
> +
> d = (struct ldtentry *) & p->slot[stbl[i]];
>
> if (((long) jfs_dirent + d->namlen + 1) >
Otherwise, looks good. I'll be applying this one.
Shaggy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-29 22:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-01 6:05 [PATCH] jfs: fix array-index-out-of-bounds in jfs_readdir Ghanshyam Agrawal
2024-10-29 22:07 ` Dave Kleikamp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®