[syzbot] KASAN: use-after-free Read in gsm_cleanup_mux

22 views
Skip to first unread message

syzbot

unread,
Nov 1, 2022, 9:52:51 AM11/1/22
to gre...@linuxfoundation.org, jiri...@kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: b229b6ca5abb Merge tag 'perf-tools-fixes-for-v6.1-2022-10-..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=135f174a880000
kernel config: https://syzkaller.appspot.com/x/.config?x=a66c6c673fb555e8
dashboard link: https://syzkaller.appspot.com/bug?extid=893c55305230e719a203
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/7a7054f95968/disk-b229b6ca.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/907d97ef4d30/vmlinux-b229b6ca.xz
kernel image: https://storage.googleapis.com/syzbot-assets/5f5f3eb6d623/bzImage-b229b6ca.xz

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

==================================================================
BUG: KASAN: use-after-free in gsm_cleanup_mux+0x785/0x800 drivers/tty/n_gsm.c:2487
Read of size 4 at addr ffff888043d4900c by task syz-executor.0/29846

CPU: 0 PID: 29846 Comm: syz-executor.0 Not tainted 6.1.0-rc2-syzkaller-00105-gb229b6ca5abb #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/11/2022
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:284 [inline]
print_report+0x15e/0x45d mm/kasan/report.c:395
kasan_report+0xbb/0x1f0 mm/kasan/report.c:495
gsm_cleanup_mux+0x785/0x800 drivers/tty/n_gsm.c:2487
gsm_config drivers/tty/n_gsm.c:2752 [inline]
gsmld_ioctl+0x52f/0x1060 drivers/tty/n_gsm.c:3113
tty_ioctl+0x741/0x1590 drivers/tty/tty_io.c:2780
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl fs/ioctl.c:856 [inline]
__x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fe6f6a8b5a9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fe6f5dff168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fe6f6bac050 RCX: 00007fe6f6a8b5a9
RDX: 0000000020000040 RSI: 00000000404c4701 RDI: 0000000000000004
RBP: 00007fe6f6ae67b0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fe6f6ccfb1f R14: 00007fe6f5dff300 R15: 0000000000022000
</TASK>

Allocated by task 29778:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45
kasan_set_track+0x21/0x30 mm/kasan/common.c:52
____kasan_kmalloc mm/kasan/common.c:371 [inline]
____kasan_kmalloc mm/kasan/common.c:330 [inline]
__kasan_kmalloc+0xa1/0xb0 mm/kasan/common.c:380
kmalloc include/linux/slab.h:576 [inline]
kzalloc include/linux/slab.h:712 [inline]
gsm_dlci_alloc+0x46/0x480 drivers/tty/n_gsm.c:2060
gsm_activate_mux drivers/tty/n_gsm.c:2534 [inline]
gsm_config drivers/tty/n_gsm.c:2776 [inline]
gsmld_ioctl+0x7fc/0x1060 drivers/tty/n_gsm.c:3113
tty_ioctl+0x741/0x1590 drivers/tty/tty_io.c:2780
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl fs/ioctl.c:856 [inline]
__x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 29841:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45
kasan_set_track+0x21/0x30 mm/kasan/common.c:52
kasan_save_free_info+0x2a/0x40 mm/kasan/generic.c:511
____kasan_slab_free mm/kasan/common.c:236 [inline]
____kasan_slab_free+0x160/0x1c0 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:177 [inline]
slab_free_hook mm/slub.c:1724 [inline]
slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1750
slab_free mm/slub.c:3661 [inline]
__kmem_cache_free+0xab/0x3b0 mm/slub.c:3674
tty_port_destructor drivers/tty/tty_port.c:296 [inline]
kref_put include/linux/kref.h:65 [inline]
tty_port_put+0x158/0x1c0 drivers/tty/tty_port.c:311
dlci_put drivers/tty/n_gsm.c:2116 [inline]
gsm_dlci_release drivers/tty/n_gsm.c:2149 [inline]
gsm_cleanup_mux+0x2f6/0x800 drivers/tty/n_gsm.c:2508
gsm_config drivers/tty/n_gsm.c:2752 [inline]
gsmld_ioctl+0x52f/0x1060 drivers/tty/n_gsm.c:3113
tty_ioctl+0x741/0x1590 drivers/tty/tty_io.c:2780
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl fs/ioctl.c:856 [inline]
__x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Last potentially related work creation:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45
__kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:481
call_rcu+0x99/0x820 kernel/rcu/tree.c:2798
netlink_release+0xeff/0x1db0 net/netlink/af_netlink.c:815
__sock_release net/socket.c:650 [inline]
sock_release+0x87/0x1b0 net/socket.c:678
netlink_kernel_release+0x4b/0x60 net/netlink/af_netlink.c:2107
nfnetlink_net_exit_batch+0x10e/0x320 net/netfilter/nfnetlink.c:781
ops_exit_list+0x125/0x170 net/core/net_namespace.c:174
cleanup_net+0x4ea/0xb00 net/core/net_namespace.c:601
process_one_work+0x9bf/0x1710 kernel/workqueue.c:2289
worker_thread+0x665/0x1080 kernel/workqueue.c:2436
kthread+0x2e4/0x3a0 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

Second to last potentially related work creation:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45
__kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:481
call_rcu+0x99/0x820 kernel/rcu/tree.c:2798
netlink_release+0xeff/0x1db0 net/netlink/af_netlink.c:815
__sock_release+0xcd/0x280 net/socket.c:650
sock_close+0x18/0x20 net/socket.c:1365
__fput+0x27c/0xa90 fs/file_table.c:320
task_work_run+0x16b/0x270 kernel/task_work.c:179
exit_task_work include/linux/task_work.h:38 [inline]
do_exit+0xb35/0x2a20 kernel/exit.c:820
do_group_exit+0xd0/0x2a0 kernel/exit.c:950
get_signal+0x21a1/0x2430 kernel/signal.c:2858
arch_do_signal_or_restart+0x82/0x2300 arch/x86/kernel/signal.c:869
exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:296
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff888043d49000
which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 12 bytes inside of
2048-byte region [ffff888043d49000, ffff888043d49800)

The buggy address belongs to the physical page:
page:ffffea00010f5200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x43d48
head:ffffea00010f5200 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000001 ffff888011842000
raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3654, tgid 3654 (syz-executor.0), ts 139828475845, free_ts 12080707870
prep_new_page mm/page_alloc.c:2538 [inline]
get_page_from_freelist+0x10b5/0x2d50 mm/page_alloc.c:4287
__alloc_pages+0x1c7/0x5a0 mm/page_alloc.c:5554
alloc_pages+0x1a6/0x270 mm/mempolicy.c:2285
alloc_slab_page mm/slub.c:1794 [inline]
allocate_slab+0x213/0x300 mm/slub.c:1939
new_slab mm/slub.c:1992 [inline]
___slab_alloc+0xa91/0x1400 mm/slub.c:3180
__slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3279
slab_alloc_node mm/slub.c:3364 [inline]
__kmem_cache_alloc_node+0x191/0x3e0 mm/slub.c:3437
__do_kmalloc_node mm/slab_common.c:954 [inline]
__kmalloc+0x44/0xc0 mm/slab_common.c:968
kmalloc include/linux/slab.h:581 [inline]
kzalloc include/linux/slab.h:712 [inline]
ops_init+0x241/0x680 net/core/net_namespace.c:125
setup_net+0x5d1/0xc50 net/core/net_namespace.c:332
copy_net_ns+0x318/0x760 net/core/net_namespace.c:478
create_new_namespaces+0x3f6/0xb20 kernel/nsproxy.c:110
unshare_nsproxy_namespaces+0xc1/0x1f0 kernel/nsproxy.c:226
ksys_unshare+0x445/0x920 kernel/fork.c:3188
__do_sys_unshare kernel/fork.c:3259 [inline]
__se_sys_unshare kernel/fork.c:3257 [inline]
__x64_sys_unshare+0x2d/0x40 kernel/fork.c:3257
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1458 [inline]
free_pcp_prepare+0x65c/0xd90 mm/page_alloc.c:1508
free_unref_page_prepare mm/page_alloc.c:3386 [inline]
free_unref_page+0x19/0x4d0 mm/page_alloc.c:3482
free_contig_range+0xb1/0x180 mm/page_alloc.c:9492
destroy_args+0xa8/0x64c mm/debug_vm_pgtable.c:1031
debug_vm_pgtable+0x2954/0x29e5 mm/debug_vm_pgtable.c:1354
do_one_initcall+0x13d/0x780 init/main.c:1303
do_initcall_level init/main.c:1376 [inline]
do_initcalls init/main.c:1392 [inline]
do_basic_setup init/main.c:1411 [inline]
kernel_init_freeable+0x6ff/0x788 init/main.c:1631
kernel_init+0x1a/0x1d0 init/main.c:1519
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

Memory state around the buggy address:
ffff888043d48f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888043d48f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888043d49000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888043d49080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888043d49100: 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.

syzbot

unread,
Dec 2, 2022, 11:57:46 PM12/2/22
to gre...@linuxfoundation.org, jiri...@kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: a4412fdd49dc error-injection: Add prompt for function erro..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=1323ec29880000
kernel config: https://syzkaller.appspot.com/x/.config?x=cc4b2e0a8e8a8366
dashboard link: https://syzkaller.appspot.com/bug?extid=893c55305230e719a203
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12b1ca83880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1023c5e3880000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/5ed30eeb21a0/disk-a4412fdd.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/db67a8a7ac7c/vmlinux-a4412fdd.xz
kernel image: https://storage.googleapis.com/syzbot-assets/8ee62d01893d/bzImage-a4412fdd.xz

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

==================================================================
BUG: KASAN: use-after-free in gsm_cleanup_mux+0x785/0x800 drivers/tty/n_gsm.c:2491
Read of size 4 at addr ffff88802179600c by task syz-executor417/3673

CPU: 0 PID: 3673 Comm: syz-executor417 Not tainted 6.1.0-rc7-syzkaller-00123-ga4412fdd49dc #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:284 [inline]
print_report+0x15e/0x45d mm/kasan/report.c:395
kasan_report+0xbf/0x1f0 mm/kasan/report.c:495
gsm_cleanup_mux+0x785/0x800 drivers/tty/n_gsm.c:2491
gsm_config drivers/tty/n_gsm.c:2754 [inline]
gsmld_ioctl+0x533/0x1060 drivers/tty/n_gsm.c:3117
tty_ioctl+0x7eb/0x1660 drivers/tty/tty_io.c:2780
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl fs/ioctl.c:856 [inline]
__x64_sys_ioctl+0x197/0x210 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f3dad9cbc79
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 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:00007f3dad95c318 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f3dada534d8 RCX: 00007f3dad9cbc79
RDX: 0000000020000040 RSI: 00000000404c4701 RDI: 0000000000000005
RBP: 00007f3dada534d0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f3dada2107c
R13: 00007fff3c20a04f R14: 00007f3dad95c400 R15: 0000000000022000
</TASK>

Allocated by task 3672:
kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
____kasan_kmalloc mm/kasan/common.c:371 [inline]
____kasan_kmalloc mm/kasan/common.c:330 [inline]
__kasan_kmalloc+0xa5/0xb0 mm/kasan/common.c:380
kmalloc include/linux/slab.h:553 [inline]
kzalloc include/linux/slab.h:689 [inline]
gsm_dlci_alloc+0x46/0x480 drivers/tty/n_gsm.c:2064
gsm_activate_mux drivers/tty/n_gsm.c:2538 [inline]
gsm_config drivers/tty/n_gsm.c:2778 [inline]
gsmld_ioctl+0x800/0x1060 drivers/tty/n_gsm.c:3117
tty_ioctl+0x7eb/0x1660 drivers/tty/tty_io.c:2780
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl fs/ioctl.c:856 [inline]
__x64_sys_ioctl+0x197/0x210 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 3672:
kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
kasan_save_free_info+0x2e/0x40 mm/kasan/generic.c:511
____kasan_slab_free mm/kasan/common.c:236 [inline]
____kasan_slab_free+0x160/0x1c0 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:177 [inline]
slab_free_hook mm/slub.c:1724 [inline]
slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1750
slab_free mm/slub.c:3661 [inline]
__kmem_cache_free+0xaf/0x3b0 mm/slub.c:3674
tty_port_destructor drivers/tty/tty_port.c:296 [inline]
kref_put include/linux/kref.h:65 [inline]
tty_port_put+0x15c/0x1c0 drivers/tty/tty_port.c:311
dlci_put drivers/tty/n_gsm.c:2120 [inline]
gsm_dlci_release drivers/tty/n_gsm.c:2153 [inline]
gsm_cleanup_mux+0x2f6/0x800 drivers/tty/n_gsm.c:2512
gsm_config drivers/tty/n_gsm.c:2754 [inline]
gsmld_ioctl+0x533/0x1060 drivers/tty/n_gsm.c:3117
tty_ioctl+0x7eb/0x1660 drivers/tty/tty_io.c:2780
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl fs/ioctl.c:856 [inline]
__x64_sys_ioctl+0x197/0x210 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Last potentially related work creation:
kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
__kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:481
call_rcu+0x9d/0x820 kernel/rcu/tree.c:2798
netlink_release+0xf0f/0x1dd0 net/netlink/af_netlink.c:815
__sock_release+0xcd/0x280 net/socket.c:650
sock_close+0x1c/0x20 net/socket.c:1365
__fput+0x27c/0xa90 fs/file_table.c:320
task_work_run+0x16f/0x270 kernel/task_work.c:179
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
exit_to_user_mode_prepare+0x23c/0x250 kernel/entry/common.c:203
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296
do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Second to last potentially related work creation:
kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
__kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:481
call_rcu+0x9d/0x820 kernel/rcu/tree.c:2798
netlink_release+0xf0f/0x1dd0 net/netlink/af_netlink.c:815
__sock_release+0xcd/0x280 net/socket.c:650
sock_close+0x1c/0x20 net/socket.c:1365
__fput+0x27c/0xa90 fs/file_table.c:320
task_work_run+0x16f/0x270 kernel/task_work.c:179
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
exit_to_user_mode_prepare+0x23c/0x250 kernel/entry/common.c:203
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296
do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff888021796000
which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 12 bytes inside of
2048-byte region [ffff888021796000, ffff888021796800)

The buggy address belongs to the physical page:
page:ffffea000085e400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x21790
head:ffffea000085e400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea000060b200 dead000000000002 ffff888012042000
raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 9, tgid 9 (kworker/u4:0), ts 8642632567, free_ts 0
prep_new_page mm/page_alloc.c:2539 [inline]
get_page_from_freelist+0x10b5/0x2d50 mm/page_alloc.c:4291
__alloc_pages+0x1cb/0x5b0 mm/page_alloc.c:5558
alloc_pages+0x1aa/0x270 mm/mempolicy.c:2285
alloc_slab_page mm/slub.c:1794 [inline]
allocate_slab+0x213/0x300 mm/slub.c:1939
new_slab mm/slub.c:1992 [inline]
___slab_alloc+0xa91/0x1400 mm/slub.c:3180
__slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3279
slab_alloc_node mm/slub.c:3364 [inline]
__kmem_cache_alloc_node+0x199/0x3e0 mm/slub.c:3437
__do_kmalloc_node mm/slab_common.c:954 [inline]
__kmalloc+0x4a/0xd0 mm/slab_common.c:968
kmalloc include/linux/slab.h:558 [inline]
kzalloc include/linux/slab.h:689 [inline]
scsi_alloc_target+0x132/0xc60 drivers/scsi/scsi_scan.c:504
__scsi_scan_target+0x13a/0xdb0 drivers/scsi/scsi_scan.c:1648
scsi_scan_channel drivers/scsi/scsi_scan.c:1753 [inline]
scsi_scan_channel+0x148/0x1e0 drivers/scsi/scsi_scan.c:1729
scsi_scan_host_selected+0x2e3/0x3b0 drivers/scsi/scsi_scan.c:1782
do_scsi_scan_host+0x1e8/0x260 drivers/scsi/scsi_scan.c:1921
do_scan_async+0x42/0x500 drivers/scsi/scsi_scan.c:1931
async_run_entry_fn+0x9c/0x530 kernel/async.c:127
process_one_work+0x9bf/0x1710 kernel/workqueue.c:2289
page_owner free stack trace missing

Memory state around the buggy address:
ffff888021795f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888021795f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888021796000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888021796080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888021796100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Hillf Danton

unread,
Dec 3, 2022, 2:49:07 AM12/3/22
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On 02 Dec 2022 20:57:45 -0800
> syzbot has found a reproducer for the following issue on:
>
> HEAD commit: a4412fdd49dc error-injection: Add prompt for function erro..
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1023c5e3880000

Check dlci under gsm->mutex.

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

--- x/drivers/tty/n_gsm.c
+++ y/drivers/tty/n_gsm.c
@@ -2481,12 +2481,13 @@ static void gsm_error(struct gsm_mux *gs
static void gsm_cleanup_mux(struct gsm_mux *gsm, bool disc)
{
int i;
- struct gsm_dlci *dlci = gsm->dlci[0];
+ struct gsm_dlci *dlci;
struct gsm_msg *txq, *ntxq;

gsm->dead = true;
mutex_lock(&gsm->mutex);

+ dlci = gsm->dlci[0];
if (dlci) {
if (disc && dlci->state != DLCI_CLOSED) {
gsm_dlci_begin_close(dlci);
@@ -2508,8 +2509,10 @@ static void gsm_cleanup_mux(struct gsm_m
gsm->has_devices = false;
}
for (i = NUM_DLCI - 1; i >= 0; i--)
- if (gsm->dlci[i])
+ if (gsm->dlci[i]) {
gsm_dlci_release(gsm->dlci[i]);
+ gsm->dlci[i] = NULL;
+ }
mutex_unlock(&gsm->mutex);
/* Now wipe the queues */
tty_ldisc_flush(gsm->tty);
--

syzbot

unread,
Dec 3, 2022, 3:56:21 AM12/3/22
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

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

Reported-and-tested-by: syzbot+893c55...@syzkaller.appspotmail.com

Tested on:

commit: a4412fdd error-injection: Add prompt for function erro..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=152efe6b880000
kernel config: https://syzkaller.appspot.com/x/.config?x=cc4b2e0a8e8a8366
dashboard link: https://syzkaller.appspot.com/bug?extid=893c55305230e719a203
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=105f3bad880000

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

syzbot

unread,
Sep 25, 2023, 7:55:27 AM9/25/23
to daniel...@siemens.com, gre...@linuxfoundation.org, hda...@sina.com, jiri...@kernel.org, linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
syzbot has bisected this issue to:

commit 01aecd917114577c423f07cec0d186ad007d76fc
Author: Daniel Starke <daniel...@siemens.com>
Date: Fri Jul 1 06:16:45 2022 +0000

tty: n_gsm: fix tty registration before control channel open

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=10d431ea680000
start commit: a4412fdd49dc error-injection: Add prompt for function erro..
git tree: upstream
final oops: https://syzkaller.appspot.com/x/report.txt?x=12d431ea680000
console output: https://syzkaller.appspot.com/x/log.txt?x=14d431ea680000
Reported-by: syzbot+893c55...@syzkaller.appspotmail.com
Fixes: 01aecd917114 ("tty: n_gsm: fix tty registration before control channel open")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

Hillf Danton

unread,
Sep 26, 2023, 7:14:11 AM9/26/23
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Mon, 25 Sep 2023 04:55:26 -0700
> syzbot has bisected this issue to:
>
> commit 01aecd917114577c423f07cec0d186ad007d76fc
> Author: Daniel Starke <daniel...@siemens.com>
> Date: Fri Jul 1 06:16:45 2022 +0000
>
> tty: n_gsm: fix tty registration before control channel open

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

--- x/drivers/tty/n_gsm.c
+++ y/drivers/tty/n_gsm.c
@@ -3126,7 +3126,9 @@ static int gsm_activate_mux(struct gsm_m
struct gsm_dlci *dlci;
int ret;

+ mutex_lock(&gsm->mutex);
dlci = gsm_dlci_alloc(gsm, 0);
+ mutex_unlock(&gsm->mutex);
if (dlci == NULL)
return -ENOMEM;

--

syzbot

unread,
Sep 26, 2023, 7:38:28 AM9/26/23
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

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

Reported-and-tested-by: syzbot+893c55...@syzkaller.appspotmail.com

Tested on:

commit: 6465e260 Linux 6.6-rc3
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=11c6d11e680000
kernel config: https://syzkaller.appspot.com/x/.config?x=50b6fcb179f758ed
dashboard link: https://syzkaller.appspot.com/bug?extid=893c55305230e719a203
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=13dd0012680000

syzbot

unread,
Oct 1, 2023, 12:29:25 AM10/1/23
to daniel...@siemens.com, gre...@linuxfoundation.org, hda...@sina.com, jiri...@kernel.org, linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com, yiya...@huawei.com, zhangq...@huawei.com
syzbot suspects this issue was fixed by commit:

commit 3c4f8333b582487a2d1e02171f1465531cde53e3
Author: Yi Yang <yiya...@huawei.com>
Date: Fri Aug 11 03:11:21 2023 +0000

tty: n_gsm: fix the UAF caused by race condition in gsm_cleanup_mux

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=121e6a92680000
start commit: a4412fdd49dc error-injection: Add prompt for function erro..
git tree: upstream
If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: tty: n_gsm: fix the UAF caused by race condition in gsm_cleanup_mux

Aleksandr Nogikh

unread,
Oct 2, 2023, 7:40:14 AM10/2/23
to syzbot, daniel...@siemens.com, gre...@linuxfoundation.org, hda...@sina.com, jiri...@kernel.org, linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com, yiya...@huawei.com, zhangq...@huawei.com
> --
Reply all
Reply to author
Forward
0 new messages