public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in jfs_readdir
@ 2024-04-01 14:07 syzbot
  0 siblings, 0 replies; 3+ messages in thread
From: syzbot @ 2024-04-01 14:07 UTC (permalink / raw)
  To: jfs-discussion, linux-fsdevel, linux-kernel, shaggy,
	syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    fe46a7dd189e Merge tag 'sound-6.9-rc1' of git://git.kernel..
git tree:       upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=1723f529180000
kernel config:  https://syzkaller.appspot.com/x/.config?x=4d90a36f0cab495a
dashboard link: https://syzkaller.appspot.com/bug?extid=0315f8fe99120601ba88
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=1574d855180000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=11d95219180000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/72ab73815344/disk-fe46a7dd.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/2d6d6b0d7071/vmlinux-fe46a7dd.xz
kernel image: https://storage.googleapis.com/syzbot-assets/48e275e5478b/bzImage-fe46a7dd.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/fe45a050e301/mount_0.gz

Bisection is inconclusive: the issue happens on the oldest tested release.

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=12f6203d180000
final oops:     https://syzkaller.appspot.com/x/report.txt?x=11f6203d180000
console output: https://syzkaller.appspot.com/x/log.txt?x=16f6203d180000

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

------------[ cut here ]------------
UBSAN: array-index-out-of-bounds in fs/jfs/jfs_dtree.c:2892:30
index -1 is out of range for type 'struct dtslot[128]'
CPU: 0 PID: 5057 Comm: syz-executor163 Not tainted 6.8.0-syzkaller-08951-gfe46a7dd189e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
 ubsan_epilogue lib/ubsan.c:217 [inline]
 __ubsan_handle_out_of_bounds+0x121/0x150 lib/ubsan.c:415
 jfs_readdir+0x1cb4/0x4660 fs/jfs/jfs_dtree.c:2892
 wrap_directory_iterator+0x94/0xe0 fs/readdir.c:67
 iterate_dir+0x539/0x6f0 fs/readdir.c:110
 __do_sys_getdents64 fs/readdir.c:409 [inline]
 __se_sys_getdents64+0x20d/0x4f0 fs/readdir.c:394
 do_syscall_64+0xfb/0x240
 entry_SYSCALL_64_after_hwframe+0x6d/0x75
RIP: 0033:0x7f00e0f665f9
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:00007fffdc32b878 EFLAGS: 00000246 ORIG_RAX: 00000000000000d9
RAX: ffffffffffffffda RBX: 00007fffdc32ba48 RCX: 00007f00e0f665f9
RDX: 000000000000102a RSI: 0000000020002280 RDI: 0000000000000004
RBP: 00007f00e0fdf610 R08: 0000000000000000 R09: 00007fffdc32ba48
R10: 00000000000060cc R11: 0000000000000246 R12: 0000000000000001
R13: 00007fffdc32ba38 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.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection

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] 3+ messages in thread

* UBSAN: array-index-out-of-bounds in jfs_readdir
@ 2024-10-01  4:56 Ghanshyam Agrawal
  2024-10-01  5:20 ` [syzbot] [jfs?] " syzbot
  0 siblings, 1 reply; 3+ messages in thread
From: Ghanshyam Agrawal @ 2024-10-01  4:56 UTC (permalink / raw)
  To: syzbot+0315f8fe99120601ba88; +Cc: linux-kernel, syzkaller-bugs

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

#syz test

[-- Attachment #2: 0001-jfs-fix-array-index-out-of-bounds-in-jfs_readdir.patch --]
[-- Type: text/x-patch, Size: 1404 bytes --]

From 05e4d925c9dec8efed1ea29b2617d2a05e18e6fd Mon Sep 17 00:00:00 2001
From: Ghanshyam Agrawal <ghanshyam1898@gmail.com>
Date: Tue, 1 Oct 2024 10:21:11 +0530
Subject: [PATCH] jfs: fix array-index-out-of-bounds in jfs_readdir
To: shaggy@kernel.org,
    eadavis@qq.com,
    osmtendev@gmail.com,
    ghandatmanas@gmail.com
Cc: jfs-discussion@lists.sourceforge.net,
    linux-kernel@vger.kernel.org

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 related	[flat|nested] 3+ messages in thread

* Re: [syzbot] [jfs?] UBSAN: array-index-out-of-bounds in jfs_readdir
  2024-10-01  4:56 UBSAN: array-index-out-of-bounds in jfs_readdir Ghanshyam Agrawal
@ 2024-10-01  5:20 ` syzbot
  0 siblings, 0 replies; 3+ messages in thread
From: syzbot @ 2024-10-01  5:20 UTC (permalink / raw)
  To: ghanshyam1898, linux-kernel, syzkaller-bugs

Hello,

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

Reported-by: syzbot+0315f8fe99120601ba88@syzkaller.appspotmail.com
Tested-by: syzbot+0315f8fe99120601ba88@syzkaller.appspotmail.com

Tested on:

commit:         e32cde8d Merge tag 'sched_ext-for-6.12-rc1-fixes-1' of..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1414fd07980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=5fde3d29a3913237
dashboard link: https://syzkaller.appspot.com/bug?extid=0315f8fe99120601ba88
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch:          https://syzkaller.appspot.com/x/patch.diff?x=17d8fd07980000

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

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

end of thread, other threads:[~2024-10-01  5:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-01  4:56 UBSAN: array-index-out-of-bounds in jfs_readdir Ghanshyam Agrawal
2024-10-01  5:20 ` [syzbot] [jfs?] " syzbot
  -- strict thread matches above, loose matches on Subject: below --
2024-04-01 14:07 syzbot

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