[v5.15] KASAN: use-after-free Write in diWrite

4 views
Skip to first unread message

syzbot

unread,
Sep 20, 2024, 4:20:26 PM9/20/24
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 3a5928702e71 Linux 5.15.167
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=113ecca9980000
kernel config: https://syzkaller.appspot.com/x/.config?x=171882977b524c53
dashboard link: https://syzkaller.appspot.com/bug?extid=32799a32790e9973dc5b
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/22ee27cb312d/disk-3a592870.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/90bf6a3e3d20/vmlinux-3a592870.xz
kernel image: https://storage.googleapis.com/syzbot-assets/096dd2c73ac3/Image-3a592870.gz.xz

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

==================================================================
BUG: KASAN: use-after-free in diWrite+0xb48/0x1604 fs/jfs/jfs_imap.c:753
Write of size 32 at addr ffff0000d18b52e0 by task syz.3.463/6565

CPU: 1 PID: 6565 Comm: syz.3.463 Not tainted 5.15.167-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Call trace:
dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
print_address_description+0x7c/0x3f0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:434 [inline]
kasan_report+0x174/0x1e4 mm/kasan/report.c:451
kasan_check_range+0x274/0x2b4 mm/kasan/generic.c:189
memcpy+0xb4/0xe8 mm/kasan/shadow.c:66
diWrite+0xb48/0x1604 fs/jfs/jfs_imap.c:753
txCommit+0x754/0x55b0 fs/jfs/jfs_txnmgr.c:1255
jfs_create+0x828/0xa1c fs/jfs/namei.c:156
lookup_open fs/namei.c:3462 [inline]
open_last_lookups fs/namei.c:3532 [inline]
path_openat+0xf18/0x26cc fs/namei.c:3739
do_filp_open+0x1a8/0x3b4 fs/namei.c:3769
do_sys_openat2+0x128/0x3e0 fs/open.c:1253
do_sys_open fs/open.c:1269 [inline]
__do_sys_openat fs/open.c:1285 [inline]
__se_sys_openat fs/open.c:1280 [inline]
__arm64_sys_openat+0x1f0/0x240 fs/open.c:1280
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

Allocated by task 4071:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track mm/kasan/common.c:46 [inline]
set_alloc_info mm/kasan/common.c:434 [inline]
__kasan_slab_alloc+0x8c/0xcc mm/kasan/common.c:467
kasan_slab_alloc include/linux/kasan.h:254 [inline]
slab_post_alloc_hook+0x74/0x3f4 mm/slab.h:519
slab_alloc_node mm/slub.c:3220 [inline]
kmem_cache_alloc_node+0x208/0x49c mm/slub.c:3256
__alloc_skb+0x174/0x584 net/core/skbuff.c:415
alloc_skb include/linux/skbuff.h:1167 [inline]
nsim_dev_trap_skb_build drivers/net/netdevsim/dev.c:664 [inline]
nsim_dev_trap_report drivers/net/netdevsim/dev.c:721 [inline]
nsim_dev_trap_report_work+0x1e4/0x90c drivers/net/netdevsim/dev.c:762
process_one_work+0x790/0x11b8 kernel/workqueue.c:2310
worker_thread+0x910/0x1034 kernel/workqueue.c:2457
kthread+0x37c/0x45c kernel/kthread.c:334
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:870

Freed by task 4071:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4c/0x84 mm/kasan/common.c:46
kasan_set_free_info+0x28/0x4c mm/kasan/generic.c:360
____kasan_slab_free+0x118/0x164 mm/kasan/common.c:366
__kasan_slab_free+0x18/0x28 mm/kasan/common.c:374
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:1705 [inline]
slab_free_freelist_hook+0x128/0x1ec mm/slub.c:1731
slab_free mm/slub.c:3499 [inline]
kmem_cache_free+0xdc/0x3c4 mm/slub.c:3515
kfree_skbmem+0x114/0x1b0
__kfree_skb net/core/skbuff.c:757 [inline]
consume_skb+0x140/0x40c net/core/skbuff.c:914
nsim_dev_trap_report drivers/net/netdevsim/dev.c:737 [inline]
nsim_dev_trap_report_work+0x618/0x90c drivers/net/netdevsim/dev.c:762
process_one_work+0x790/0x11b8 kernel/workqueue.c:2310
worker_thread+0x910/0x1034 kernel/workqueue.c:2457
kthread+0x37c/0x45c kernel/kthread.c:334
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:870

The buggy address belongs to the object at ffff0000d18b5280
which belongs to the cache skbuff_head_cache of size 232
The buggy address is located 96 bytes inside of
232-byte region [ffff0000d18b5280, ffff0000d18b5368)
The buggy address belongs to the page:
page:00000000fd0c3923 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1118b5
flags: 0x5ffc00000000200(slab|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000000200 fffffc0003561f80 0000000400000002 ffff0000c086a000
raw: 0000000000000000 00000000000c000c 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff0000d18b5180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff0000d18b5200: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc
>ffff0000d18b5280: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff0000d18b5300: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc
ffff0000d18b5380: fc fc fc fc fc fc fc fc 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 report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

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

syzbot

unread,
Dec 28, 2024, 4:44:26 PM12/28/24
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 91786f140358 Linux 5.15.175
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1064c818580000
kernel config: https://syzkaller.appspot.com/x/.config?x=1fc30776feb70ea7
dashboard link: https://syzkaller.appspot.com/bug?extid=32799a32790e9973dc5b
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=111a32c4580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1464c818580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/210b1e4b59b1/disk-91786f14.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/1cf8391059a0/vmlinux-91786f14.xz
kernel image: https://storage.googleapis.com/syzbot-assets/1d9077a44b1c/bzImage-91786f14.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/cb29777164b4/mount_0.gz

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

loop0: detected capacity change from 0 to 32768
==================================================================
BUG: KASAN: slab-out-of-bounds in diWrite+0xddb/0x19b0 fs/jfs/jfs_imap.c:753
Write of size 32 at addr ffff88801f7270c0 by task syz-executor411/4164

CPU: 1 PID: 4164 Comm: syz-executor411 Not tainted 5.15.175-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
print_address_description+0x63/0x3b0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:434 [inline]
kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
kasan_check_range+0x27e/0x290 mm/kasan/generic.c:189
memcpy+0x3c/0x60 mm/kasan/shadow.c:66
diWrite+0xddb/0x19b0 fs/jfs/jfs_imap.c:753
txCommit+0xa13/0x6ba0 fs/jfs/jfs_txnmgr.c:1255
add_missing_indices+0x8af/0xbf0 fs/jfs/jfs_dtree.c:2959
jfs_readdir+0x2008/0x3bc0 fs/jfs/jfs_dtree.c:3315
iterate_dir+0x224/0x570
__do_sys_getdents64 fs/readdir.c:369 [inline]
__se_sys_getdents64+0x209/0x4f0 fs/readdir.c:354
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f0b357ea159
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 1c 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:00007ffc9ac7a618 EFLAGS: 00000246 ORIG_RAX: 00000000000000d9
RAX: ffffffffffffffda RBX: 00007f0b3582e269 RCX: 00007f0b357ea159
RDX: 000000000000009e RSI: 0000000020000280 RDI: 0000000000000004
RBP: 00007f0b3582e239 R08: 00007ffc9ac7a690 R09: 00007ffc9ac7a690
R10: 00007ffc9ac7a690 R11: 0000000000000246 R12: 00007f0b3582e1d7
R13: 00007f0b3582e0ed R14: 00007f0b3582e05f R15: 00007ffc9ac7a648
</TASK>

Allocated by task 1:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track mm/kasan/common.c:46 [inline]
set_alloc_info mm/kasan/common.c:434 [inline]
____kasan_kmalloc+0xba/0xf0 mm/kasan/common.c:513
kasan_kmalloc include/linux/kasan.h:264 [inline]
kmem_cache_alloc_trace+0x143/0x290 mm/slub.c:3247
kmalloc include/linux/slab.h:591 [inline]
kzalloc include/linux/slab.h:721 [inline]
drm_property_add_enum+0x1b2/0x3c0 drivers/gpu/drm/drm_property.c:420
drm_property_create_enum+0xb0/0x140 drivers/gpu/drm/drm_property.c:177
drm_connector_create_standard_properties+0x14b/0x240 drivers/gpu/drm/drm_connector.c:1288
drm_mode_create_standard_properties drivers/gpu/drm/drm_mode_config.c:223 [inline]
drmm_mode_config_init+0x566/0x1460 drivers/gpu/drm/drm_mode_config.c:424
drm_mode_config_init include/drm/drm_mode_config.h:967 [inline]
vkms_modeset_init drivers/gpu/drm/vkms/vkms_drv.c:145 [inline]
vkms_create drivers/gpu/drm/vkms/vkms_drv.c:201 [inline]
vkms_init+0x35d/0x6d0 drivers/gpu/drm/vkms/vkms_drv.c:235
do_one_initcall+0x22b/0x7a0 init/main.c:1302
do_initcall_level+0x157/0x210 init/main.c:1375
do_initcalls+0x49/0x90 init/main.c:1391
kernel_init_freeable+0x425/0x5c0 init/main.c:1615
kernel_init+0x19/0x290 init/main.c:1506
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

The buggy address belongs to the object at ffff88801f727080
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes to the right of
64-byte region [ffff88801f727080, ffff88801f7270c0)
The buggy address belongs to the page:
page:ffffea00007dc9c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1f727
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 0000000400000001 ffff888017441640
raw: 0000000000000000 0000000000200020 00000001ffffffff 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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 1, ts 8012677507, free_ts 8010666038
prep_new_page mm/page_alloc.c:2426 [inline]
get_page_from_freelist+0x3b78/0x3d40 mm/page_alloc.c:4192
__alloc_pages+0x272/0x700 mm/page_alloc.c:5465
alloc_page_interleave+0x22/0x1c0 mm/mempolicy.c:2031
alloc_slab_page mm/slub.c:1775 [inline]
allocate_slab mm/slub.c:1912 [inline]
new_slab+0xbb/0x4b0 mm/slub.c:1975
___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
__slab_alloc mm/slub.c:3095 [inline]
slab_alloc_node mm/slub.c:3186 [inline]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc_trace+0x1a0/0x290 mm/slub.c:3245
kmalloc include/linux/slab.h:591 [inline]
kzalloc include/linux/slab.h:721 [inline]
drm_property_add_enum+0x1b2/0x3c0 drivers/gpu/drm/drm_property.c:420
drm_property_create_enum+0xb0/0x140 drivers/gpu/drm/drm_property.c:177
drm_connector_create_standard_properties+0x7a/0x240 drivers/gpu/drm/drm_connector.c:1265
drm_mode_create_standard_properties drivers/gpu/drm/drm_mode_config.c:223 [inline]
drmm_mode_config_init+0x566/0x1460 drivers/gpu/drm/drm_mode_config.c:424
drm_mode_config_init include/drm/drm_mode_config.h:967 [inline]
vkms_modeset_init drivers/gpu/drm/vkms/vkms_drv.c:145 [inline]
vkms_create drivers/gpu/drm/vkms/vkms_drv.c:201 [inline]
vkms_init+0x35d/0x6d0 drivers/gpu/drm/vkms/vkms_drv.c:235
do_one_initcall+0x22b/0x7a0 init/main.c:1302
do_initcall_level+0x157/0x210 init/main.c:1375
do_initcalls+0x49/0x90 init/main.c:1391
kernel_init_freeable+0x425/0x5c0 init/main.c:1615
kernel_init+0x19/0x290 init/main.c:1506
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1340 [inline]
free_pcp_prepare mm/page_alloc.c:1391 [inline]
free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
__vunmap+0x8d4/0xa20 mm/vmalloc.c:2621
free_work+0x57/0x80 mm/vmalloc.c:95
process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
kthread+0x3f6/0x4f0 kernel/kthread.c:334
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

Memory state around the buggy address:
ffff88801f726f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88801f727000: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
>ffff88801f727080: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
^
ffff88801f727100: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
ffff88801f727180: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
==================================================================


---
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,
4:16 PM (4 hours ago) 4:16 PM
to syzkaller...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit f98bf80b20f4a930589cda48a35f751a64fe0dc2
Author: Edward Adam Davis <ead...@qq.com>
Date: Thu Apr 11 12:05:28 2024 +0000

jfs: fix null ptr deref in dtInsertEntry

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=13f02134580000
start commit: 98f47d0e9b8c Linux 5.15.184
git tree: linux-5.15.y
kernel config: https://syzkaller.appspot.com/x/.config?x=6d966a9f787a9782
dashboard link: https://syzkaller.appspot.com/bug?extid=32799a32790e9973dc5b
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11bd400c580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17eeded4580000

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

#syz fix: jfs: fix null ptr deref in dtInsertEntry

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