public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dtDelete
@ 2025-03-18 19:54 syzbot
  2025-04-18  3:25 ` [syzbot] " syzbot
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: syzbot @ 2025-03-18 19:54 UTC (permalink / raw)
  To: jfs-discussion, linux-kernel, shaggy, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    e3a854b577cb Merge tag 'clk-fixes-for-linus' of git://git...
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=111b1fa8580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=eb44f62cb82f8a0a
dashboard link: https://syzkaller.appspot.com/bug?extid=4f9c823a6f63d87491ba
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1484dc78580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=151b1fa8580000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/7feb34a89c2a/non_bootable_disk-e3a854b5.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/80a4e52e75a6/vmlinux-e3a854b5.xz
kernel image: https://storage.googleapis.com/syzbot-assets/e261756ed740/bzImage-e3a854b5.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/7fd9c181a987/mount_0.gz
  fsck result: failed (log: https://syzkaller.appspot.com/x/fsck.log?x=135a419b980000)

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+4f9c823a6f63d87491ba@syzkaller.appspotmail.com

loop0: detected capacity change from 0 to 32768
------------[ cut here ]------------
UBSAN: array-index-out-of-bounds in fs/jfs/jfs_dtree.c:2132:32
index 240 is out of range for type 'struct dtslot[128]'
CPU: 0 UID: 0 PID: 5303 Comm: syz-executor483 Not tainted 6.14.0-rc6-syzkaller-00115-ge3a854b577cb #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 ubsan_epilogue lib/ubsan.c:231 [inline]
 __ubsan_handle_out_of_bounds+0x121/0x150 lib/ubsan.c:429
 dtDelete+0x2d67/0x2db0 fs/jfs/jfs_dtree.c:2132
 jfs_rename+0xf91/0x1bf0 fs/jfs/namei.c:1239
 vfs_rename+0xbdb/0xf00 fs/namei.c:5069
 do_renameat2+0xd94/0x13f0 fs/namei.c:5226
 __do_sys_rename fs/namei.c:5273 [inline]
 __se_sys_rename fs/namei.c:5271 [inline]
 __x64_sys_rename+0x82/0x90 fs/namei.c:5271
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fc873bc9bb9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 61 17 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff24dc46e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000052
RAX: ffffffffffffffda RBX: 0000400000000e00 RCX: 00007fc873bc9bb9
RDX: 00007fc873bc9bb9 RSI: 0000400000000f40 RDI: 0000400000000300
RBP: 00007fc873c42610 R08: 00007fff24dc48b8 R09: 00007fff24dc48b8
R10: 00007fff24dc48b8 R11: 0000000000000246 R12: 0000000000000001
R13: 00007fff24dc48a8 R14: 0000000000000001 R15: 0000000000000001
 </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] 9+ messages in thread

* Re: [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dtDelete
@ 2025-03-19  2:26 Leonardo Hirata
  2025-03-19  2:43 ` syzbot
  0 siblings, 1 reply; 9+ messages in thread
From: Leonardo Hirata @ 2025-03-19  2:26 UTC (permalink / raw)
  To: syzbot+4f9c823a6f63d87491ba
  Cc: jfs-discussion, linux-kernel, shaggy, syzkaller-bugs


[-- Attachment #1.1: Type: text/plain, Size: 10 bytes --]

#syz test

[-- Attachment #1.2: Type: text/html, Size: 31 bytes --]

[-- Attachment #2: 0001-jfs-Add-check-for-array-bounds-in-dtReadFirst.patch --]
[-- Type: text/x-patch, Size: 906 bytes --]

From d2015dde38d6f730eabdc613eb26f7c59daa9cab Mon Sep 17 00:00:00 2001
From: Leonardo Felipe Takao Hirata <leo.fthirata@gmail.com>
Date: Tue, 18 Mar 2025 22:03:57 -0300
Subject: [PATCH] jfs: Add check for array bounds in dtReadFirst

Add a check for index out of bound.

Signed-off-by: Leonardo Felipe Takao Hirata <leo.fthirata@gmail.com>
---
 fs/jfs/jfs_dtree.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index 8f85177f284b..4e29f8c7d624 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -2128,6 +2128,13 @@ int dtDelete(tid_t tid,
 					next_index = -1;
 				else {
 					stbl = DT_GETSTBL(np);
+
+					if (stbl[0] < 0 || stbl[0] > 127) {
+						DT_PUTPAGE(mp);
+						jfs_error(ip->i_sb, "stbl[0] out of bound\n");
+						return -EIO;
+					}
+
 					ldtentry =
 					    (struct ldtentry *) & np->
 					    slot[stbl[0]];
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dtDelete
  2025-03-19  2:26 Leonardo Hirata
@ 2025-03-19  2:43 ` syzbot
  0 siblings, 0 replies; 9+ messages in thread
From: syzbot @ 2025-03-19  2:43 UTC (permalink / raw)
  To: jfs-discussion, leo.fthirata, linux-kernel, shaggy,
	syzkaller-bugs

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
kernel BUG in jfs_evict_inode

------------[ cut here ]------------
kernel BUG at fs/jfs/inode.c:169!
Oops: invalid opcode: 0000 [#1] PREEMPT SMP KASAN NOPTI
CPU: 0 UID: 0 PID: 5776 Comm: syz-executor Not tainted 6.14.0-rc7-syzkaller-g81e4f8d68c66-dirty #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
RIP: 0010:jfs_evict_inode+0x434/0x440 fs/jfs/inode.c:169
Code: df e8 00 e8 d4 fe e9 1d fe ff ff e8 96 a8 6d fe 48 c7 c7 60 42 f5 8e 4c 89 ee e8 77 24 da 01 e9 92 fd ff ff e8 7d a8 6d fe 90 <0f> 0b 66 2e 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90 90 90
RSP: 0018:ffffc900029ffab8 EFLAGS: 00010293
RAX: ffffffff83543803 RBX: ffff888042646f58 RCX: ffff88801f43c880
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff8880426472d0
RBP: ffffc900029ffc30 R08: ffffffff825ef183 R09: 1ffffffff28a9b2c
R10: dffffc0000000000 R11: ffffffff83541530 R12: ffff8880426472d0
R13: ffff888042647350 R14: dffffc0000000000 R15: ffff888042642ad0
FS:  00005555647e6500(0000) GS:ffff88801fc00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005555648015c8 CR3: 0000000058ab8000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 evict+0x4e8/0x9a0 fs/inode.c:796
 dispose_list fs/inode.c:845 [inline]
 evict_inodes+0x6f6/0x790 fs/inode.c:899
 generic_shutdown_super+0xa0/0x2d0 fs/super.c:627
 kill_block_super+0x44/0x90 fs/super.c:1710
 deactivate_locked_super+0xc4/0x130 fs/super.c:473
 cleanup_mnt+0x41f/0x4b0 fs/namespace.c:1413
 task_work_run+0x24f/0x310 kernel/task_work.c:227
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:114 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:329 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
 syscall_exit_to_user_mode+0x13f/0x340 kernel/entry/common.c:218
 do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f885038e497
Code: a8 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 0f 1f 44 00 00 31 f6 e9 09 00 00 00 66 0f 1f 84 00 00 00 00 00 b8 a6 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 01 c3 48 c7 c2 a8 ff ff ff f7 d8 64 89 02 b8
RSP: 002b:00007ffebd08a8a8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
RAX: 0000000000000000 RBX: 00007f885040e08c RCX: 00007f885038e497
RDX: 0000000000000000 RSI: 0000000000000009 RDI: 00007ffebd08a960
RBP: 00007ffebd08a960 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000ffffffff R11: 0000000000000246 R12: 00007ffebd08b9f0
R13: 00007f885040e08c R14: 000000000001eab0 R15: 00007ffebd08ba30
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:jfs_evict_inode+0x434/0x440 fs/jfs/inode.c:169
Code: df e8 00 e8 d4 fe e9 1d fe ff ff e8 96 a8 6d fe 48 c7 c7 60 42 f5 8e 4c 89 ee e8 77 24 da 01 e9 92 fd ff ff e8 7d a8 6d fe 90 <0f> 0b 66 2e 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90 90 90
RSP: 0018:ffffc900029ffab8 EFLAGS: 00010293
RAX: ffffffff83543803 RBX: ffff888042646f58 RCX: ffff88801f43c880
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff8880426472d0
RBP: ffffc900029ffc30 R08: ffffffff825ef183 R09: 1ffffffff28a9b2c
R10: dffffc0000000000 R11: ffffffff83541530 R12: ffff8880426472d0
R13: ffff888042647350 R14: dffffc0000000000 R15: ffff888042642ad0
FS:  00005555647e6500(0000) GS:ffff88801fc00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000c00987e000 CR3: 0000000058ab8000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


Tested on:

commit:         81e4f8d6 Merge tag 'pmdomain-v6.14-rc4' of git://git.k..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=135c25e4580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=27515cfdbafbb90d
dashboard link: https://syzkaller.appspot.com/bug?extid=4f9c823a6f63d87491ba
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch:          https://syzkaller.appspot.com/x/patch.diff?x=171c644c580000


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [syzbot] Re: [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dtDelete
  2025-03-18 19:54 [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dtDelete syzbot
@ 2025-04-18  3:25 ` syzbot
  2025-09-18 21:04 ` [PATCH] jfs: Add check for array bounds " Pedro Demarchi Gomes
  2025-09-19 15:23 ` Forwarded: " syzbot
  2 siblings, 0 replies; 9+ messages in thread
From: syzbot @ 2025-04-18  3:25 UTC (permalink / raw)
  To: linux-kernel

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.

***

Subject: Re: [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dtDelete
Author: richard120310@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git e3a854b577cb

Signed-off-by: I Hsin Cheng <richard120310@gmail.com>
---
 fs/jfs/jfs_dtree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index 8f85177f284b..0a209b30686a 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -2130,7 +2130,7 @@ int dtDelete(tid_t tid,
 					stbl = DT_GETSTBL(np);
 					ldtentry =
 					    (struct ldtentry *) & np->
-					    slot[stbl[0]];
+					    slot[stbl[0] % np->header.maxslot];
 					next_index =
 					    le32_to_cpu(ldtentry->index);
 					DT_PUTPAGE(nmp);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dtDelete
       [not found] <20250418032543.128924-1-richard120310@gmail.com>
@ 2025-04-18  3:53 ` syzbot
  0 siblings, 0 replies; 9+ messages in thread
From: syzbot @ 2025-04-18  3:53 UTC (permalink / raw)
  To: linux-kernel, richard120310, syzkaller-bugs

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
divide error in dtDelete

Oops: divide error: 0000 [#1] PREEMPT SMP KASAN NOPTI
CPU: 0 UID: 0 PID: 6398 Comm: syz.0.176 Not tainted 6.14.0-rc6-syzkaller-00115-ge3a854b577cb-dirty #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
RIP: 0010:dtDelete+0x1d29/0x2de0 fs/jfs/jfs_dtree.c:2133
Code: 04 28 84 c0 0f 85 ef 0c 00 00 44 0f b6 3b 49 8d 5e 14 48 89 d8 48 c1 e8 03 42 0f b6 04 28 84 c0 0f 85 ed 0c 00 00 41 0f b6 c7 <f6> 33 0f b6 dc bf 81 00 00 00 89 de e8 86 ec 68 fe 80 fb 80 0f 87
RSP: 0018:ffffc9000d54f4e0 EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff888012dc3014 RCX: ffff88801d184880
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000081
RBP: ffffc9000d54f7d0 R08: ffffffff83586b02 R09: 1ffffd4000096e18
R10: dffffc0000000000 R11: fffff94000096e19 R12: ffff8880598a81f0
R13: dffffc0000000000 R14: ffff888012dc3000 R15: 0000000000000000
FS:  00007fc17c5f26c0(0000) GS:ffff88801fc00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fc17c5f1fe0 CR3: 0000000012d60000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 jfs_rename+0xf91/0x1bf0 fs/jfs/namei.c:1239
 vfs_rename+0xbdb/0xf00 fs/namei.c:5069
 do_renameat2+0xd94/0x13f0 fs/namei.c:5226
 __do_sys_rename fs/namei.c:5273 [inline]
 __se_sys_rename fs/namei.c:5271 [inline]
 __x64_sys_rename+0x82/0x90 fs/namei.c:5271
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x210 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fc17b78d169
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 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:00007fc17c5f2038 EFLAGS: 00000246 ORIG_RAX: 0000000000000052
RAX: ffffffffffffffda RBX: 00007fc17b9a6080 RCX: 00007fc17b78d169
RDX: 0000000000000000 RSI: 0000400000000f40 RDI: 0000400000000300
RBP: 00007fc17b80e2a0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000001 R14: 00007fc17b9a6080 R15: 00007ffcc2700f98
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:dtDelete+0x1d29/0x2de0 fs/jfs/jfs_dtree.c:2133
Code: 04 28 84 c0 0f 85 ef 0c 00 00 44 0f b6 3b 49 8d 5e 14 48 89 d8 48 c1 e8 03 42 0f b6 04 28 84 c0 0f 85 ed 0c 00 00 41 0f b6 c7 <f6> 33 0f b6 dc bf 81 00 00 00 89 de e8 86 ec 68 fe 80 fb 80 0f 87
RSP: 0018:ffffc9000d54f4e0 EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff888012dc3014 RCX: ffff88801d184880
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000081
RBP: ffffc9000d54f7d0 R08: ffffffff83586b02 R09: 1ffffd4000096e18
R10: dffffc0000000000 R11: fffff94000096e19 R12: ffff8880598a81f0
R13: dffffc0000000000 R14: ffff888012dc3000 R15: 0000000000000000
FS:  00007fc17c5f26c0(0000) GS:ffff88801fc00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fc17c5f1fe0 CR3: 0000000012d60000 CR4: 0000000000352ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	04 28                	add    $0x28,%al
   2:	84 c0                	test   %al,%al
   4:	0f 85 ef 0c 00 00    	jne    0xcf9
   a:	44 0f b6 3b          	movzbl (%rbx),%r15d
   e:	49 8d 5e 14          	lea    0x14(%r14),%rbx
  12:	48 89 d8             	mov    %rbx,%rax
  15:	48 c1 e8 03          	shr    $0x3,%rax
  19:	42 0f b6 04 28       	movzbl (%rax,%r13,1),%eax
  1e:	84 c0                	test   %al,%al
  20:	0f 85 ed 0c 00 00    	jne    0xd13
  26:	41 0f b6 c7          	movzbl %r15b,%eax
* 2a:	f6 33                	divb   (%rbx) <-- trapping instruction
  2c:	0f b6 dc             	movzbl %ah,%ebx
  2f:	bf 81 00 00 00       	mov    $0x81,%edi
  34:	89 de                	mov    %ebx,%esi
  36:	e8 86 ec 68 fe       	call   0xfe68ecc1
  3b:	80 fb 80             	cmp    $0x80,%bl
  3e:	0f                   	.byte 0xf
  3f:	87                   	.byte 0x87


Tested on:

commit:         e3a854b5 Merge tag 'clk-fixes-for-linus' of git://git...
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=14ad9470580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=522f1f3e5f61442b
dashboard link: https://syzkaller.appspot.com/bug?extid=4f9c823a6f63d87491ba
compiler:       Debian clang version 15.0.6, Debian LLD 15.0.6
patch:          https://syzkaller.appspot.com/x/patch.diff?x=1167ba3f980000


^ permalink raw reply	[flat|nested] 9+ 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 in dtDelete syzbot
  2025-04-18  3:25 ` [syzbot] " syzbot
@ 2025-09-18 21:04 ` Pedro Demarchi Gomes
  2025-09-18 21:27   ` [syzbot] [jfs?] UBSAN: array-index-out-of-bounds " syzbot
  2025-09-19 15:23 ` Forwarded: " syzbot
  2 siblings, 1 reply; 9+ 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 related	[flat|nested] 9+ messages in thread

* Re: [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dtDelete
  2025-09-18 21:04 ` [PATCH] jfs: Add check for array bounds " Pedro Demarchi Gomes
@ 2025-09-18 21:27   ` syzbot
  0 siblings, 0 replies; 9+ messages in thread
From: syzbot @ 2025-09-18 21:27 UTC (permalink / raw)
  To: jfs-discussion, linux-kernel, pedrodemargomes, shaggy,
	syzkaller-bugs

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
kernel BUG in jfs_evict_inode

------------[ cut here ]------------
kernel BUG at fs/jfs/inode.c:169!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
CPU: 0 UID: 0 PID: 5829 Comm: syz-executor Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
RIP: 0010:jfs_evict_inode+0x438/0x440 fs/jfs/inode.c:169
Code: fe e9 e0 fd ff ff 44 89 f1 80 e1 07 80 c1 03 38 c1 0f 8c 23 fe ff ff 4c 89 f7 e8 53 32 e8 fe e9 16 fe ff ff e8 a9 30 83 fe 90 <0f> 0b 66 0f 1f 44 00 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90
RSP: 0018:ffffc9000294fae0 EFLAGS: 00010293
RAX: ffffffff833c7ea7 RBX: ffff888040f50430 RCX: ffff888000b00000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff888040f50430
RBP: 0000000000000001 R08: ffffffff8fa1dc37 R09: 1ffffffff1f43b86
R10: dffffc0000000000 R11: ffffffff833c5ba0 R12: dffffc0000000000
R13: dffffc0000000000 R14: ffff888040f500b8 R15: ffffffff833c7a70
FS:  0000555570297500(0000) GS:ffff88808d261000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffd8d810d68 CR3: 00000000594b6000 CR4: 0000000000352ef0
Call Trace:
 <TASK>
 evict+0x504/0x9c0 fs/inode.c:810
 dispose_list fs/inode.c:852 [inline]
 evict_inodes+0x64c/0x6d0 fs/inode.c:906
 generic_shutdown_super+0x9a/0x2c0 fs/super.c:628
 kill_block_super+0x44/0x90 fs/super.c:1766
 deactivate_locked_super+0xb9/0x130 fs/super.c:474
 cleanup_mnt+0x425/0x4c0 fs/namespace.c:1375
 task_work_run+0x1d1/0x260 kernel/task_work.c:227
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 exit_to_user_mode_loop+0xec/0x110 kernel/entry/common.c:43
 exit_to_user_mode_prepare include/linux/irq-entry-common.h:225 [inline]
 syscall_exit_to_user_mode_work include/linux/entry-common.h:175 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:210 [inline]
 do_syscall_64+0x2bd/0x3b0 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fd644f8e497
Code: a8 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 0f 1f 44 00 00 31 f6 e9 09 00 00 00 66 0f 1f 84 00 00 00 00 00 b8 a6 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 01 c3 48 c7 c2 a8 ff ff ff f7 d8 64 89 02 b8
RSP: 002b:00007ffd8d811518 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
RAX: 0000000000000000 RBX: 00007fd64500e08c RCX: 00007fd644f8e497
RDX: 0000000000000000 RSI: 0000000000000009 RDI: 00007ffd8d8115d0
RBP: 00007ffd8d8115d0 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000ffffffff R11: 0000000000000246 R12: 00007ffd8d812660
R13: 00007fd64500e08c R14: 0000000000023de4 R15: 00007ffd8d8126a0
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:jfs_evict_inode+0x438/0x440 fs/jfs/inode.c:169
Code: fe e9 e0 fd ff ff 44 89 f1 80 e1 07 80 c1 03 38 c1 0f 8c 23 fe ff ff 4c 89 f7 e8 53 32 e8 fe e9 16 fe ff ff e8 a9 30 83 fe 90 <0f> 0b 66 0f 1f 44 00 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90
RSP: 0018:ffffc9000294fae0 EFLAGS: 00010293
RAX: ffffffff833c7ea7 RBX: ffff888040f50430 RCX: ffff888000b00000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff888040f50430
RBP: 0000000000000001 R08: ffffffff8fa1dc37 R09: 1ffffffff1f43b86
R10: dffffc0000000000 R11: ffffffff833c5ba0 R12: dffffc0000000000
R13: dffffc0000000000 R14: ffff888040f500b8 R15: ffffffff833c7a70
FS:  0000555570297500(0000) GS:ffff88808d261000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000c009bee020 CR3: 00000000594b6000 CR4: 0000000000352ef0


Tested on:

commit:         cbf658dd Merge tag 'net-6.17-rc7' of git://git.kernel...
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1261cf62580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=839dff357af8f40d
dashboard link: https://syzkaller.appspot.com/bug?extid=4f9c823a6f63d87491ba
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
patch:          https://syzkaller.appspot.com/x/patch.diff?x=11123f62580000


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Forwarded: Re: [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dtDelete
  2025-03-18 19:54 [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dtDelete syzbot
  2025-04-18  3:25 ` [syzbot] " syzbot
  2025-09-18 21:04 ` [PATCH] jfs: Add check for array bounds " Pedro Demarchi Gomes
@ 2025-09-19 15:23 ` syzbot
  2 siblings, 0 replies; 9+ messages in thread
From: syzbot @ 2025-09-19 15:23 UTC (permalink / raw)
  To: linux-kernel

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.

***

Subject: Re: [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dtDelete
Author: pedrodemargomes@gmail.com

#syz test


---
 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.43.0

-- 
You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/syzkaller-bugs/825ad453-7347-4af7-8a14-3aaf678c83a6n%40googlegroups.com.

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dtDelete
       [not found] <825ad453-7347-4af7-8a14-3aaf678c83a6n@googlegroups.com>
@ 2025-09-19 15:45 ` syzbot
  0 siblings, 0 replies; 9+ messages in thread
From: syzbot @ 2025-09-19 15:45 UTC (permalink / raw)
  To: linux-kernel, pedrodemargomes, syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+4f9c823a6f63d87491ba@syzkaller.appspotmail.com
Tested-by: syzbot+4f9c823a6f63d87491ba@syzkaller.appspotmail.com

Tested on:

commit:         097a6c33 Merge tag 'trace-rv-v6.17-rc5' of git://git.k..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=157a39cd980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=839dff357af8f40d
dashboard link: https://syzkaller.appspot.com/bug?extid=4f9c823a6f63d87491ba
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
patch:          https://syzkaller.appspot.com/x/patch.diff?x=103410e2580000

Note: testing is done by a robot and is best-effort only.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-09-19 15:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-18 19:54 [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in dtDelete syzbot
2025-04-18  3:25 ` [syzbot] " syzbot
2025-09-18 21:04 ` [PATCH] jfs: Add check for array bounds " Pedro Demarchi Gomes
2025-09-18 21:27   ` [syzbot] [jfs?] UBSAN: array-index-out-of-bounds " syzbot
2025-09-19 15:23 ` Forwarded: " syzbot
  -- strict thread matches above, loose matches on Subject: below --
2025-03-19  2:26 Leonardo Hirata
2025-03-19  2:43 ` syzbot
     [not found] <20250418032543.128924-1-richard120310@gmail.com>
2025-04-18  3:53 ` syzbot
     [not found] <825ad453-7347-4af7-8a14-3aaf678c83a6n@googlegroups.com>
2025-09-19 15:45 ` syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox