[syzbot] [jfs?] KASAN: slab-use-after-free Read in jfs_evict_inode

4 views
Skip to first unread message

syzbot

unread,
Oct 27, 2023, 1:15:24 AM10/27/23
to jfs-dis...@lists.sourceforge.net, linux-...@vger.kernel.org, linux-...@vger.kernel.org, sha...@kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: fe3cfe869d5e Merge tag 'phy-fixes-6.6' of git://git.kernel..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=15db4635680000
kernel config: https://syzkaller.appspot.com/x/.config?x=b400c09b1315b112
dashboard link: https://syzkaller.appspot.com/bug?extid=01cf2dbcbe2022454388
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=170eb95d680000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/57e585f5caff/disk-fe3cfe86.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/d2904450b051/vmlinux-fe3cfe86.xz
kernel image: https://storage.googleapis.com/syzbot-assets/8fb732d9bee9/bzImage-fe3cfe86.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/be380785486a/mount_0.gz

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

jfs_mount: diMount failed w/rc = -5
==================================================================
BUG: KASAN: slab-use-after-free in jfs_evict_inode+0x4aa/0x4b0 fs/jfs/inode.c:155
Read of size 8 at addr ffff88806356f970 by task syz-executor.5/6182

CPU: 0 PID: 6182 Comm: syz-executor.5 Not tainted 6.6.0-rc6-syzkaller-00355-gfe3cfe869d5e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:364 [inline]
print_report+0xc4/0x620 mm/kasan/report.c:475
kasan_report+0xda/0x110 mm/kasan/report.c:588
jfs_evict_inode+0x4aa/0x4b0 fs/jfs/inode.c:155
evict+0x2ed/0x6b0 fs/inode.c:664
iput_final fs/inode.c:1775 [inline]
iput.part.0+0x55e/0x7a0 fs/inode.c:1801
iput+0x5c/0x80 fs/inode.c:1791
diFreeSpecial+0x7a/0x110 fs/jfs/jfs_imap.c:549
jfs_mount+0x471/0x890 fs/jfs/jfs_mount.c:203
jfs_fill_super+0x5a3/0xd20 fs/jfs/super.c:556
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fac16a7e1ea
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 09 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fac178baee8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fac178baf80 RCX: 00007fac16a7e1ea
RDX: 0000000020002400 RSI: 0000000020000040 RDI: 00007fac178baf40
RBP: 0000000020002400 R08: 00007fac178baf80 R09: 0000000000000080
R10: 0000000000000080 R11: 0000000000000246 R12: 0000000020000040
R13: 00007fac178baf40 R14: 0000000000002332 R15: 0000000020002500
</TASK>

Allocated by task 6182:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
__kasan_slab_alloc+0x81/0x90 mm/kasan/common.c:328
kasan_slab_alloc include/linux/kasan.h:188 [inline]
slab_post_alloc_hook mm/slab.h:762 [inline]
slab_alloc_node mm/slab.c:3237 [inline]
slab_alloc mm/slab.c:3246 [inline]
__kmem_cache_alloc_lru mm/slab.c:3423 [inline]
kmem_cache_alloc_lru+0x202/0x6d0 mm/slab.c:3439
alloc_inode_sb include/linux/fs.h:2868 [inline]
jfs_alloc_inode+0x25/0x60 fs/jfs/super.c:105
alloc_inode+0x5d/0x220 fs/inode.c:259
new_inode_pseudo fs/inode.c:1004 [inline]
new_inode+0x22/0x260 fs/inode.c:1030
diReadSpecial+0x51/0x6e0 fs/jfs/jfs_imap.c:423
jfs_mount+0x31e/0x890 fs/jfs/jfs_mount.c:166
jfs_fill_super+0x5a3/0xd20 fs/jfs/super.c:556
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 5231:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
kasan_save_free_info+0x28/0x40 mm/kasan/generic.c:522
____kasan_slab_free mm/kasan/common.c:236 [inline]
____kasan_slab_free+0x138/0x190 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:164 [inline]
__cache_free mm/slab.c:3370 [inline]
__do_kmem_cache_free mm/slab.c:3557 [inline]
kmem_cache_free+0x104/0x380 mm/slab.c:3582
i_callback+0x43/0x70 fs/inode.c:248
rcu_do_batch kernel/rcu/tree.c:2139 [inline]
rcu_core+0x805/0x1bb0 kernel/rcu/tree.c:2403
__do_softirq+0x218/0x965 kernel/softirq.c:553

Last potentially related work creation:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
__kasan_record_aux_stack+0x78/0x80 mm/kasan/generic.c:492
__call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:2653
destroy_inode+0x129/0x1b0 fs/inode.c:314
iput_final fs/inode.c:1775 [inline]
iput.part.0+0x55e/0x7a0 fs/inode.c:1801
iput+0x5c/0x80 fs/inode.c:1791
diFreeSpecial+0x7a/0x110 fs/jfs/jfs_imap.c:549
jfs_mount+0x424/0x890 fs/jfs/jfs_mount.c:191
jfs_fill_super+0x5a3/0xd20 fs/jfs/super.c:556
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Second to last potentially related work creation:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
__kasan_record_aux_stack+0x78/0x80 mm/kasan/generic.c:492
__call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:2653
destroy_inode+0x129/0x1b0 fs/inode.c:314
iput_final fs/inode.c:1775 [inline]
iput.part.0+0x55e/0x7a0 fs/inode.c:1801
iput+0x5c/0x80 fs/inode.c:1791
jfs_fill_super+0x95c/0xd20 fs/jfs/super.c:607
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff88806356f5c0
which belongs to the cache jfs_ip of size 2240
The buggy address is located 944 bytes inside of
freed 2240-byte region [ffff88806356f5c0, ffff88806356fe80)

The buggy address belongs to the physical page:
page:ffffea00018d5bc0 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88806356ffff pfn:0x6356f
memcg:ffff888028945f41
flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0x1()
raw: 00fff00000000800 ffff8881422a8700 ffffea00018d5c90 ffffea00018d6350
raw: ffff88806356ffff ffff88806356f5c0 0000000100000001 ffff888028945f41
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Reclaimable, gfp_mask 0x342050(__GFP_IO|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE|__GFP_RECLAIMABLE), pid 5219, tgid 5216 (syz-executor.1), ts 145722879804, free_ts 145541609248
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1536
prep_new_page mm/page_alloc.c:1543 [inline]
get_page_from_freelist+0xee0/0x2f20 mm/page_alloc.c:3170
__alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4426
__alloc_pages_node include/linux/gfp.h:237 [inline]
kmem_getpages mm/slab.c:1356 [inline]
cache_grow_begin+0x99/0x3a0 mm/slab.c:2550
cache_alloc_refill+0x294/0x3a0 mm/slab.c:2923
____cache_alloc mm/slab.c:2999 [inline]
____cache_alloc mm/slab.c:2982 [inline]
__do_cache_alloc mm/slab.c:3182 [inline]
slab_alloc_node mm/slab.c:3230 [inline]
slab_alloc mm/slab.c:3246 [inline]
__kmem_cache_alloc_lru mm/slab.c:3423 [inline]
kmem_cache_alloc_lru+0x566/0x6d0 mm/slab.c:3439
alloc_inode_sb include/linux/fs.h:2868 [inline]
jfs_alloc_inode+0x25/0x60 fs/jfs/super.c:105
alloc_inode+0x5d/0x220 fs/inode.c:259
new_inode_pseudo fs/inode.c:1004 [inline]
new_inode+0x22/0x260 fs/inode.c:1030
diReadSpecial+0x51/0x6e0 fs/jfs/jfs_imap.c:423
jfs_mount+0xe0/0x890 fs/jfs/jfs_mount.c:87
jfs_fill_super+0x5a3/0xd20 fs/jfs/super.c:556
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1136 [inline]
free_unref_page_prepare+0x476/0xa40 mm/page_alloc.c:2312
free_unref_page+0x33/0x3b0 mm/page_alloc.c:2405
slab_destroy mm/slab.c:1608 [inline]
slabs_destroy+0x85/0xc0 mm/slab.c:1628
cache_flusharray mm/slab.c:3341 [inline]
___cache_free+0x2b7/0x420 mm/slab.c:3404
qlink_free mm/kasan/quarantine.c:166 [inline]
qlist_free_all+0x4c/0x1b0 mm/kasan/quarantine.c:185
kasan_quarantine_reduce+0x18e/0x1d0 mm/kasan/quarantine.c:292
__kasan_slab_alloc+0x65/0x90 mm/kasan/common.c:305
kasan_slab_alloc include/linux/kasan.h:188 [inline]
slab_post_alloc_hook mm/slab.h:762 [inline]
slab_alloc_node mm/slab.c:3237 [inline]
__kmem_cache_alloc_node+0x163/0x470 mm/slab.c:3521
__do_kmalloc_node mm/slab_common.c:1025 [inline]
__kmalloc+0x4f/0x100 mm/slab_common.c:1039
kmalloc_array include/linux/slab.h:636 [inline]
kcalloc include/linux/slab.h:667 [inline]
ext4_find_extent+0x958/0xce0 fs/ext4/extents.c:914
ext4_ext_map_blocks+0x26b/0x5b10 fs/ext4/extents.c:4101
ext4_map_blocks+0x844/0x1770 fs/ext4/inode.c:548
ext4_append+0x1fb/0x560 fs/ext4/namei.c:75
ext4_init_new_dir+0x220/0x4c0 fs/ext4/namei.c:2981
ext4_mkdir+0x316/0xb70 fs/ext4/namei.c:3027
vfs_mkdir+0x532/0x7e0 fs/namei.c:4121

Memory state around the buggy address:
ffff88806356f800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88806356f880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88806356f900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88806356f980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88806356fa00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


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

If the bug is already fixed, 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 bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

Edward Adam Davis

unread,
Oct 27, 2023, 6:46:38 AM10/27/23
to syzbot+01cf2d...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
please test KASAN: slab-use-after-free Read in jfs_evict_inode

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

diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 2e2f7f6d36a0..a9a13b4da6f4 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -113,6 +113,8 @@ static struct inode *jfs_alloc_inode(struct super_block *sb)

static void jfs_free_inode(struct inode *inode)
{
+ if (JFS_IP(inode)->fileset == FILESYSTEM_I)
+ JFS_SBI(inode->i_sb)->ipimap = NULL;
kmem_cache_free(jfs_inode_cachep, JFS_IP(inode));
}


syzbot

unread,
Oct 27, 2023, 7:02:05 AM10/27/23
to ead...@qq.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Write in jfs_free_inode

==================================================================
BUG: KASAN: slab-use-after-free in jfs_free_inode+0xf8/0x100 fs/jfs/super.c:117
Write of size 8 at addr ffff88802c11f028 by task dhcpcd-run-hook/5606

CPU: 1 PID: 5606 Comm: dhcpcd-run-hook Not tainted 6.6.0-rc6-syzkaller-00355-gfe3cfe869d5e-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:364 [inline]
print_report+0xc4/0x620 mm/kasan/report.c:475
kasan_report+0xda/0x110 mm/kasan/report.c:588
jfs_free_inode+0xf8/0x100 fs/jfs/super.c:117
i_callback+0x43/0x70 fs/inode.c:248
rcu_do_batch kernel/rcu/tree.c:2139 [inline]
rcu_core+0x805/0x1bb0 kernel/rcu/tree.c:2403
__do_softirq+0x218/0x965 kernel/softirq.c:553
invoke_softirq kernel/softirq.c:427 [inline]
__irq_exit_rcu kernel/softirq.c:632 [inline]
irq_exit_rcu+0xb7/0x120 kernel/softirq.c:644
sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1074
</IRQ>
<TASK>
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:645
RIP: 0010:deref_stack_reg arch/x86/kernel/unwind_orc.c:403 [inline]
RIP: 0010:unwind_next_frame+0x1a85/0x2390 arch/x86/kernel/unwind_orc.c:648
Code: c6 84 c9 0f 95 c1 40 84 ce 0f 85 88 08 00 00 83 e0 07 38 c2 0f 9e c1 84 d2 0f 95 c0 84 c1 0f 85 73 08 00 00 4d 0f bf 64 24 02 <ba> 08 00 00 00 48 89 df 4d 01 ec 4c 89 e6 e8 f8 e2 ff ff 31 ff 41
RSP: 0018:ffffc9000360f528 EFLAGS: 00000246
RAX: 0000000000000000 RBX: ffffc9000360f5a8 RCX: 0000000000000001
RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffffffff8f5fe9e0
RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000004
R10: 0000000000000001 R11: 0000000000000001 R12: ffffffffffffffe0
R13: ffffc9000360f930 R14: 0000000000000001 R15: 0000000000000001
arch_stack_walk+0xfa/0x170 arch/x86/kernel/stacktrace.c:25
stack_trace_save+0x96/0xd0 kernel/stacktrace.c:122
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
__kasan_slab_alloc+0x81/0x90 mm/kasan/common.c:328
kasan_slab_alloc include/linux/kasan.h:188 [inline]
slab_post_alloc_hook mm/slab.h:762 [inline]
slab_alloc_node mm/slab.c:3237 [inline]
slab_alloc mm/slab.c:3246 [inline]
__kmem_cache_alloc_lru mm/slab.c:3423 [inline]
kmem_cache_alloc+0x159/0x400 mm/slab.c:3432
vm_area_dup+0x21/0x2f0 kernel/fork.c:500
dup_mmap+0x93c/0x1d80 kernel/fork.c:710
dup_mm kernel/fork.c:1686 [inline]
copy_mm kernel/fork.c:1735 [inline]
copy_process+0x6bff/0x73f0 kernel/fork.c:2501
kernel_clone+0xfd/0x920 kernel/fork.c:2909
__do_sys_clone+0xba/0x100 kernel/fork.c:3052
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f0e3f393a12
Code: 41 5d 41 5e 41 5f c3 64 48 8b 04 25 10 00 00 00 45 31 c0 31 d2 31 f6 bf 11 00 20 01 4c 8d 90 d0 02 00 00 b8 38 00 00 00 0f 05 <48> 3d 00 f0 ff ff 76 10 48 8b 15 e7 43 0f 00 f7 d8 64 89 02 48 83
RSP: 002b:00007fff35d052e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000038
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007f0e3f393a12
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000001200011
RBP: 000056225d3c9930 R08: 0000000000000000 R09: 00007f0e3f488b20
R10: 00007f0e3f259650 R11: 0000000000000246 R12: 0000000000000084
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000024
</TASK>

Allocated by task 5598:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
____kasan_kmalloc mm/kasan/common.c:374 [inline]
__kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:383
kmalloc include/linux/slab.h:599 [inline]
kzalloc include/linux/slab.h:720 [inline]
jfs_fill_super+0xe5/0xd20 fs/jfs/super.c:497
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 5598:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
kasan_save_free_info+0x28/0x40 mm/kasan/generic.c:522
____kasan_slab_free mm/kasan/common.c:236 [inline]
____kasan_slab_free+0x138/0x190 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:164 [inline]
__cache_free mm/slab.c:3370 [inline]
__do_kmem_cache_free mm/slab.c:3557 [inline]
__kmem_cache_free+0xcc/0x2d0 mm/slab.c:3564
jfs_fill_super+0x7c7/0xd20 fs/jfs/super.c:614
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff88802c11f000
which belongs to the cache kmalloc-256 of size 256
The buggy address is located 40 bytes inside of
freed 256-byte region [ffff88802c11f000, ffff88802c11f100)

The buggy address belongs to the physical page:
page:ffffea0000b047c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2c11f
flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0x8()
raw: 00fff00000000800 ffff888012c40500 ffffea0001e2a950 ffffea0001878ed0
raw: 0000000000000000 ffff88802c11f000 0000000100000008 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x3420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 5406, tgid 5406 (syz-executor.1), ts 113494436089, free_ts 113409130595
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1536
prep_new_page mm/page_alloc.c:1543 [inline]
get_page_from_freelist+0xee0/0x2f20 mm/page_alloc.c:3170
__alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4426
__alloc_pages_node include/linux/gfp.h:237 [inline]
kmem_getpages mm/slab.c:1356 [inline]
cache_grow_begin+0x99/0x3a0 mm/slab.c:2550
cache_alloc_refill+0x294/0x3a0 mm/slab.c:2923
____cache_alloc mm/slab.c:2999 [inline]
____cache_alloc mm/slab.c:2982 [inline]
__do_cache_alloc mm/slab.c:3182 [inline]
slab_alloc_node mm/slab.c:3230 [inline]
__kmem_cache_alloc_node+0x3c5/0x470 mm/slab.c:3521
kmalloc_trace+0x25/0xe0 mm/slab_common.c:1117
kmalloc include/linux/slab.h:599 [inline]
kzalloc include/linux/slab.h:720 [inline]
____ip_mc_inc_group+0x273/0xcf0 net/ipv4/igmp.c:1450
__ip_mc_inc_group net/ipv4/igmp.c:1485 [inline]
ip_mc_inc_group net/ipv4/igmp.c:1491 [inline]
ip_mc_up+0x14f/0x3a0 net/ipv4/igmp.c:1790
inetdev_event+0xbc6/0x1900 net/ipv4/devinet.c:1598
notifier_call_chain+0xb6/0x3b0 kernel/notifier.c:93
call_netdevice_notifiers_info+0xb9/0x130 net/core/dev.c:1995
call_netdevice_notifiers_extack net/core/dev.c:2033 [inline]
call_netdevice_notifiers net/core/dev.c:2047 [inline]
__dev_notify_flags+0x12d/0x2e0 net/core/dev.c:8665
dev_change_flags+0x122/0x170 net/core/dev.c:8703
do_setlink+0x1a2a/0x3fa0 net/core/rtnetlink.c:2880
__rtnl_newlink+0xc1d/0x1940 net/core/rtnetlink.c:3671
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1136 [inline]
free_unref_page_prepare+0x476/0xa40 mm/page_alloc.c:2312
free_unref_page+0x33/0x3b0 mm/page_alloc.c:2405
slab_destroy mm/slab.c:1608 [inline]
slabs_destroy+0x85/0xc0 mm/slab.c:1628
cache_flusharray mm/slab.c:3341 [inline]
___cache_free+0x2b7/0x420 mm/slab.c:3404
qlink_free mm/kasan/quarantine.c:166 [inline]
qlist_free_all+0x4c/0x1b0 mm/kasan/quarantine.c:185
kasan_quarantine_reduce+0x18e/0x1d0 mm/kasan/quarantine.c:292
__kasan_slab_alloc+0x65/0x90 mm/kasan/common.c:305
kasan_slab_alloc include/linux/kasan.h:188 [inline]
slab_post_alloc_hook mm/slab.h:762 [inline]
slab_alloc_node mm/slab.c:3237 [inline]
kmem_cache_alloc_node+0x173/0x540 mm/slab.c:3509
__alloc_skb+0x287/0x330 net/core/skbuff.c:640
alloc_skb include/linux/skbuff.h:1286 [inline]
alloc_skb_with_frags+0xe4/0x710 net/core/skbuff.c:6313
sock_alloc_send_pskb+0x7e4/0x970 net/core/sock.c:2795
sock_alloc_send_skb include/net/sock.h:1883 [inline]
mld_newpack.isra.0+0x1ee/0x790 net/ipv6/mcast.c:1746
add_grhead+0x295/0x340 net/ipv6/mcast.c:1849
add_grec+0x10bb/0x1680 net/ipv6/mcast.c:1987
mld_send_initial_cr.part.0+0xe2/0x260 net/ipv6/mcast.c:2234
mld_send_initial_cr net/ipv6/mcast.c:2225 [inline]
mld_dad_work+0x57/0x2e0 net/ipv6/mcast.c:2260

Memory state around the buggy address:
ffff88802c11ef00: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc
ffff88802c11ef80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88802c11f000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88802c11f080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88802c11f100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
----------------
Code disassembly (best guess), 1 bytes skipped:
0: 84 c9 test %cl,%cl
2: 0f 95 c1 setne %cl
5: 40 84 ce test %cl,%sil
8: 0f 85 88 08 00 00 jne 0x896
e: 83 e0 07 and $0x7,%eax
11: 38 c2 cmp %al,%dl
13: 0f 9e c1 setle %cl
16: 84 d2 test %dl,%dl
18: 0f 95 c0 setne %al
1b: 84 c1 test %al,%cl
1d: 0f 85 73 08 00 00 jne 0x896
23: 4d 0f bf 64 24 02 movswq 0x2(%r12),%r12
* 29: ba 08 00 00 00 mov $0x8,%edx <-- trapping instruction
2e: 48 89 df mov %rbx,%rdi
31: 4d 01 ec add %r13,%r12
34: 4c 89 e6 mov %r12,%rsi
37: e8 f8 e2 ff ff call 0xffffe334
3c: 31 ff xor %edi,%edi
3e: 41 rex.B


Tested on:

commit: fe3cfe86 Merge tag 'phy-fixes-6.6' of git://git.kernel..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=106788ab680000
kernel config: https://syzkaller.appspot.com/x/.config?x=b400c09b1315b112
dashboard link: https://syzkaller.appspot.com/bug?extid=01cf2dbcbe2022454388
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=174d9cb5680000

Edward Adam Davis

unread,
Oct 27, 2023, 9:10:01 PM10/27/23
to syzbot+01cf2d...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
please test KASAN: slab-use-after-free Read in jfs_evict_inode

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

diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 2e2f7f6d36a0..a9a13b4da6f4 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -113,6 +113,8 @@ static struct inode *jfs_alloc_inode(struct super_block *sb)

static void jfs_free_inode(struct inode *inode)
{
+ if (!IS_ERR_OR_NULL(inode) && JFS_IP(inode)->fileset == FILESYSTEM_I)

syzbot

unread,
Oct 27, 2023, 10:44:06 PM10/27/23
to ead...@qq.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Write in jfs_free_inode

==================================================================
BUG: KASAN: slab-use-after-free in jfs_free_inode+0x11f/0x130 fs/jfs/super.c:117
Write of size 8 at addr ffff88807c98a228 by task swapper/1/0

CPU: 1 PID: 0 Comm: swapper/1 Not tainted 6.6.0-rc6-syzkaller-00355-gfe3cfe869d5e-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:364 [inline]
print_report+0xc4/0x620 mm/kasan/report.c:475
kasan_report+0xda/0x110 mm/kasan/report.c:588
jfs_free_inode+0x11f/0x130 fs/jfs/super.c:117
i_callback+0x43/0x70 fs/inode.c:248
rcu_do_batch kernel/rcu/tree.c:2139 [inline]
rcu_core+0x805/0x1bb0 kernel/rcu/tree.c:2403
__do_softirq+0x218/0x965 kernel/softirq.c:553
invoke_softirq kernel/softirq.c:427 [inline]
__irq_exit_rcu kernel/softirq.c:632 [inline]
irq_exit_rcu+0xb7/0x120 kernel/softirq.c:644
sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1074
</IRQ>
<TASK>
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:645
RIP: 0010:native_irq_disable arch/x86/include/asm/irqflags.h:37 [inline]
RIP: 0010:arch_local_irq_disable arch/x86/include/asm/irqflags.h:72 [inline]
RIP: 0010:acpi_safe_halt+0x1b/0x20 drivers/acpi/processor_idle.c:113
Code: ed c3 66 66 2e 0f 1f 84 00 00 00 00 00 66 90 65 48 8b 04 25 00 bd 03 00 48 8b 00 a8 08 75 0c 66 90 0f 00 2d e7 7a b6 00 fb f4 <fa> c3 0f 1f 00 0f b6 47 08 3c 01 74 0b 3c 02 74 05 8b 7f 04 eb 9f
RSP: 0018:ffffc9000038fd58 EFLAGS: 00000246
RAX: 0000000000004000 RBX: 0000000000000001 RCX: ffffffff8a3da75e
RDX: 0000000000000001 RSI: ffff888145a4b000 RDI: ffff888145a4b064
RBP: ffff888145a4b064 R08: 0000000000000001 R09: ffffed1017326dbd
R10: ffff8880b9936deb R11: 0000000000000000 R12: ffff888144ace000
R13: ffffffff8d658fc0 R14: 0000000000000001 R15: 0000000000000000
acpi_idle_enter+0xc5/0x160 drivers/acpi/processor_idle.c:707
cpuidle_enter_state+0x82/0x500 drivers/cpuidle/cpuidle.c:267
cpuidle_enter+0x4e/0xa0 drivers/cpuidle/cpuidle.c:388
cpuidle_idle_call kernel/sched/idle.c:215 [inline]
do_idle+0x315/0x3f0 kernel/sched/idle.c:282
cpu_startup_entry+0x50/0x60 kernel/sched/idle.c:380
start_secondary+0x20e/0x2a0 arch/x86/kernel/smpboot.c:326
secondary_startup_64_no_verify+0x166/0x16b
</TASK>

Allocated by task 5612:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
____kasan_kmalloc mm/kasan/common.c:374 [inline]
__kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:383
kmalloc include/linux/slab.h:599 [inline]
kzalloc include/linux/slab.h:720 [inline]
jfs_fill_super+0xe5/0xd20 fs/jfs/super.c:497
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 5612:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
kasan_save_free_info+0x28/0x40 mm/kasan/generic.c:522
____kasan_slab_free mm/kasan/common.c:236 [inline]
____kasan_slab_free+0x138/0x190 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:164 [inline]
__cache_free mm/slab.c:3370 [inline]
__do_kmem_cache_free mm/slab.c:3557 [inline]
__kmem_cache_free+0xcc/0x2d0 mm/slab.c:3564
jfs_fill_super+0x7c7/0xd20 fs/jfs/super.c:614
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff88807c98a200
which belongs to the cache kmalloc-256 of size 256
The buggy address is located 40 bytes inside of
freed 256-byte region [ffff88807c98a200, ffff88807c98a300)

The buggy address belongs to the physical page:
page:ffffea0001f26280 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7c98a
flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0x8()
raw: 00fff00000000800 ffff888012c40500 ffffea000079d2d0 ffffea0001ceaf90
raw: 0000000000000000 ffff88807c98a000 0000000100000008 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x3420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 5410, tgid 5410 (syz-executor.4), ts 165581635883, free_ts 157634386789
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1536
prep_new_page mm/page_alloc.c:1543 [inline]
get_page_from_freelist+0xee0/0x2f20 mm/page_alloc.c:3170
__alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4426
__alloc_pages_node include/linux/gfp.h:237 [inline]
kmem_getpages mm/slab.c:1356 [inline]
cache_grow_begin+0x99/0x3a0 mm/slab.c:2550
cache_alloc_refill+0x294/0x3a0 mm/slab.c:2923
____cache_alloc mm/slab.c:2999 [inline]
____cache_alloc mm/slab.c:2982 [inline]
__do_cache_alloc mm/slab.c:3182 [inline]
slab_alloc_node mm/slab.c:3230 [inline]
__kmem_cache_alloc_node+0x3c5/0x470 mm/slab.c:3521
__do_kmalloc_node mm/slab_common.c:1025 [inline]
__kmalloc+0x4f/0x100 mm/slab_common.c:1039
kmalloc include/linux/slab.h:603 [inline]
kzalloc include/linux/slab.h:720 [inline]
fib_create_info+0x852/0x4d50 net/ipv4/fib_semantics.c:1459
fib_table_insert+0x1d7/0x1d70 net/ipv4/fib_trie.c:1236
fib_magic+0x491/0x550 net/ipv4/fib_frontend.c:1104
fib_add_ifaddr+0x174/0x560 net/ipv4/fib_frontend.c:1126
fib_inetaddr_event+0x166/0x2a0 net/ipv4/fib_frontend.c:1440
notifier_call_chain+0xb6/0x3b0 kernel/notifier.c:93
blocking_notifier_call_chain kernel/notifier.c:388 [inline]
blocking_notifier_call_chain+0x69/0x90 kernel/notifier.c:376
__inet_insert_ifa+0x936/0xc20 net/ipv4/devinet.c:556
inet_rtm_newaddr+0x560/0xae0 net/ipv4/devinet.c:976
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1136 [inline]
free_unref_page_prepare+0x476/0xa40 mm/page_alloc.c:2312
free_unref_page+0x33/0x3b0 mm/page_alloc.c:2405
slab_destroy mm/slab.c:1608 [inline]
slabs_destroy+0x85/0xc0 mm/slab.c:1628
cache_flusharray mm/slab.c:3341 [inline]
___cache_free+0x2b7/0x420 mm/slab.c:3404
qlink_free mm/kasan/quarantine.c:166 [inline]
qlist_free_all+0x4c/0x1b0 mm/kasan/quarantine.c:185
kasan_quarantine_reduce+0x18e/0x1d0 mm/kasan/quarantine.c:292
__kasan_slab_alloc+0x65/0x90 mm/kasan/common.c:305
kasan_slab_alloc include/linux/kasan.h:188 [inline]
slab_post_alloc_hook mm/slab.h:762 [inline]
slab_alloc_node mm/slab.c:3237 [inline]
__kmem_cache_alloc_node+0x163/0x470 mm/slab.c:3521
__do_kmalloc_node mm/slab_common.c:1025 [inline]
__kmalloc+0x4f/0x100 mm/slab_common.c:1039
kmalloc include/linux/slab.h:603 [inline]
tomoyo_realpath_from_path+0xb9/0x710 security/tomoyo/realpath.c:251
tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
tomoyo_path_number_perm+0x241/0x580 security/tomoyo/file.c:723
security_file_ioctl+0x72/0xb0 security/security.c:2647
__do_sys_ioctl fs/ioctl.c:865 [inline]
__se_sys_ioctl fs/ioctl.c:857 [inline]
__x64_sys_ioctl+0xbb/0x210 fs/ioctl.c:857
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
ffff88807c98a100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88807c98a180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88807c98a200: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88807c98a280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807c98a300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
----------------
Code disassembly (best guess):
0: ed in (%dx),%eax
1: c3 ret
2: 66 66 2e 0f 1f 84 00 data16 cs nopw 0x0(%rax,%rax,1)
9: 00 00 00 00
d: 66 90 xchg %ax,%ax
f: 65 48 8b 04 25 00 bd mov %gs:0x3bd00,%rax
16: 03 00
18: 48 8b 00 mov (%rax),%rax
1b: a8 08 test $0x8,%al
1d: 75 0c jne 0x2b
1f: 66 90 xchg %ax,%ax
21: 0f 00 2d e7 7a b6 00 verw 0xb67ae7(%rip) # 0xb67b0f
28: fb sti
29: f4 hlt
* 2a: fa cli <-- trapping instruction
2b: c3 ret
2c: 0f 1f 00 nopl (%rax)
2f: 0f b6 47 08 movzbl 0x8(%rdi),%eax
33: 3c 01 cmp $0x1,%al
35: 74 0b je 0x42
37: 3c 02 cmp $0x2,%al
39: 74 05 je 0x40
3b: 8b 7f 04 mov 0x4(%rdi),%edi
3e: eb 9f jmp 0xffffffdf


Tested on:

commit: fe3cfe86 Merge tag 'phy-fixes-6.6' of git://git.kernel..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=14c710b5680000
kernel config: https://syzkaller.appspot.com/x/.config?x=b400c09b1315b112
dashboard link: https://syzkaller.appspot.com/bug?extid=01cf2dbcbe2022454388
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=14b20b57680000

Edward Adam Davis

unread,
Oct 29, 2023, 12:23:26 AM10/29/23
to syzbot+01cf2d...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
please test KASAN: slab-use-after-free Read in jfs_evict_inode

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

diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 920d58a1566b..fc7d4470a4fd 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -152,6 +152,7 @@ void jfs_evict_inode(struct inode *inode)
if (test_cflag(COMMIT_Freewmap, inode))
jfs_free_zero_link(inode);

+ printk("ipimap: %p, %s\n", ipimap, __func__);
if (ipimap && JFS_IP(ipimap)->i_imap)
diFree(inode);

diff --git a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c
index b83aae56a1f2..8cc3ebac1352 100644
--- a/fs/jfs/jfs_mount.c
+++ b/fs/jfs/jfs_mount.c
@@ -188,6 +188,7 @@ int jfs_mount(struct super_block *sb)
*/
err_ipimap:
/* close fileset inode allocation map inode */
+ printk("ipimap: %p, fileset:%d, %s\n", ipimap, JFS_IP(inode)->fileset, __func__);
diFreeSpecial(ipimap);
err_umount_ipaimap2:
/* close secondary aggregate inode allocation map */
@@ -200,6 +201,7 @@ int jfs_mount(struct super_block *sb)
err_umount_ipbmap: /* close aggregate block allocation map */
dbUnmount(ipbmap, 1);
err_ipbmap: /* close aggregate inodes */
+ printk("ipbmap: %p, fileset:%d, %s\n", ipbmap, JFS_IP(inode)->fileset, __func__);
diFreeSpecial(ipbmap);
err_umount_ipaimap: /* close aggregate inode allocation map */
diUnmount(ipaimap, 1);
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 2e2f7f6d36a0..02fc47863a4d 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -113,6 +113,7 @@ static struct inode *jfs_alloc_inode(struct super_block *sb)

static void jfs_free_inode(struct inode *inode)
{
+ printk("inode: %p, %s\n", inode, __func__);
kmem_cache_free(jfs_inode_cachep, JFS_IP(inode));
}


syzbot

unread,
Oct 29, 2023, 1:16:06 AM10/29/23
to ead...@qq.com, syzkall...@googlegroups.com
Hello,

syzbot tried to test the proposed patch but the build/boot failed:

fs/jfs/jfs_mount.c:191:63: error: 'inode' undeclared (first use in this function)


Tested on:

commit: fe3cfe86 Merge tag 'phy-fixes-6.6' of git://git.kernel..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel config: https://syzkaller.appspot.com/x/.config?x=b400c09b1315b112
dashboard link: https://syzkaller.appspot.com/bug?extid=01cf2dbcbe2022454388
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=141750d7680000

Edward Adam Davis

unread,
Oct 29, 2023, 6:37:15 AM10/29/23
to syzbot+01cf2d...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
please test KASAN: slab-use-after-free Read in jfs_evict_inode

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

diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 920d58a1566b..fc7d4470a4fd 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -152,6 +152,7 @@ void jfs_evict_inode(struct inode *inode)
if (test_cflag(COMMIT_Freewmap, inode))
jfs_free_zero_link(inode);

+ printk("ipimap: %p, %s\n", ipimap, __func__);
if (ipimap && JFS_IP(ipimap)->i_imap)
diFree(inode);

diff --git a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c
index b83aae56a1f2..8de4640112d4 100644
--- a/fs/jfs/jfs_mount.c
+++ b/fs/jfs/jfs_mount.c
@@ -188,6 +188,7 @@ int jfs_mount(struct super_block *sb)
*/
err_ipimap:
/* close fileset inode allocation map inode */
+ printk("ipimap: %p, fileset:%d, %s\n", ipimap, JFS_IP(ipimap)->fileset, __func__);
diFreeSpecial(ipimap);
err_umount_ipaimap2:
/* close secondary aggregate inode allocation map */
@@ -200,6 +201,7 @@ int jfs_mount(struct super_block *sb)
err_umount_ipbmap: /* close aggregate block allocation map */
dbUnmount(ipbmap, 1);
err_ipbmap: /* close aggregate inodes */
+ printk("ipbmap: %p, fileset:%d, %s\n", ipbmap, JFS_IP(ipbmap)->fileset, __func__);

syzbot

unread,
Oct 29, 2023, 6:56:05 AM10/29/23
to ead...@qq.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Read in jfs_evict_inode

jfs_mount: diMount failed w/rc = -5
ipimap: ffff888062a7b570, fileset:1, jfs_mount
ipbmap: ffff888062a794f0, fileset:16, jfs_mount
ipimap: ffff888062a7b570, jfs_evict_inode
==================================================================
BUG: KASAN: slab-use-after-free in jfs_evict_inode+0x4c0/0x4d0 fs/jfs/inode.c:156
Read of size 8 at addr ffff888062a7b4f0 by task syz-executor.1/5589

CPU: 0 PID: 5589 Comm: syz-executor.1 Not tainted 6.6.0-rc6-syzkaller-00355-gfe3cfe869d5e-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:364 [inline]
print_report+0xc4/0x620 mm/kasan/report.c:475
kasan_report+0xda/0x110 mm/kasan/report.c:588
jfs_evict_inode+0x4c0/0x4d0 fs/jfs/inode.c:156
evict+0x2ed/0x6b0 fs/inode.c:664
iput_final fs/inode.c:1775 [inline]
iput.part.0+0x55e/0x7a0 fs/inode.c:1801
iput+0x5c/0x80 fs/inode.c:1791
diFreeSpecial+0x7a/0x110 fs/jfs/jfs_imap.c:549
jfs_mount+0x4fd/0x930 fs/jfs/jfs_mount.c:205
jfs_fill_super+0x5a3/0xd20 fs/jfs/super.c:557
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f0815e7e1ea
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 09 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f0816b8fee8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f0816b8ff80 RCX: 00007f0815e7e1ea
RDX: 0000000020002400 RSI: 0000000020000040 RDI: 00007f0816b8ff40
RBP: 0000000020002400 R08: 00007f0816b8ff80 R09: 0000000000000080
R10: 0000000000000080 R11: 0000000000000246 R12: 0000000020000040
R13: 00007f0816b8ff40 R14: 0000000000002332 R15: 0000000020002500
</TASK>

Allocated by task 5589:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
__kasan_slab_alloc+0x81/0x90 mm/kasan/common.c:328
kasan_slab_alloc include/linux/kasan.h:188 [inline]
slab_post_alloc_hook mm/slab.h:762 [inline]
slab_alloc_node mm/slab.c:3237 [inline]
slab_alloc mm/slab.c:3246 [inline]
__kmem_cache_alloc_lru mm/slab.c:3423 [inline]
kmem_cache_alloc_lru+0x202/0x6d0 mm/slab.c:3439
alloc_inode_sb include/linux/fs.h:2868 [inline]
jfs_alloc_inode+0x25/0x60 fs/jfs/super.c:105
alloc_inode+0x5d/0x220 fs/inode.c:259
new_inode_pseudo fs/inode.c:1004 [inline]
new_inode+0x22/0x260 fs/inode.c:1030
diReadSpecial+0x51/0x6e0 fs/jfs/jfs_imap.c:423
jfs_mount+0x31e/0x930 fs/jfs/jfs_mount.c:166
jfs_fill_super+0x5a3/0xd20 fs/jfs/super.c:557
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 5419:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
kasan_save_free_info+0x28/0x40 mm/kasan/generic.c:522
____kasan_slab_free mm/kasan/common.c:236 [inline]
____kasan_slab_free+0x138/0x190 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:164 [inline]
__cache_free mm/slab.c:3370 [inline]
__do_kmem_cache_free mm/slab.c:3557 [inline]
kmem_cache_free+0x104/0x380 mm/slab.c:3582
i_callback+0x43/0x70 fs/inode.c:248
rcu_do_batch kernel/rcu/tree.c:2139 [inline]
rcu_core+0x805/0x1bb0 kernel/rcu/tree.c:2403
__do_softirq+0x218/0x965 kernel/softirq.c:553

Last potentially related work creation:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
__kasan_record_aux_stack+0x78/0x80 mm/kasan/generic.c:492
__call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:2653
destroy_inode+0x129/0x1b0 fs/inode.c:314
iput_final fs/inode.c:1775 [inline]
iput.part.0+0x55e/0x7a0 fs/inode.c:1801
iput+0x5c/0x80 fs/inode.c:1791
diFreeSpecial+0x7a/0x110 fs/jfs/jfs_imap.c:549
jfs_mount+0x46b/0x930 fs/jfs/jfs_mount.c:192
jfs_fill_super+0x5a3/0xd20 fs/jfs/super.c:557
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff888062a7b140
which belongs to the cache jfs_ip of size 2240
The buggy address is located 944 bytes inside of
freed 2240-byte region [ffff888062a7b140, ffff888062a7ba00)

The buggy address belongs to the physical page:
page:ffffea00018a9ec0 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888062a7bfff pfn:0x62a7b
memcg:ffff88807e5b8401
flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0x1()
raw: 00fff00000000800 ffff888016ad0400 ffffea00018a9e90 ffff8880153b9350
raw: ffff888062a7bfff ffff888062a7b140 0000000100000001 ffff88807e5b8401
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Reclaimable, gfp_mask 0x342050(__GFP_IO|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE|__GFP_RECLAIMABLE), pid 5589, tgid 5587 (syz-executor.1), ts 126698475522, free_ts 26348408774
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1536
prep_new_page mm/page_alloc.c:1543 [inline]
get_page_from_freelist+0xee0/0x2f20 mm/page_alloc.c:3170
__alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4426
__alloc_pages_node include/linux/gfp.h:237 [inline]
kmem_getpages mm/slab.c:1356 [inline]
cache_grow_begin+0x99/0x3a0 mm/slab.c:2550
cache_alloc_refill+0x294/0x3a0 mm/slab.c:2923
____cache_alloc mm/slab.c:2999 [inline]
____cache_alloc mm/slab.c:2982 [inline]
__do_cache_alloc mm/slab.c:3182 [inline]
slab_alloc_node mm/slab.c:3230 [inline]
slab_alloc mm/slab.c:3246 [inline]
__kmem_cache_alloc_lru mm/slab.c:3423 [inline]
kmem_cache_alloc_lru+0x566/0x6d0 mm/slab.c:3439
alloc_inode_sb include/linux/fs.h:2868 [inline]
jfs_alloc_inode+0x25/0x60 fs/jfs/super.c:105
alloc_inode+0x5d/0x220 fs/inode.c:259
new_inode_pseudo fs/inode.c:1004 [inline]
new_inode+0x22/0x260 fs/inode.c:1030
diReadSpecial+0x51/0x6e0 fs/jfs/jfs_imap.c:423
jfs_mount+0x31e/0x930 fs/jfs/jfs_mount.c:166
jfs_fill_super+0x5a3/0xd20 fs/jfs/super.c:557
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1136 [inline]
free_unref_page_prepare+0x476/0xa40 mm/page_alloc.c:2312
free_unref_page+0x33/0x3b0 mm/page_alloc.c:2405
free_contig_range+0xb6/0x190 mm/page_alloc.c:6342
destroy_args+0x768/0x990 mm/debug_vm_pgtable.c:1028
debug_vm_pgtable+0x1d79/0x3e00 mm/debug_vm_pgtable.c:1408
do_one_initcall+0x117/0x630 init/main.c:1232
do_initcall_level init/main.c:1294 [inline]
do_initcalls init/main.c:1310 [inline]
do_basic_setup init/main.c:1329 [inline]
kernel_init_freeable+0x5c2/0x900 init/main.c:1547
kernel_init+0x1c/0x2a0 init/main.c:1437
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304

Memory state around the buggy address:
ffff888062a7b380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888062a7b400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888062a7b480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888062a7b500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888062a7b580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


Tested on:

commit: fe3cfe86 Merge tag 'phy-fixes-6.6' of git://git.kernel..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=1507cb53680000
kernel config: https://syzkaller.appspot.com/x/.config?x=b400c09b1315b112
dashboard link: https://syzkaller.appspot.com/bug?extid=01cf2dbcbe2022454388
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=14f06b51680000

Edward Adam Davis

unread,
Oct 29, 2023, 8:03:53 AM10/29/23
to syzbot+01cf2d...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
please test KASAN: slab-use-after-free Read in jfs_evict_inode

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

diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 920d58a1566b..fc7d4470a4fd 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -152,6 +152,7 @@ void jfs_evict_inode(struct inode *inode)
if (test_cflag(COMMIT_Freewmap, inode))
jfs_free_zero_link(inode);

+ printk("ipimap: %p, %s\n", ipimap, __func__);
if (ipimap && JFS_IP(ipimap)->i_imap)
diFree(inode);

diff --git a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c
index b83aae56a1f2..ae04ddaa63d1 100644
--- a/fs/jfs/jfs_mount.c
+++ b/fs/jfs/jfs_mount.c
@@ -111,6 +111,7 @@ int jfs_mount(struct super_block *sb)
goto err_umount_ipaimap;
}

+ printk("read, ipbmap: %p, fileset:%d, %s\n", ipbmap, JFS_IP(ipbmap)->fileset, __func__);
jfs_info("jfs_mount: ipbmap:0x%p", ipbmap);

sbi->ipbmap = ipbmap;
@@ -170,6 +171,7 @@ int jfs_mount(struct super_block *sb)
rc = -EIO;
goto err_umount_ipaimap2;
}
+ printk("read, ipimap: %p, fileset:%d, %s\n", ipimap, JFS_IP(ipimap)->fileset, __func__);
jfs_info("jfs_mount: ipimap:0x%p", ipimap);

/* map further access of per fileset inodes by the fileset inode */
@@ -188,6 +190,7 @@ int jfs_mount(struct super_block *sb)
*/
err_ipimap:
/* close fileset inode allocation map inode */
+ printk("err, ipimap: %p, fileset:%d, %s\n", ipimap, JFS_IP(ipimap)->fileset, __func__);
diFreeSpecial(ipimap);
err_umount_ipaimap2:
/* close secondary aggregate inode allocation map */
@@ -200,6 +203,7 @@ int jfs_mount(struct super_block *sb)
err_umount_ipbmap: /* close aggregate block allocation map */
dbUnmount(ipbmap, 1);
err_ipbmap: /* close aggregate inodes */
+ printk("err, ipbmap: %p, fileset:%d, %s\n", ipbmap, JFS_IP(ipbmap)->fileset, __func__);

syzbot

unread,
Oct 29, 2023, 8:31:05 AM10/29/23
to ead...@qq.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Read in jfs_evict_inode

err, ipbmap: ffff888063a88630, fileset:16, jfs_mount
ipimap: ffff888063a8a6b0, jfs_evict_inode
==================================================================
BUG: KASAN: slab-use-after-free in jfs_evict_inode+0x4c0/0x4d0 fs/jfs/inode.c:156
Read of size 8 at addr ffff888063a8a630 by task syz-executor.4/5591

CPU: 0 PID: 5591 Comm: syz-executor.4 Not tainted 6.6.0-rc6-syzkaller-00355-gfe3cfe869d5e-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:364 [inline]
print_report+0xc4/0x620 mm/kasan/report.c:475
kasan_report+0xda/0x110 mm/kasan/report.c:588
jfs_evict_inode+0x4c0/0x4d0 fs/jfs/inode.c:156
evict+0x2ed/0x6b0 fs/inode.c:664
iput_final fs/inode.c:1775 [inline]
iput.part.0+0x55e/0x7a0 fs/inode.c:1801
iput+0x5c/0x80 fs/inode.c:1791
diFreeSpecial+0x7a/0x110 fs/jfs/jfs_imap.c:549
jfs_mount+0x58f/0x9e0 fs/jfs/jfs_mount.c:207
jfs_fill_super+0x5a3/0xd20 fs/jfs/super.c:557
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fc15e67e1ea
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 09 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fc15f2fcee8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fc15f2fcf80 RCX: 00007fc15e67e1ea
RDX: 0000000020002400 RSI: 0000000020000040 RDI: 00007fc15f2fcf40
RBP: 0000000020002400 R08: 00007fc15f2fcf80 R09: 0000000000000080
R10: 0000000000000080 R11: 0000000000000246 R12: 0000000020000040
R13: 00007fc15f2fcf40 R14: 0000000000002332 R15: 0000000020002500
</TASK>

Allocated by task 5591:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
__kasan_slab_alloc+0x81/0x90 mm/kasan/common.c:328
kasan_slab_alloc include/linux/kasan.h:188 [inline]
slab_post_alloc_hook mm/slab.h:762 [inline]
slab_alloc_node mm/slab.c:3237 [inline]
slab_alloc mm/slab.c:3246 [inline]
__kmem_cache_alloc_lru mm/slab.c:3423 [inline]
kmem_cache_alloc_lru+0x202/0x6d0 mm/slab.c:3439
alloc_inode_sb include/linux/fs.h:2868 [inline]
jfs_alloc_inode+0x25/0x60 fs/jfs/super.c:105
alloc_inode+0x5d/0x220 fs/inode.c:259
new_inode_pseudo fs/inode.c:1004 [inline]
new_inode+0x22/0x260 fs/inode.c:1030
diReadSpecial+0x51/0x6e0 fs/jfs/jfs_imap.c:423
jfs_mount+0x368/0x9e0 fs/jfs/jfs_mount.c:167
jfs_fill_super+0x5a3/0xd20 fs/jfs/super.c:557
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 5591:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
kasan_save_free_info+0x28/0x40 mm/kasan/generic.c:522
____kasan_slab_free mm/kasan/common.c:236 [inline]
____kasan_slab_free+0x138/0x190 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:164 [inline]
__cache_free mm/slab.c:3370 [inline]
__do_kmem_cache_free mm/slab.c:3557 [inline]
kmem_cache_free+0x104/0x380 mm/slab.c:3582
i_callback+0x43/0x70 fs/inode.c:248
rcu_do_batch kernel/rcu/tree.c:2139 [inline]
rcu_core+0x805/0x1bb0 kernel/rcu/tree.c:2403
__do_softirq+0x218/0x965 kernel/softirq.c:553

Last potentially related work creation:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
__kasan_record_aux_stack+0x78/0x80 mm/kasan/generic.c:492
__call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:2653
destroy_inode+0x129/0x1b0 fs/inode.c:314
iput_final fs/inode.c:1775 [inline]
iput.part.0+0x55e/0x7a0 fs/inode.c:1801
iput+0x5c/0x80 fs/inode.c:1791
diFreeSpecial+0x7a/0x110 fs/jfs/jfs_imap.c:549
jfs_mount+0x501/0x9e0 fs/jfs/jfs_mount.c:194
jfs_fill_super+0x5a3/0xd20 fs/jfs/super.c:557
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff888063a8a280
which belongs to the cache jfs_ip of size 2240
The buggy address is located 944 bytes inside of
freed 2240-byte region [ffff888063a8a280, ffff888063a8ab40)

The buggy address belongs to the physical page:
page:ffffea00018ea280 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888063a8afff pfn:0x63a8a
memcg:ffff88802820a701
flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0x1()
raw: 00fff00000000800 ffff888014fd2200 ffffea00018ea250 ffff8880153fff50
raw: ffff888063a8afff ffff888063a8a280 0000000100000001 ffff88802820a701
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Reclaimable, gfp_mask 0x342050(__GFP_IO|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE|__GFP_RECLAIMABLE), pid 5591, tgid 5590 (syz-executor.4), ts 125532239077, free_ts 24393840795
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1536
prep_new_page mm/page_alloc.c:1543 [inline]
get_page_from_freelist+0xee0/0x2f20 mm/page_alloc.c:3170
__alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4426
__alloc_pages_node include/linux/gfp.h:237 [inline]
kmem_getpages mm/slab.c:1356 [inline]
cache_grow_begin+0x99/0x3a0 mm/slab.c:2550
cache_alloc_refill+0x294/0x3a0 mm/slab.c:2923
____cache_alloc mm/slab.c:2999 [inline]
____cache_alloc mm/slab.c:2982 [inline]
__do_cache_alloc mm/slab.c:3182 [inline]
slab_alloc_node mm/slab.c:3230 [inline]
slab_alloc mm/slab.c:3246 [inline]
__kmem_cache_alloc_lru mm/slab.c:3423 [inline]
kmem_cache_alloc_lru+0x566/0x6d0 mm/slab.c:3439
alloc_inode_sb include/linux/fs.h:2868 [inline]
jfs_alloc_inode+0x25/0x60 fs/jfs/super.c:105
alloc_inode+0x5d/0x220 fs/inode.c:259
new_inode_pseudo fs/inode.c:1004 [inline]
new_inode+0x22/0x260 fs/inode.c:1030
diReadSpecial+0x51/0x6e0 fs/jfs/jfs_imap.c:423
jfs_mount+0x368/0x9e0 fs/jfs/jfs_mount.c:167
jfs_fill_super+0x5a3/0xd20 fs/jfs/super.c:557
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1136 [inline]
free_unref_page_prepare+0x476/0xa40 mm/page_alloc.c:2312
free_unref_page+0x33/0x3b0 mm/page_alloc.c:2405
free_contig_range+0xb6/0x190 mm/page_alloc.c:6342
destroy_args+0x768/0x990 mm/debug_vm_pgtable.c:1028
debug_vm_pgtable+0x1d79/0x3e00 mm/debug_vm_pgtable.c:1408
do_one_initcall+0x117/0x630 init/main.c:1232
do_initcall_level init/main.c:1294 [inline]
do_initcalls init/main.c:1310 [inline]
do_basic_setup init/main.c:1329 [inline]
kernel_init_freeable+0x5c2/0x900 init/main.c:1547
kernel_init+0x1c/0x2a0 init/main.c:1437
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304

Memory state around the buggy address:
ffff888063a8a500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888063a8a580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888063a8a600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888063a8a680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888063a8a700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


Tested on:

commit: fe3cfe86 Merge tag 'phy-fixes-6.6' of git://git.kernel..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=17c7e1b5680000
kernel config: https://syzkaller.appspot.com/x/.config?x=b400c09b1315b112
dashboard link: https://syzkaller.appspot.com/bug?extid=01cf2dbcbe2022454388
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=1489cec7680000

Edward Adam Davis

unread,
Oct 30, 2023, 10:21:54 PM10/30/23
to syzbot+01cf2d...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
please test KASAN: slab-use-after-free Read in jfs_evict_inode

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

diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 1a6b5921d17a..76e94d679d37 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -143,6 +143,7 @@ void jfs_evict_inode(struct inode *inode)
jfs_info("In jfs_evict_inode, inode = 0x%p", inode);

if (!inode->i_nlink && !is_bad_inode(inode)) {
+ printk("inode: %p, fs: %d, %s\n", inode, JFS_IP(inode)->fileset, __func__);
dquot_initialize(inode);

if (JFS_IP(inode)->fileset == FILESYSTEM_I) {
@@ -152,6 +153,7 @@ void jfs_evict_inode(struct inode *inode)
if (test_cflag(COMMIT_Freewmap, inode))
jfs_free_zero_link(inode);

+ printk("inode: %p, ipimap: %p, %s\n", inode, ipimap, __func__);
if (ipimap && JFS_IP(ipimap)->i_imap)
diFree(inode);

diff --git a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c
index 415eb65a36ff..5e059b35440c 100644
index 966826c394ee..5fc7ff044d66 100644

syzbot

unread,
Oct 30, 2023, 10:48:05 PM10/30/23
to ead...@qq.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Read in jfs_evict_inode

==================================================================
BUG: KASAN: slab-use-after-free in jfs_evict_inode+0x4e5/0x520 fs/jfs/inode.c:157
Read of size 8 at addr ffff8880623cc5f0 by task syz-executor.1/5662

CPU: 0 PID: 5662 Comm: syz-executor.1 Not tainted 6.6.0-rc6-syzkaller-00355-gfe3cfe869d5e-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:364 [inline]
print_report+0xc4/0x620 mm/kasan/report.c:475
kasan_report+0xda/0x110 mm/kasan/report.c:588
jfs_evict_inode+0x4e5/0x520 fs/jfs/inode.c:157
evict+0x2ed/0x6b0 fs/inode.c:664
iput_final fs/inode.c:1775 [inline]
iput.part.0+0x55e/0x7a0 fs/inode.c:1801
iput+0x5c/0x80 fs/inode.c:1791
diFreeSpecial+0x7a/0x110 fs/jfs/jfs_imap.c:549
jfs_mount+0x58f/0x9e0 fs/jfs/jfs_mount.c:207
jfs_fill_super+0x5a3/0xd20 fs/jfs/super.c:557
mount_bdev+0x1f3/0x2e0 fs/super.c:1629
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x8c/0x370 fs/super.c:1750
do_new_mount fs/namespace.c:3335 [inline]
path_mount+0x1492/0x1ed0 fs/namespace.c:3662
do_mount fs/namespace.c:3675 [inline]
__do_sys_mount fs/namespace.c:3884 [inline]
__se_sys_mount fs/namespace.c:3861 [inline]
__x64_sys_mount+0x293/0x310 fs/namespace.c:3861
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fc23327e1ea
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 09 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fc234013ee8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fc234013f80 RCX: 00007fc23327e1ea
RDX: 0000000020002400 RSI: 0000000020000040 RDI: 00007fc234013f40
RBP: 0000000020002400 R08: 00007fc234013f80 R09: 0000000000000080
R10: 0000000000000080 R11: 0000000000000246 R12: 0000000020000040
R13: 00007fc234013f40 R14: 0000000000002332 R15: 0000000020002500
</TASK>

Allocated by task 5662:
Freed by task 2785:
The buggy address belongs to the object at ffff8880623cc240
which belongs to the cache jfs_ip of size 2240
The buggy address is located 944 bytes inside of
freed 2240-byte region [ffff8880623cc240, ffff8880623ccb00)

The buggy address belongs to the physical page:
page:ffffea000188f300 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880623ccfff pfn:0x623cc
memcg:ffff888014ec05c1
flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0x1()
raw: 00fff00000000800 ffff888014f62900 ffffea000188f2d0 ffff888015349950
raw: ffff8880623ccfff ffff8880623cc240 0000000100000001 ffff888014ec05c1
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Reclaimable, gfp_mask 0x342050(__GFP_IO|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE|__GFP_RECLAIMABLE), pid 5662, tgid 5661 (syz-executor.1), ts 133529530977, free_ts 25555871525
ffff8880623cc480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880623cc500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880623cc580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880623cc600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880623cc680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


Tested on:

commit: fe3cfe86 Merge tag 'phy-fixes-6.6' of git://git.kernel..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=1437ed73680000
kernel config: https://syzkaller.appspot.com/x/.config?x=b400c09b1315b112
dashboard link: https://syzkaller.appspot.com/bug?extid=01cf2dbcbe2022454388
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=17cfcb53680000

Edward Adam Davis

unread,
Oct 31, 2023, 12:06:39 AM10/31/23
to syzbot+01cf2d...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
please test KASAN: slab-use-after-free Read in jfs_evict_inode

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

diff --git a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c
index 415eb65a36ff..9b5c6a20b30c 100644
--- a/fs/jfs/jfs_mount.c
+++ b/fs/jfs/jfs_mount.c
@@ -172,15 +172,15 @@ int jfs_mount(struct super_block *sb)
}
jfs_info("jfs_mount: ipimap:0x%p", ipimap);

- /* map further access of per fileset inodes by the fileset inode */
- sbi->ipimap = ipimap;
-
/* initialize fileset inode allocation map */
if ((rc = diMount(ipimap))) {
jfs_err("jfs_mount: diMount failed w/rc = %d", rc);
goto err_ipimap;
}

+ /* map further access of per fileset inodes by the fileset inode */
+ sbi->ipimap = ipimap;
+
return rc;

/*

syzbot

unread,
Oct 31, 2023, 12:31:05 AM10/31/23
to ead...@qq.com, syzkall...@googlegroups.com
Hello,

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

Reported-and-tested-by: syzbot+01cf2d...@syzkaller.appspotmail.com

Tested on:

commit: fe3cfe86 Merge tag 'phy-fixes-6.6' of git://git.kernel..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=15941549680000
kernel config: https://syzkaller.appspot.com/x/.config?x=b400c09b1315b112
dashboard link: https://syzkaller.appspot.com/bug?extid=01cf2dbcbe2022454388
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=12d83ab5680000

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

Edward Adam Davis

unread,
Oct 31, 2023, 1:39:20 AM10/31/23
to syzbot+01cf2d...@syzkaller.appspotmail.com, jfs-dis...@lists.sourceforge.net, linux-...@vger.kernel.org, sha...@kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
When the execution of diMount(ipimap) fails, the object ipimap that has been
released may be accessed in diFreeSpecial(). Asynchronous ipimap release occurs
when rcu_core() calls jfs_free_node().

Therefore, when diMount(ipimap) fails, sbi->ipimap should not be initialized as
ipimap.

Reported-and-tested-by: syzbot+01cf2d...@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <ead...@qq.com>
---
fs/jfs/jfs_mount.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c
index 415eb65a36ff..9b5c6a20b30c 100644
--- a/fs/jfs/jfs_mount.c
+++ b/fs/jfs/jfs_mount.c
@@ -172,15 +172,15 @@ int jfs_mount(struct super_block *sb)
}
jfs_info("jfs_mount: ipimap:0x%p", ipimap);

- /* map further access of per fileset inodes by the fileset inode */
- sbi->ipimap = ipimap;
-
/* initialize fileset inode allocation map */
if ((rc = diMount(ipimap))) {
jfs_err("jfs_mount: diMount failed w/rc = %d", rc);
goto err_ipimap;
}

+ /* map further access of per fileset inodes by the fileset inode */
+ sbi->ipimap = ipimap;
+
return rc;

/*
--
2.25.1

Dave Kleikamp

unread,
Nov 1, 2023, 11:48:31 AM11/1/23
to Edward Adam Davis, syzbot+01cf2d...@syzkaller.appspotmail.com, jfs-dis...@lists.sourceforge.net, linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On 10/31/23 12:39AM, Edward Adam Davis wrote:
> When the execution of diMount(ipimap) fails, the object ipimap that has been
> released may be accessed in diFreeSpecial(). Asynchronous ipimap release occurs
> when rcu_core() calls jfs_free_node().
>
> Therefore, when diMount(ipimap) fails, sbi->ipimap should not be initialized as
> ipimap.
>
> Reported-and-tested-by: syzbot+01cf2d...@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <ead...@qq.com>

Looks good.

Thanks,
Shaggy
Reply all
Reply to author
Forward
0 new messages