[v6.1] KASAN: use-after-free Read in diFree

6 views
Skip to first unread message

syzbot

unread,
Apr 20, 2023, 3:00:56 AM4/20/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 0102425ac76b Linux 6.1.24
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=152bd81bc80000
kernel config: https://syzkaller.appspot.com/x/.config?x=f23561925d39903
dashboard link: https://syzkaller.appspot.com/bug?extid=5d27913a927bee249e21
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/11b4f76a294e/disk-0102425a.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/45c8eec62c60/vmlinux-0102425a.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0a7b8f48ec43/Image-0102425a.gz.xz

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

jfs_mount: diMount failed w/rc = -5
==================================================================
BUG: KASAN: use-after-free in diFree+0x17ac/0x2648 fs/jfs/jfs_imap.c:871
Read of size 4 at addr ffff0000c72b0004 by task syz-executor.3/10082

CPU: 1 PID: 10082 Comm: syz-executor.3 Not tainted 6.1.24-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/2023
Call trace:
dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:284 [inline]
print_report+0x174/0x4c0 mm/kasan/report.c:395
kasan_report+0xd4/0x130 mm/kasan/report.c:495
__asan_report_load4_noabort+0x2c/0x38 mm/kasan/report_generic.c:350
diFree+0x17ac/0x2648 fs/jfs/jfs_imap.c:871
jfs_evict_inode+0x2d0/0x3f4 fs/jfs/inode.c:156
evict+0x260/0x68c fs/inode.c:664
iput_final fs/inode.c:1747 [inline]
iput+0x7c0/0x8a4 fs/inode.c:1773
diFreeSpecial+0x78/0x108 fs/jfs/jfs_imap.c:548
jfs_mount+0x53c/0x7a4 fs/jfs/jfs_mount.c:203
jfs_fill_super+0x464/0x9f0 fs/jfs/super.c:556
mount_bdev+0x26c/0x368 fs/super.c:1423
jfs_do_mount+0x44/0x58 fs/jfs/super.c:670
legacy_get_tree+0xd4/0x16c fs/fs_context.c:610
vfs_get_tree+0x90/0x274 fs/super.c:1553
do_new_mount+0x25c/0x8c8 fs/namespace.c:3040
path_mount+0x590/0xe58 fs/namespace.c:3370
do_mount fs/namespace.c:3383 [inline]
__do_sys_mount fs/namespace.c:3591 [inline]
__se_sys_mount fs/namespace.c:3568 [inline]
__arm64_sys_mount+0x45c/0x594 fs/namespace.c:3568
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

The buggy address belongs to the physical page:
page:000000009770db67 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1072b0
flags: 0x5ffc00000000000(node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000000000 fffffc00049e0e08 fffffc0004a86408 0000000000000000
raw: 0000000000000000 0000000000040000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff0000c72aff00: 04 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff0000c72aff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff0000c72b0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff0000c72b0080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff0000c72b0100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================
imap: 0000000086cd690d: d6d36b40 ffff0000 0000078b 048a032f
imap: 00000000dc473e99: 00008000 11640000 00c0376a 33c60102
ERROR: (device loop3): diFree: inum = 2, iagno = 0, nextiag = -65536

ERROR: (device loop3): remounting filesystem as read-only
Mount JFS Failure: -5
jfs_mount failed w/return code = -5


---
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 syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
May 23, 2023, 8:45:48 PM5/23/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: fa74641fb6b9 Linux 6.1.29
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=14a71451280000
kernel config: https://syzkaller.appspot.com/x/.config?x=7454aa89ac475d7b
dashboard link: https://syzkaller.appspot.com/bug?extid=5d27913a927bee249e21
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=136b80c1280000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1143596a280000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/53e4da6b145c/disk-fa74641f.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/adeb1a2cfa86/vmlinux-fa74641f.xz
kernel image: https://storage.googleapis.com/syzbot-assets/c976f1155d08/Image-fa74641f.gz.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/3d856f9d09f0/mount_0.gz

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

loop0: detected capacity change from 0 to 14901
read_mapping_page failed!
jfs_mount: diMount failed w/rc = -5
==================================================================
BUG: KASAN: use-after-free in diFree+0x17ac/0x2648 fs/jfs/jfs_imap.c:871
Read of size 4 at addr ffff0000d8130004 by task syz-executor453/4290

CPU: 0 PID: 4290 Comm: syz-executor453 Not tainted 6.1.29-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
Allocated by task 3840:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
kasan_save_alloc_info+0x24/0x30 mm/kasan/generic.c:505
____kasan_kmalloc mm/kasan/common.c:374 [inline]
__kasan_kmalloc+0xac/0xc4 mm/kasan/common.c:383
kasan_kmalloc include/linux/kasan.h:211 [inline]
__do_kmalloc_node mm/slab_common.c:955 [inline]
__kmalloc+0xd8/0x1c4 mm/slab_common.c:968
kmalloc include/linux/slab.h:558 [inline]
tomoyo_realpath_from_path+0xc8/0x4cc security/tomoyo/realpath.c:251
tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
tomoyo_path_perm+0x208/0x568 security/tomoyo/file.c:822
tomoyo_inode_getattr+0x28/0x38 security/tomoyo/tomoyo.c:122
security_inode_getattr+0xd8/0x124 security/security.c:1347
vfs_getattr fs/stat.c:158 [inline]
vfs_statx+0x184/0x420 fs/stat.c:233
vfs_fstatat fs/stat.c:267 [inline]
__do_sys_newfstatat fs/stat.c:437 [inline]
__se_sys_newfstatat fs/stat.c:431 [inline]
__arm64_sys_newfstatat+0x134/0x1c0 fs/stat.c:431
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

Freed by task 3840:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
kasan_save_free_info+0x38/0x5c mm/kasan/generic.c:516
____kasan_slab_free+0x144/0x1c0 mm/kasan/common.c:236
__kasan_slab_free+0x18/0x28 mm/kasan/common.c:244
kasan_slab_free include/linux/kasan.h:177 [inline]
slab_free_hook mm/slub.c:1724 [inline]
slab_free_freelist_hook mm/slub.c:1750 [inline]
slab_free mm/slub.c:3661 [inline]
__kmem_cache_free+0x2c0/0x4b4 mm/slub.c:3674
kfree+0xcc/0x1b8 mm/slab_common.c:1007
tomoyo_realpath_from_path+0x484/0x4cc security/tomoyo/realpath.c:286
tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
tomoyo_path_perm+0x208/0x568 security/tomoyo/file.c:822
tomoyo_inode_getattr+0x28/0x38 security/tomoyo/tomoyo.c:122
security_inode_getattr+0xd8/0x124 security/security.c:1347
vfs_getattr fs/stat.c:158 [inline]
vfs_statx+0x184/0x420 fs/stat.c:233
vfs_fstatat fs/stat.c:267 [inline]
__do_sys_newfstatat fs/stat.c:437 [inline]
__se_sys_newfstatat fs/stat.c:431 [inline]
__arm64_sys_newfstatat+0x134/0x1c0 fs/stat.c:431
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

The buggy address belongs to the object at ffff0000d8130000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 4 bytes inside of
4096-byte region [ffff0000d8130000, ffff0000d8131000)

The buggy address belongs to the physical page:
page:00000000896df55b refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x118130
head:00000000896df55b order:3 compound_mapcount:0 compound_pincount:0
flags: 0x5ffc00000010200(slab|head|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000010200 fffffc000354b800 dead000000000003 ffff0000c0002a80
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff0000d812ff00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff0000d812ff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff0000d8130000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff0000d8130080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff0000d8130100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
imap: 00000000d883ed5a: c7481500 ffff0000 00000f00 06600263
imap: 000000001ff316ea: 00000000 00000000 00000000 00000000
ERROR: (device loop0): diFree: inum = 2, iagno = 0, nextiag = -65536

Mount JFS Failure: -5
jfs_mount failed w/return code = -5


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

syzbot

unread,
Oct 30, 2023, 1:58:04 AM10/30/23
to syzkaller...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit 4de3a603010e0ca334487de24c6aab0777b7f808
Author: Liu Shixin via Jfs-discussion <jfs-dis...@lists.sourceforge.net>
Date: Thu Dec 1 12:46:28 2022 +0000

jfs: fix invalid free of JFS_IP(ipimap)->i_imap in diUnmount

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1670c151680000
start commit: e84a4e368abe Linux 6.1.35
git tree: linux-6.1.y
kernel config: https://syzkaller.appspot.com/x/.config?x=a69b5c9de715622a
dashboard link: https://syzkaller.appspot.com/bug?extid=5d27913a927bee249e21
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1150808f280000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15e73f13280000

If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: jfs: fix invalid free of JFS_IP(ipimap)->i_imap in diUnmount

For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Reply all
Reply to author
Forward
0 new messages