* [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dbFindLeaf (2)
@ 2026-01-08 13:00 syzbot
2026-01-08 14:45 ` [PATCH] jfs: fix oob in dbFindLeaf Edward Adam Davis
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: syzbot @ 2026-01-08 13:00 UTC (permalink / raw)
To: jfs-discussion, linux-kernel, shaggy, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: f0b9d8eb98df Merge tag 'nfsd-6.19-3' of git://git.kernel.o..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=130f7e9a580000
kernel config: https://syzkaller.appspot.com/x/.config?x=1f2b6fe1fdf1a00b
dashboard link: https://syzkaller.appspot.com/bug?extid=1afe7ef2d0062e19eeb3
compiler: Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16e4ee9a580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1491c922580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/cbc651b8fda7/disk-f0b9d8eb.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/c3b1f0bf4b6c/vmlinux-f0b9d8eb.xz
kernel image: https://storage.googleapis.com/syzbot-assets/e102a718f8b0/bzImage-f0b9d8eb.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/c8289184ec3d/mount_0.gz
fsck result: failed (log: https://syzkaller.appspot.com/x/fsck.log?x=12e4ee9a580000)
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+1afe7ef2d0062e19eeb3@syzkaller.appspotmail.com
------------[ cut here ]------------
UBSAN: array-index-out-of-bounds in fs/jfs/jfs_dmap.c:2976:16
index 1365 is out of range for type 's8[1365]' (aka 'signed char[1365]')
CPU: 1 UID: 0 PID: 6059 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT_{RT,(full)}
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/25/2025
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
ubsan_epilogue+0xa/0x40 lib/ubsan.c:233
__ubsan_handle_out_of_bounds+0xe9/0xf0 lib/ubsan.c:455
dbFindLeaf+0x308/0x520 fs/jfs/jfs_dmap.c:2976
dbFindCtl+0x267/0x520 fs/jfs/jfs_dmap.c:1717
dbAllocAny fs/jfs/jfs_dmap.c:1527 [inline]
dbAlloc+0x5fa/0xba0 fs/jfs/jfs_dmap.c:878
diNewIAG fs/jfs/jfs_imap.c:2510 [inline]
diAllocExt fs/jfs/jfs_imap.c:1905 [inline]
diAllocAG+0xd45/0x1df0 fs/jfs/jfs_imap.c:1669
diAlloc+0x1d4/0x1670 fs/jfs/jfs_imap.c:1590
ialloc+0x8c/0x8f0 fs/jfs/jfs_inode.c:56
jfs_mkdir+0x193/0xa70 fs/jfs/namei.c:225
vfs_mkdir+0x52d/0x5d0 fs/namei.c:5130
do_mkdirat+0x27a/0x4b0 fs/namei.c:5164
__do_sys_mkdirat fs/namei.c:5186 [inline]
__se_sys_mkdirat fs/namei.c:5184 [inline]
__x64_sys_mkdirat+0x87/0xa0 fs/namei.c:5184
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xec/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7efe6c5ade97
Code: 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 02 01 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007efe6bbf4e68 EFLAGS: 00000246 ORIG_RAX: 0000000000000102
RAX: ffffffffffffffda RBX: 00007efe6bbf4ef0 RCX: 00007efe6c5ade97
RDX: 00000000000001ff RSI: 00002000000002c0 RDI: 00000000ffffff9c
RBP: 0000200000000200 R08: 00002000000000c0 R09: 0000000000000000
R10: 0000200000000200 R11: 0000000000000246 R12: 00002000000002c0
R13: 00007efe6bbf4eb0 R14: 0000000000000000 R15: 0000000000000000
</TASK>
---[ end trace ]---
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] jfs: fix oob in dbFindLeaf
2026-01-08 13:00 [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dbFindLeaf (2) syzbot
@ 2026-01-08 14:45 ` Edward Adam Davis
2026-04-17 10:11 ` Forwarded: [PATCH] jfs: fix off-by-one in dbFindLeaf tree bounds check syzbot
2026-04-17 16:19 ` Forwarded: Re: [syzbot] UBSAN: array-index-out-of-bounds in dbFindLeaf syzbot
2 siblings, 0 replies; 4+ messages in thread
From: Edward Adam Davis @ 2026-01-08 14:45 UTC (permalink / raw)
To: syzbot+1afe7ef2d0062e19eeb3
Cc: jfs-discussion, linux-kernel, shaggy, syzkaller-bugs
The initial value of x is ti, and there is a potential risk that the
value of ti might equal max_size. The existing boundary checks have
been improved to prevent the out-of-bounds (OOB) issue [1] reported
by syzbot.
[1]
UBSAN: array-index-out-of-bounds in fs/jfs/jfs_dmap.c:2976:16
index 1365 is out of range for type 's8[1365]' (aka 'signed char[1365]')
Call Trace:
dbFindLeaf+0x308/0x520 fs/jfs/jfs_dmap.c:2976
dbFindCtl+0x267/0x520 fs/jfs/jfs_dmap.c:1717
dbAllocAny fs/jfs/jfs_dmap.c:1527 [inline]
Reported-by: syzbot+1afe7ef2d0062e19eeb3@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1afe7ef2d0062e19eeb3
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
fs/jfs/jfs_dmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index cdfa699cd7c8..18a7dc58f289 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -2971,7 +2971,7 @@ static int dbFindLeaf(dmtree_t *tp, int l2nb, int *leafidx, bool is_ctl)
/* sufficient free space found. move to the next
* level (or quit if this is the last level).
*/
- if (x + n > max_size)
+ if (x + n >= max_size)
return -ENOSPC;
if (l2nb <= tp->dmt_stree[x + n])
break;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Forwarded: [PATCH] jfs: fix off-by-one in dbFindLeaf tree bounds check
2026-01-08 13:00 [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dbFindLeaf (2) syzbot
2026-01-08 14:45 ` [PATCH] jfs: fix oob in dbFindLeaf Edward Adam Davis
@ 2026-04-17 10:11 ` syzbot
2026-04-17 16:19 ` Forwarded: Re: [syzbot] UBSAN: array-index-out-of-bounds in dbFindLeaf syzbot
2 siblings, 0 replies; 4+ messages in thread
From: syzbot @ 2026-04-17 10:11 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] jfs: fix off-by-one in dbFindLeaf tree bounds check
Author: tristmd@gmail.com
From: Tristan Madani <tristan@talencesecurity.com>
#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
The bounds check in dbFindLeaf() uses a strict greater-than comparison
(x + n > max_size) to guard access to the dmt_stree[] array. However,
max_size is set to the array size itself (TREESIZE or CTLTREESIZE), so
valid indices are 0 through max_size-1. When x + n equals max_size, the
check passes but the subsequent array access tp->dmt_stree[x + n] reads
one element past the end of the array.
This is reached when a corrupted filesystem image has an invalid
dmt_height value that causes the tree walk loop to descend beyond the
actual tree depth, pushing the starting index ti to exactly max_size.
For the dmapctl case (CTLTREESIZE = 1365), a height of 6 instead of the
valid maximum of 5 produces: ti = 1 -> 5 -> 21 -> 85 -> 341 -> 1365,
and the access at stree[1365] is one past the s8[1365] array.
UBSAN reports:
UBSAN: array-index-out-of-bounds in fs/jfs/jfs_dmap.c:2976:16
index 1365 is out of range for type 's8[1365]' (aka 'signed char[1365]')
Fix the off-by-one by changing '>' to '>=' so that the boundary index is
correctly treated as out-of-bounds.
Reported-by: syzbot+1afe7ef2d0062e19eeb3@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1afe7ef2d0062e19eeb3
Fixes: 22cad8bc1d36 ("jfs: fix array-index-out-of-bounds in dbFindLeaf")
Cc: stable@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
fs/jfs/jfs_dmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index XXXXXXX..XXXXXXX 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -3058,7 +3058,7 @@ static int dbFindLeaf(dmtree_t *tp, int l2nb, int *leafidx, bool is_ctl)
/* sufficient free space found. move to the next
* level (or quit if this is the last level).
*/
- if (x + n > max_size)
+ if (x + n >= max_size)
return -ENOSPC;
if (l2nb <= tp->dmt_stree[x + n])
break;
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Forwarded: Re: [syzbot] UBSAN: array-index-out-of-bounds in dbFindLeaf
2026-01-08 13:00 [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dbFindLeaf (2) syzbot
2026-01-08 14:45 ` [PATCH] jfs: fix oob in dbFindLeaf Edward Adam Davis
2026-04-17 10:11 ` Forwarded: [PATCH] jfs: fix off-by-one in dbFindLeaf tree bounds check syzbot
@ 2026-04-17 16:19 ` syzbot
2 siblings, 0 replies; 4+ messages in thread
From: syzbot @ 2026-04-17 16:19 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: Re: [syzbot] UBSAN: array-index-out-of-bounds in dbFindLeaf
Author: tristmd@gmail.com
#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>From 9fdbd0cb4943449d1104e60ec721d8dbe92a56ff Mon Sep 17 00:00:00 2001
From: Tristan Madani <tristan@talencesecurity.com>
Date: Fri, 17 Apr 2026 16:15:14 +0000
Subject: [PATCH] jfs: fix array-index-out-of-bounds in dbFindLeaf
dbFindLeaf() uses an off-by-one comparison when checking array
bounds: `if (x + n > max_size)` should be `>= max_size` since
array indices are 0-based and max_size is the total element count.
When x + n equals max_size, the access tp->dmt_stree[x + n] reads
one element past the end of the array.
Fix by using >= instead of > in the bounds check.
Reported-by: syzbot+1afe7ef2d0062e19eeb3@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1afe7ef2d0062e19eeb3
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
fs/jfs/jfs_dmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index a841cf2..cbdcc8d 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -3058,7 +3058,7 @@ static int dbFindLeaf(dmtree_t *tp, int l2nb, int *leafidx, bool is_ctl)
/* sufficient free space found. move to the next
* level (or quit if this is the last level).
*/
- if (x + n > max_size)
+ if (x + n >= max_size)
return -ENOSPC;
if (l2nb <= tp->dmt_stree[x + n])
break;
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-17 16:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-08 13:00 [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dbFindLeaf (2) syzbot
2026-01-08 14:45 ` [PATCH] jfs: fix oob in dbFindLeaf Edward Adam Davis
2026-04-17 10:11 ` Forwarded: [PATCH] jfs: fix off-by-one in dbFindLeaf tree bounds check syzbot
2026-04-17 16:19 ` Forwarded: Re: [syzbot] UBSAN: array-index-out-of-bounds in dbFindLeaf syzbot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox