KASAN: use-after-free Read in sock_def_readable

6 views
Skip to first unread message

syzbot

unread,
Sep 30, 2021, 10:25:18 AM9/30/21
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: c2276d585654 Linux 4.19.208
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=162dc9cb300000
kernel config: https://syzkaller.appspot.com/x/.config?x=9080caca9deef589
dashboard link: https://syzkaller.appspot.com/bug?extid=ae1d1ad9a270c5adc16e
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)

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

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

loop3: p1 p2 p3 p4[EZD]
loop3: partition table partially beyond EOD, truncated
loop3: p1 size 78398975 extends beyond EOD, truncated
==================================================================
BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:261 [inline]
BUG: KASAN: use-after-free in sock_def_readable+0x4a8/0x4d0 net/core/sock.c:2722
Read of size 8 at addr ffff88804a5a0cc8 by task syz-executor.3/22100

CPU: 1 PID: 22100 Comm: syz-executor.3 Not tainted 4.19.208-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
<IRQ>
__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
__read_once_size include/linux/compiler.h:261 [inline]
sock_def_readable+0x4a8/0x4d0 net/core/sock.c:2722
packet_rcv+0xd57/0x1490 net/packet/af_packet.c:2131
dev_queue_xmit_nit+0x756/0xa20 net/core/dev.c:2050
xmit_one net/core/dev.c:3252 [inline]
dev_hard_start_xmit+0xaa/0x920 net/core/dev.c:3272
__dev_queue_xmit+0x269d/0x2e00 net/core/dev.c:3838
neigh_hh_output include/net/neighbour.h:491 [inline]
neigh_output include/net/neighbour.h:499 [inline]
ip6_finish_output2+0xde7/0x2290 net/ipv6/ip6_output.c:120
ip6_finish_output+0x89b/0x10f0 net/ipv6/ip6_output.c:192
NF_HOOK_COND include/linux/netfilter.h:278 [inline]
ip6_output+0x205/0x770 net/ipv6/ip6_output.c:209
dst_output include/net/dst.h:455 [inline]
NF_HOOK include/linux/netfilter.h:289 [inline]
ndisc_send_skb+0xa24/0x1720 net/ipv6/ndisc.c:491
ndisc_send_rs+0x131/0x690 net/ipv6/ndisc.c:685
addrconf_rs_timer+0x384/0x6a0 net/ipv6/addrconf.c:3835
call_timer_fn+0x177/0x700 kernel/time/timer.c:1338
expire_timers+0x243/0x4e0 kernel/time/timer.c:1375
__run_timers kernel/time/timer.c:1696 [inline]
run_timer_softirq+0x21c/0x670 kernel/time/timer.c:1709
__do_softirq+0x265/0x980 kernel/softirq.c:292
invoke_softirq kernel/softirq.c:372 [inline]
irq_exit+0x215/0x260 kernel/softirq.c:412
exiting_irq arch/x86/include/asm/apic.h:536 [inline]
smp_apic_timer_interrupt+0x136/0x550 arch/x86/kernel/apic/apic.c:1098
apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:894
</IRQ>
RIP: 0010:arch_local_irq_restore arch/x86/include/asm/paravirt.h:789 [inline]
RIP: 0010:__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:160 [inline]
RIP: 0010:_raw_spin_unlock_irqrestore+0xa3/0xe0 kernel/locking/spinlock.c:184
Code: 48 c7 c0 88 82 f1 89 48 ba 00 00 00 00 00 fc ff df 48 c1 e8 03 80 3c 10 00 75 2f 48 83 3d 0c 4e d8 01 00 74 15 48 89 df 57 9d <0f> 1f 44 00 00 eb b2 e8 8b 08 e7 f8 eb c0 0f 0b 0f 0b 48 c7 c7 88
RSP: 0018:ffff888041d0eef0 EFLAGS: 00000286 ORIG_RAX: ffffffffffffff13
RAX: 1ffffffff13e3051 RBX: 0000000000000286 RCX: 1ffff110142101d5
RDX: dffffc0000000000 RSI: ffff8880a1080eb0 RDI: 0000000000000286
RBP: ffffffff89f88280 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880a1080600
R13: ffffffff89f88340 R14: ffff8880a1080978 R15: ffffffff89f88280
rcu_read_unlock_special+0x7ce/0xfc0 kernel/rcu/tree_plugin.h:587
__rcu_read_unlock+0x158/0x160 kernel/rcu/tree_plugin.h:428
rcu_read_unlock include/linux/rcupdate.h:680 [inline]
is_bpf_text_address+0xdf/0x1b0 kernel/bpf/core.c:548
kernel_text_address kernel/extable.c:152 [inline]
kernel_text_address+0xbd/0xf0 kernel/extable.c:122
__kernel_text_address+0x9/0x30 kernel/extable.c:107
unwind_get_return_address arch/x86/kernel/unwind_orc.c:297 [inline]
unwind_get_return_address+0x51/0x90 arch/x86/kernel/unwind_orc.c:292
__save_stack_trace+0xaf/0x190 arch/x86/kernel/stacktrace.c:45
save_stack mm/kasan/kasan.c:448 [inline]
set_track mm/kasan/kasan.c:460 [inline]
kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:553
__do_kmalloc mm/slab.c:3727 [inline]
__kmalloc_track_caller+0x155/0x3c0 mm/slab.c:3742
kstrdup+0x36/0x70 mm/util.c:56
kstrdup_const+0x53/0x80 mm/util.c:77
__kernfs_new_node+0x9b/0x680 fs/kernfs/dir.c:629
kernfs_new_node fs/kernfs/dir.c:693 [inline]
kernfs_create_dir_ns+0x9e/0x230 fs/kernfs/dir.c:1019
sysfs_create_dir_ns+0x127/0x280 fs/sysfs/dir.c:58
create_dir lib/kobject.c:88 [inline]
kobject_add_internal+0x2a5/0x9c0 lib/kobject.c:247
kobject_add_varg lib/kobject.c:382 [inline]
kobject_add+0x150/0x1c0 lib/kobject.c:426
device_add+0x37b/0x16d0 drivers/base/core.c:2122
add_partition+0x82e/0xdd0 block/partition-generic.c:382
rescan_partitions+0x589/0x970 block/partition-generic.c:629
__blkdev_reread_part+0x189/0x220 block/ioctl.c:173
blkdev_reread_part+0x23/0x40 block/ioctl.c:193
loop_reread_partitions drivers/block/loop.c:645 [inline]
loop_set_status+0x103e/0x1800 drivers/block/loop.c:1330
loop_set_status64+0xb2/0x110 drivers/block/loop.c:1450
lo_ioctl+0x41f/0x20e0 drivers/block/loop.c:1593
__blkdev_driver_ioctl block/ioctl.c:303 [inline]
blkdev_ioctl+0x5cb/0x1a80 block/ioctl.c:601
block_ioctl+0xe9/0x130 fs/block_dev.c:1906
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0xcdb/0x12e0 fs/ioctl.c:688
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:705
__do_sys_ioctl fs/ioctl.c:712 [inline]
__se_sys_ioctl fs/ioctl.c:710 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:710
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7fa3857f8697
Code: 3c 1c 48 f7 d8 49 39 c4 72 b8 e8 94 53 02 00 85 c0 78 bd 48 83 c4 08 4c 89 e0 5b 41 5c c3 0f 1f 44 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fa382d6eef8 EFLAGS: 00000202 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fa382d6ef40 RCX: 00007fa3857f8697
RDX: 00007fa382d6f050 RSI: 0000000000004c04 RDI: 0000000000000005
RBP: 00007fa385852cb4 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 00007fa382d6f050
R13: 00007fff371cbe2f R14: 00007fa382d6f300 R15: 0000000000022000

Allocated by task 22114:
__do_kmalloc mm/slab.c:3727 [inline]
__kmalloc+0x15a/0x3c0 mm/slab.c:3736
kmalloc include/linux/slab.h:520 [inline]
sk_prot_alloc+0x1e2/0x2d0 net/core/sock.c:1466
sk_alloc+0x36/0xec0 net/core/sock.c:1520
packet_create+0x117/0x850 net/packet/af_packet.c:3259
__sock_create+0x3d8/0x740 net/socket.c:1365
sock_create net/socket.c:1416 [inline]
__sys_socket+0xef/0x200 net/socket.c:1458
__do_sys_socket net/socket.c:1467 [inline]
__se_sys_socket net/socket.c:1465 [inline]
__x64_sys_socket+0x6f/0xb0 net/socket.c:1465
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 22113:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
sk_prot_free net/core/sock.c:1503 [inline]
__sk_destruct+0x684/0x8a0 net/core/sock.c:1584
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]
packet_release+0x890/0xb70 net/packet/af_packet.c:3088
__sock_release+0xcd/0x2a0 net/socket.c:599
sock_close+0x15/0x20 net/socket.c:1214
__fput+0x2ce/0x890 fs/file_table.c:278
task_work_run+0x148/0x1c0 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:193 [inline]
exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88804a5a0ac0
which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 520 bytes inside of
2048-byte region [ffff88804a5a0ac0, ffff88804a5a12c0)
The buggy address belongs to the page:
page:ffffea0001296800 count:1 mapcount:0 mapping:ffff88813bff0c40 index:0xffff88804a5a1340 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffffea000147b588 ffffea0001454208 ffff88813bff0c40
raw: ffff88804a5a1340 ffff88804a5a0240 0000000100000002 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88804a5a0b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88804a5a0c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88804a5a0c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88804a5a0d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88804a5a0d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess):
0: 48 c7 c0 88 82 f1 89 mov $0xffffffff89f18288,%rax
7: 48 ba 00 00 00 00 00 movabs $0xdffffc0000000000,%rdx
e: fc ff df
11: 48 c1 e8 03 shr $0x3,%rax
15: 80 3c 10 00 cmpb $0x0,(%rax,%rdx,1)
19: 75 2f jne 0x4a
1b: 48 83 3d 0c 4e d8 01 cmpq $0x0,0x1d84e0c(%rip) # 0x1d84e2f
22: 00
23: 74 15 je 0x3a
25: 48 89 df mov %rbx,%rdi
28: 57 push %rdi
29: 9d popfq
* 2a: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) <-- trapping instruction
2f: eb b2 jmp 0xffffffe3
31: e8 8b 08 e7 f8 callq 0xf8e708c1
36: eb c0 jmp 0xfffffff8
38: 0f 0b ud2
3a: 0f 0b ud2
3c: 48 rex.W
3d: c7 .byte 0xc7
3e: c7 (bad)
3f: 88 .byte 0x88


---
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,
Jan 28, 2022, 9:25:14 AM1/28/22
to syzkaller...@googlegroups.com
Auto-closing this bug as obsolete.
Crashes did not happen for a while, no reproducer and no activity.
Reply all
Reply to author
Forward
0 new messages