syzbot


KASAN: invalid-free in packet_set_ring

Status: upstream: reported C repro on 2021/12/12 11:35
Reported-by: syzbot+9c5a6de222342268be36@syzkaller.appspotmail.com
First crash: 1086d, last: 1086d
Fix bisection: failed (error log, bisect log)
  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-54 KASAN: invalid-free in packet_set_ring C 1 1086d 1086d 0/2 auto-obsoleted due to no activity on 2023/04/20 06:54
upstream KASAN: invalid-free in packet_set_ring net C inconclusive 4 1086d 1086d 20/28 fixed on 2022/03/08 16:11

Sample crash report:
==================================================================
BUG: KASAN: double-free or invalid-free in packet_set_ring+0x109f/0x1c50 net/packet/af_packet.c:4442

CPU: 0 PID: 22346 Comm: syz-executor944 Not tainted 4.19.211-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_invalid_free+0x61/0xa0 mm/kasan/report.c:336
 __kasan_slab_free+0x1d0/0x1f0 mm/kasan/kasan.c:501
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcc/0x210 mm/slab.c:3822
 packet_set_ring+0x109f/0x1c50 net/packet/af_packet.c:4442
 packet_setsockopt+0x1480/0x2cc0 net/packet/af_packet.c:3721
 __sys_setsockopt+0x14d/0x240 net/socket.c:2013
 __do_sys_setsockopt net/socket.c:2024 [inline]
 __se_sys_setsockopt net/socket.c:2021 [inline]
 __x64_sys_setsockopt+0xba/0x150 net/socket.c:2021
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f219fc7a6c9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 01 18 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:00007f219fc03318 EFLAGS: 00000246 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 00007f219fcfb3d8 RCX: 00007f219fc7a6c9
RDX: 0000000000000005 RSI: 0000000000000107 RDI: 0000000000000003
RBP: 00007f219fcfb3d0 R08: 000000000000001c R09: 0000000000000000
R10: 00000000200000c0 R11: 0000000000000246 R12: 00007f219fcc82bc
R13: 00007fff5bda8c0f R14: 00007f219fc03400 R15: 0000000000022000

Allocated by task 22339:
 __do_kmalloc mm/slab.c:3727 [inline]
 __kmalloc+0x15a/0x3c0 mm/slab.c:3736
 kmalloc_array include/linux/slab.h:637 [inline]
 kcalloc include/linux/slab.h:648 [inline]
 alloc_pg_vec net/packet/af_packet.c:4264 [inline]
 packet_set_ring+0xb1c/0x1c50 net/packet/af_packet.c:4354
 packet_setsockopt+0x1480/0x2cc0 net/packet/af_packet.c:3721
 __sys_setsockopt+0x14d/0x240 net/socket.c:2013
 __do_sys_setsockopt net/socket.c:2024 [inline]
 __se_sys_setsockopt net/socket.c:2021 [inline]
 __x64_sys_setsockopt+0xba/0x150 net/socket.c:2021
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 22339:
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcc/0x210 mm/slab.c:3822
 packet_set_ring+0x72e/0x1c50 net/packet/af_packet.c:4444
 packet_setsockopt+0x1480/0x2cc0 net/packet/af_packet.c:3721
 __sys_setsockopt+0x14d/0x240 net/socket.c:2013
 __do_sys_setsockopt net/socket.c:2024 [inline]
 __se_sys_setsockopt net/socket.c:2021 [inline]
 __x64_sys_setsockopt+0xba/0x150 net/socket.c:2021
 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 ffff8880a9e98f00
 which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes inside of
 64-byte region [ffff8880a9e98f00, ffff8880a9e98f40)
The buggy address belongs to the page:
page:ffffea0002a7a600 count:1 mapcount:0 mapping:ffff88813bff0340 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea0002a6f2c8 ffffea0002a892c8 ffff88813bff0340
raw: 0000000000000000 ffff8880a9e98000 0000000100000020 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a9e98e00: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc
 ffff8880a9e98e80: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
>ffff8880a9e98f00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                   ^
 ffff8880a9e98f80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8880a9e99000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/12/12 11:34 linux-4.19.y 3f8a27f9e27b 49ca1f59 .config console log report syz C ci2-linux-4-19 KASAN: invalid-free in packet_set_ring
* Struck through repros no longer work on HEAD.