KASAN: use-after-free Read in packet_rcv (2)

7 views
Skip to first unread message

syzbot

unread,
Dec 4, 2021, 5:14:21 PM12/4/21
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 3f8a27f9e27b Linux 4.19.211
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=17fd5116b00000
kernel config: https://syzkaller.appspot.com/x/.config?x=9b9277b418617afe
dashboard link: https://syzkaller.appspot.com/bug?extid=4f9a765a5eec1d48d32a
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+4f9a76...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in packet_rcv+0x5aa/0x1490 net/packet/af_packet.c:2104
Read of size 1 at addr ffff8880583730ec by task syz-executor.5/15432

CPU: 0 PID: 15432 Comm: syz-executor.5 Not tainted 4.19.211-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_load1_noabort+0x88/0x90 mm/kasan/report.c:430
packet_rcv+0x5aa/0x1490 net/packet/af_packet.c:2104
packet_rcv_fanout+0x505/0x6d0 net/packet/af_packet.c:1466
deliver_skb net/core/dev.c:1956 [inline]
dev_queue_xmit_nit+0x24d/0xa20 net/core/dev.c:2012
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
hsr_xmit net/hsr/hsr_forward.c:237 [inline]
hsr_forward_do net/hsr/hsr_forward.c:295 [inline]
hsr_forward_skb+0xd2d/0x1c30 net/hsr/hsr_forward.c:373
send_hsr_supervision_frame+0x917/0xf70 net/hsr/hsr_device.c:321
hsr_announce+0x125/0x3a0 net/hsr/hsr_device.c:350
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:__rcu_read_unlock+0x104/0x160 kernel/rcu/tree_plugin.h:430
Code: d2 75 62 8b 83 74 03 00 00 85 c0 75 69 48 b8 00 00 00 00 00 fc ff df 48 89 ea 48 c1 ea 03 0f b6 04 02 84 c0 74 04 3c 03 7e 42 <c7> 83 70 03 00 00 00 00 00 00 e9 34 ff ff ff 0f 0b 5b 5d c3 48 89
RSP: 0018:ffff8882321c7718 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff13
RAX: 0000000000000000 RBX: ffff8880b323a280 RCX: ffffffff81518c83
RDX: 1ffff110166474be RSI: 0000000000000004 RDI: ffff8880b323a5f4
RBP: ffff8880b323a5f0 R08: 0000000000000000 R09: ffffed101740455a
R10: ffff8880ba022ad3 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: dead000000000100 R15: 00007f5814eed000
rcu_read_unlock include/linux/rcupdate.h:680 [inline]
__unlock_page_memcg+0x54/0x100 mm/memcontrol.c:1955
page_remove_rmap+0xe5/0x120 mm/rmap.c:1297
zap_pte_range mm/memory.c:1350 [inline]
zap_pmd_range mm/memory.c:1463 [inline]
zap_pud_range mm/memory.c:1492 [inline]
zap_p4d_range mm/memory.c:1513 [inline]
unmap_page_range+0x147d/0x2c50 mm/memory.c:1534
unmap_single_vma+0x198/0x300 mm/memory.c:1579
unmap_vmas+0xa9/0x180 mm/memory.c:1609
exit_mmap+0x2b9/0x530 mm/mmap.c:3093
__mmput kernel/fork.c:1016 [inline]
mmput+0x14e/0x4a0 kernel/fork.c:1037
exit_mm kernel/exit.c:549 [inline]
do_exit+0xaec/0x2be0 kernel/exit.c:857
do_group_exit+0x125/0x310 kernel/exit.c:967
get_signal+0x3f2/0x1f70 kernel/signal.c:2589
do_signal+0x8f/0x1670 arch/x86/kernel/signal.c:799
exit_to_usermode_loop+0x204/0x2a0 arch/x86/entry/common.c:163
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
RIP: 0033:0x7f581549cae9
Code: Bad RIP value.
RSP: 002b:00007f58143f1218 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: fffffffffffffe00 RBX: 00007f58155b0030 RCX: 00007f581549cae9
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00007f58155b0030
RBP: 00007f58155b0028 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f58155b0034
R13: 00007ffce34f585f R14: 00007f58143f1300 R15: 0000000000022000

Allocated by task 15426:
__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:1483
sk_alloc+0x36/0xec0 net/core/sock.c:1537
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 15419:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
sk_prot_free net/core/sock.c:1520 [inline]
__sk_destruct+0x684/0x8a0 net/core/sock.c:1602
sk_destruct net/core/sock.c:1617 [inline]
__sk_free+0x165/0x3b0 net/core/sock.c:1628
sk_free+0x3b/0x50 net/core/sock.c:1639
sock_put include/net/sock.h:1713 [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 ffff8880583729c0
which belongs to the cache kmalloc-4096 of size 4096
The buggy address is located 1836 bytes inside of
4096-byte region [ffff8880583729c0, ffff8880583739c0)
The buggy address belongs to the page:
page:ffffea000160dc80 count:1 mapcount:0 mapping:ffff88813bff0dc0 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffffea000235b888 ffffea000283cf88 ffff88813bff0dc0
raw: 0000000000000000 ffff8880583729c0 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff888058372f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888058373000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888058373080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888058373100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888058373180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess):
0: d2 75 62 shlb %cl,0x62(%rbp)
3: 8b 83 74 03 00 00 mov 0x374(%rbx),%eax
9: 85 c0 test %eax,%eax
b: 75 69 jne 0x76
d: 48 b8 00 00 00 00 00 movabs $0xdffffc0000000000,%rax
14: fc ff df
17: 48 89 ea mov %rbp,%rdx
1a: 48 c1 ea 03 shr $0x3,%rdx
1e: 0f b6 04 02 movzbl (%rdx,%rax,1),%eax
22: 84 c0 test %al,%al
24: 74 04 je 0x2a
26: 3c 03 cmp $0x3,%al
28: 7e 42 jle 0x6c
* 2a: c7 83 70 03 00 00 00 movl $0x0,0x370(%rbx) <-- trapping instruction
31: 00 00 00
34: e9 34 ff ff ff jmpq 0xffffff6d
39: 0f 0b ud2
3b: 5b pop %rbx
3c: 5d pop %rbp
3d: c3 retq
3e: 48 rex.W
3f: 89 .byte 0x89


---
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,
Mar 3, 2023, 9:26:54 PM3/3/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 3f8a27f9e27b Linux 4.19.211
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=166d439cc80000
kernel config: https://syzkaller.appspot.com/x/.config?x=9b9277b418617afe
dashboard link: https://syzkaller.appspot.com/bug?extid=4f9a765a5eec1d48d32a
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=165d1682c80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/98c0bdb4abb3/disk-3f8a27f9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ea228ff02669/vmlinux-3f8a27f9.xz

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

ieee802154 phy0 wpan0: encryption failed: -22
ieee802154 phy1 wpan1: encryption failed: -22
==================================================================
BUG: KASAN: use-after-free in packet_rcv+0x5aa/0x1490 net/packet/af_packet.c:2104
Read of size 1 at addr ffff8880afc5886c by task syz-executor.1/22271

CPU: 0 PID: 22271 Comm: syz-executor.1 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/16/2023
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_load1_noabort+0x88/0x90 mm/kasan/report.c:430
packet_rcv+0x5aa/0x1490 net/packet/af_packet.c:2104
deliver_skb net/core/dev.c:1956 [inline]
dev_queue_xmit_nit+0x24d/0xa20 net/core/dev.c:2012
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
hsr_xmit net/hsr/hsr_forward.c:237 [inline]
hsr_forward_do net/hsr/hsr_forward.c:295 [inline]
hsr_forward_skb+0xd2d/0x1c30 net/hsr/hsr_forward.c:373
send_hsr_supervision_frame+0x917/0xf70 net/hsr/hsr_device.c:321
hsr_announce+0x125/0x3a0 net/hsr/hsr_device.c:350
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 7c 31 d8 01 00 74 15 48 89 df 57 9d <0f> 1f 44 00 00 eb b2 e8 fb eb e6 f8 eb c0 0f 0b 0f 0b 48 c7 c7 88
RSP: 0018:ffff888093d6f930 EFLAGS: 00000286 ORIG_RAX: ffffffffffffff13
RAX: 1ffffffff13e3051 RBX: 0000000000000286 RCX: 0000000000000000
RDX: dffffc0000000000 RSI: ffff8880b16fcd08 RDI: 0000000000000286
RBP: ffffffff89f888d8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: ffff88813be45200 R15: 0000000000000120
__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
kmem_cache_alloc+0x122/0x370 mm/slab.c:3559
__d_alloc+0x2b/0xa10 fs/dcache.c:1612
d_alloc_pseudo+0x19/0x70 fs/dcache.c:1743
alloc_file_pseudo+0xc6/0x250 fs/file_table.c:224
create_pipe_files+0x3e7/0x7f0 fs/pipe.c:779
__do_pipe_flags fs/pipe.c:810 [inline]
do_pipe2+0x96/0x1b0 fs/pipe.c:858
__do_sys_pipe fs/pipe.c:881 [inline]
__se_sys_pipe fs/pipe.c:879 [inline]
__x64_sys_pipe+0x2f/0x40 fs/pipe.c:879
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7ff2ab3cd0f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 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:00007ff2aa6bb168 EFLAGS: 00000246 ORIG_RAX: 0000000000000016
RAX: ffffffffffffffda RBX: 00007ff2ab4ed2c0 RCX: 00007ff2ab3cd0f9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 00007ff2ab428ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd2122c64f R14: 00007ff2aa6bb300 R15: 0000000000022000

Allocated by task 22267:
__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:1483
sk_alloc+0x36/0xec0 net/core/sock.c:1537
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 22265:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
sk_prot_free net/core/sock.c:1520 [inline]
__sk_destruct+0x684/0x8a0 net/core/sock.c:1602
sk_destruct net/core/sock.c:1617 [inline]
__sk_free+0x165/0x3b0 net/core/sock.c:1628
sk_free+0x3b/0x50 net/core/sock.c:1639
sock_put include/net/sock.h:1713 [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
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 ffff8880afc58140
which belongs to the cache kmalloc-4096 of size 4096
The buggy address is located 1836 bytes inside of
4096-byte region [ffff8880afc58140, ffff8880afc59140)
The buggy address belongs to the page:
page:ffffea0002bf1600 count:1 mapcount:0 mapping:ffff88813bff0dc0 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffffea0002510088 ffffea0002bf1688 ffff88813bff0dc0
raw: 0000000000000000 ffff8880afc58140 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880afc58700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880afc58780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880afc58800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880afc58880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880afc58900: 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 7c 31 d8 01 cmpq $0x0,0x1d8317c(%rip) # 0x1d8319f
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 fb eb e6 f8 callq 0xf8e6ec31
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

Reply all
Reply to author
Forward
0 new messages