* [PATCH] jfs: Add check for array bounds in dtDelete
@ 2025-09-19 22:50 Pedro Demarchi Gomes
0 siblings, 0 replies; 2+ messages in thread
From: Pedro Demarchi Gomes @ 2025-09-19 22:50 UTC (permalink / raw)
To: shaggy, duttaditya18, ghanshyam1898
Cc: jfs-discussion, linux-kernel, Pedro Demarchi Gomes,
syzbot+4f9c823a6f63d87491ba
stbl is s8 but it must contain offsets into slot which can go from 0 to
127.
Add a bound check for that error inside dtDelete function.
Reported-by: syzbot+4f9c823a6f63d87491ba@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=4f9c823a6f63d87491ba
Signed-off-by: Pedro Demarchi Gomes <pedrodemargomes@gmail.com>
---
fs/jfs/jfs_dtree.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index ab11849cf9cc..c200b37f4562 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -2129,11 +2129,17 @@ int dtDelete(tid_t tid,
next_index = -1;
else {
stbl = DT_GETSTBL(np);
- ldtentry =
- (struct ldtentry *) & np->
- slot[stbl[0]];
- next_index =
- le32_to_cpu(ldtentry->index);
+ if (stbl[0] < 0 || stbl[0] >= DTPAGEMAXSLOT) {
+ jfs_err("JFS: Invalid stbl[0] = %d for inode %ld, block = %lld",
+ stbl[0], (long)ip->i_ino, (long long)le64_to_cpu(p->header.next));
+ next_index = -1;
+ } else {
+ ldtentry =
+ (struct ldtentry *) & np->
+ slot[stbl[0]];
+ next_index =
+ le32_to_cpu(ldtentry->index);
+ }
DT_PUTPAGE(nmp);
}
}
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] jfs: Add check for array bounds in dtDelete
2025-03-18 19:54 [syzbot] [jfs?] UBSAN: array-index-out-of-bounds " syzbot
@ 2025-09-18 21:04 ` Pedro Demarchi Gomes
0 siblings, 0 replies; 2+ messages in thread
From: Pedro Demarchi Gomes @ 2025-09-18 21:04 UTC (permalink / raw)
To: syzbot+4f9c823a6f63d87491ba
Cc: jfs-discussion, linux-kernel, shaggy, syzkaller-bugs,
Pedro Demarchi Gomes
#syz test
---
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 ab11849cf9cc..b30f57304c09 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -2129,6 +2129,14 @@ int dtDelete(tid_t tid,
next_index = -1;
else {
stbl = DT_GETSTBL(np);
+ if (stbl[0] < 0 || stbl[0] >= DTPAGEMAXSLOT) {
+ jfs_err("JFS: Invalid stbl[0] = %d for inode %ld, block = %lld",
+ stbl[0], (long)ip->i_ino, (long long)le64_to_cpu(p->header.next));
+ DT_PUTPAGE(nmp);
+ DT_PUTPAGE(mp);
+ return -EIO;
+ }
+
ldtentry =
(struct ldtentry *) & np->
slot[stbl[0]];
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-19 22:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-19 22:50 [PATCH] jfs: Add check for array bounds in dtDelete Pedro Demarchi Gomes
-- strict thread matches above, loose matches on Subject: below --
2025-03-18 19:54 [syzbot] [jfs?] UBSAN: array-index-out-of-bounds " syzbot
2025-09-18 21:04 ` [PATCH] jfs: Add check for array bounds " Pedro Demarchi Gomes
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®