syzbot


KASAN: use-after-free Read in nfc_llcp_sock_unlink

Status: fixed on 2021/06/23 17:43
Reported-by: syzbot+174a4f09354b9dacb1bd@syzkaller.appspotmail.com
Fix commit: 48fba458fe54 net/nfc: fix use-after-free llcp_sock_bind/connect
First crash: 1317d, last: 1279d
Fix bisection: fixed by (bisect log) :
commit 48fba458fe54cc2a980a05c13e6c19b8b2cfb610
Author: Or Cohen <orcohen@paloaltonetworks.com>
Date: Tue May 4 07:16:46 2021 +0000

  net/nfc: fix use-after-free llcp_sock_bind/connect

  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in nfc_llcp_sock_unlink net nfc C done done 68 1293d 1332d 0/28 auto-obsoleted due to no activity on 2022/09/14 15:37
linux-4.14 KASAN: use-after-free Read in nfc_llcp_sock_unlink C error 13 803d 1313d 0/1 upstream: reported C repro on 2021/04/17 16:59

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x2cb4/0x3ff0 kernel/locking/lockdep.c:3295
Read of size 8 at addr ffff888238ae35d0 by task syz-executor880/8113

CPU: 1 PID: 8113 Comm: syz-executor880 Not tainted 4.19.189-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
 print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
 kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
 kasan_report mm/kasan/report.c:412 [inline]
 __asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433
 __lock_acquire+0x2cb4/0x3ff0 kernel/locking/lockdep.c:3295
 lock_acquire+0x170/0x3c0 kernel/locking/lockdep.c:3908
 __raw_write_lock include/linux/rwlock_api_smp.h:210 [inline]
 _raw_write_lock+0x2a/0x40 kernel/locking/spinlock.c:288
 nfc_llcp_sock_unlink+0x1d/0x190 net/nfc/llcp_core.c:44
 llcp_sock_release+0x286/0x520 net/nfc/llcp_sock.c:652
 __sock_release+0xcd/0x2a0 net/socket.c:579
 sock_close+0x15/0x20 net/socket.c:1140
 __fput+0x2ce/0x890 fs/file_table.c:278
 task_work_run+0x148/0x1c0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xbf3/0x2be0 kernel/exit.c:870
 do_group_exit+0x125/0x310 kernel/exit.c:967
 __do_sys_exit_group kernel/exit.c:978 [inline]
 __se_sys_exit_group kernel/exit.c:976 [inline]
 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:976
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x43db99
Code: Bad RIP value.
RSP: 002b:00007ffe77888748 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00000000004ae230 RCX: 000000000043db99
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffffffffffffffc0 R09: 0000000000400488
R10: 0000000000400488 R11: 0000000000000246 R12: 00000000004ae230
R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001

Allocated by task 1:
 kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
 kmalloc include/linux/slab.h:515 [inline]
 kzalloc include/linux/slab.h:709 [inline]
 nfc_llcp_register_device+0x45/0x9b0 net/nfc/llcp_core.c:1584
 nfc_register_device+0x6d/0x360 net/nfc/core.c:1129
 nfcsim_device_new+0x333/0x5af drivers/nfc/nfcsim.c:417
 nfcsim_init+0x71/0x14d drivers/nfc/nfcsim.c:464
 do_one_initcall+0xf1/0x740 init/main.c:884
 do_initcall_level init/main.c:952 [inline]
 do_initcalls init/main.c:960 [inline]
 do_basic_setup init/main.c:978 [inline]
 kernel_init_freeable+0x9a6/0xa98 init/main.c:1145
 kernel_init+0xd/0x1b6 init/main.c:1062
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

Freed by task 8113:
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcc/0x210 mm/slab.c:3822
 local_release net/nfc/llcp_core.c:187 [inline]
 kref_put include/linux/kref.h:70 [inline]
 nfc_llcp_local_put+0x155/0x1b0 net/nfc/llcp_core.c:195
 llcp_sock_destruct+0x7b/0x140 net/nfc/llcp_sock.c:959
 __sk_destruct+0x4b/0x8a0 net/core/sock.c:1559
 sk_destruct net/core/sock.c:1599 [inline]
 __sk_free+0x165/0x3b0 net/core/sock.c:1610
 sk_free+0x3b/0x50 net/core/sock.c:1621
 sock_put include/net/sock.h:1711 [inline]
 llcp_sock_release+0x37a/0x520 net/nfc/llcp_sock.c:656
 __sock_release+0xcd/0x2a0 net/socket.c:579
 sock_close+0x15/0x20 net/socket.c:1140
 __fput+0x2ce/0x890 fs/file_table.c:278
 task_work_run+0x148/0x1c0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xbf3/0x2be0 kernel/exit.c:870
 do_group_exit+0x125/0x310 kernel/exit.c:967
 __do_sys_exit_group kernel/exit.c:978 [inline]
 __se_sys_exit_group kernel/exit.c:976 [inline]
 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:976
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff888238ae31c0
 which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 1040 bytes inside of
 2048-byte region [ffff888238ae31c0, ffff888238ae39c0)
The buggy address belongs to the page:
page:ffffea0008e2b880 count:1 mapcount:0 mapping:ffff88813bff0c40 index:0x0 compound_mapcount: 0
flags: 0x57ff00000008100(slab|head)
raw: 057ff00000008100 ffffea0008e29a88 ffffea0008e2c288 ffff88813bff0c40
raw: 0000000000000000 ffff888238ae20c0 0000000100000003 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888238ae3480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888238ae3500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888238ae3580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                 ^
 ffff888238ae3600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888238ae3680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (22):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/05/02 12:17 linux-4.19.y 97a8651cadce 77e2b668 .config console log report syz C ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/04/21 11:43 linux-4.19.y 2965db2e004c 95777977 .config console log report syz C ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/05/07 18:36 linux-4.19.y 3c8c23092588 f6da8120 .config console log report syz ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/05/21 20:06 linux-4.19.y 3c8c23092588 3c7fef33 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/05/20 12:16 linux-4.19.y 3c8c23092588 c560a65d .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/05/18 12:28 linux-4.19.y 3c8c23092588 a343ba6b .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/05/15 10:58 linux-4.19.y 3c8c23092588 93f844de .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/05/13 14:14 linux-4.19.y 3c8c23092588 ecb594cb .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/05/10 13:33 linux-4.19.y 3c8c23092588 ca873091 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/05/09 14:12 linux-4.19.y 3c8c23092588 bc5434be .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/05/07 21:21 linux-4.19.y 3c8c23092588 bc5434be .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/05/03 13:23 linux-4.19.y 97a8651cadce ad61f371 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/04/28 12:15 linux-4.19.y 97a8651cadce 77e2b668 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/04/28 06:13 linux-4.19.y 2965db2e004c 77e2b668 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/04/24 08:58 linux-4.19.y 2965db2e004c 17f0b706 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/04/21 20:10 linux-4.19.y 2965db2e004c 2bc8999a .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/04/21 10:37 linux-4.19.y 2965db2e004c 95777977 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/04/14 21:44 linux-4.19.y 0f1b4cb77d7f fcdb12ba .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/04/14 11:33 linux-4.19.y 0f1b4cb77d7f 3134b37f .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/04/14 10:02 linux-4.19.y 0f1b4cb77d7f 3134b37f .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/04/14 07:14 linux-4.19.y 0f1b4cb77d7f a184b83e .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in nfc_llcp_sock_unlink
2021/05/17 02:20 linux-4.19.y 3c8c23092588 f54a5c09 .config console log report info ci2-linux-4-19 KASAN: null-ptr-deref Write in nfc_llcp_sock_unlink
* Struck through repros no longer work on HEAD.