syzbot


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

Status: upstream: reported C repro on 2022/02/27 11:03
Reported-by: syzbot+cec8578fe6948dbfbf77@syzkaller.appspotmail.com
First crash: 789d, last: 485d
Fix bisection: failed (error log, bisect log)
  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in hooks_validate netfilter syz error error 5 868d 1067d 0/26 auto-closed as invalid on 2022/09/19 14:29
linux-4.19 KASAN: use-after-free Read in hooks_validate 1 1082d 1082d 0/1 auto-closed as invalid on 2021/09/07 00:40

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in nf_hook_entries_get_hook_ops include/linux/netfilter.h:107 [inline]
BUG: KASAN: use-after-free in hooks_validate+0x139/0x160 net/netfilter/core.c:170
Read of size 2 at addr ffff8880b0ce16c0 by task syz-executor644/8124

CPU: 1 PID: 8124 Comm: syz-executor644 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_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
 kasan_report mm/kasan/report.c:412 [inline]
 __asan_report_load2_noabort+0x88/0x90 mm/kasan/report.c:431
 nf_hook_entries_get_hook_ops include/linux/netfilter.h:107 [inline]
 hooks_validate+0x139/0x160 net/netfilter/core.c:170
 __nf_register_net_hook+0x1b0/0x480 net/netfilter/core.c:345
 nf_register_net_hook net/netfilter/core.c:463 [inline]
 nf_register_net_hooks+0x4c/0x190 net/netfilter/core.c:479
 synproxy_tg6_check+0x3c1/0x610 net/ipv6/netfilter/ip6t_SYNPROXY.c:478
 xt_check_target+0x26c/0x650 net/netfilter/x_tables.c:1023
 check_target net/ipv6/netfilter/ip6_tables.c:532 [inline]
 find_check_entry.constprop.0+0x7f1/0x9e0 net/ipv6/netfilter/ip6_tables.c:575
 translate_table+0xc46/0x16a0 net/ipv6/netfilter/ip6_tables.c:737
 do_replace net/ipv6/netfilter/ip6_tables.c:1156 [inline]
 do_ip6t_set_ctl+0x29d/0x430 net/ipv6/netfilter/ip6_tables.c:1686
 nf_sockopt net/netfilter/nf_sockopt.c:106 [inline]
 nf_setsockopt+0x6f/0xc0 net/netfilter/nf_sockopt.c:115
 ipv6_setsockopt+0x103/0x160 net/ipv6/ipv6_sockglue.c:945
 rawv6_setsockopt+0x55/0x140 net/ipv6/raw.c:1084
 __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:0x7f5364a2f599
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 61 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:00007f53649d8208 EFLAGS: 00000246 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 0000000000000020 RCX: 00007f5364a2f599
RDX: 0000000000000040 RSI: 0000000000000029 RDI: 0000000000000003
RBP: 00007f5364ab14a0 R08: 0000000000000001 R09: 00007f5364ab14a8
R10: 0000000020000000 R11: 0000000000000246 R12: 00007f5364ab14ac
R13: 00007ffe160d3b2f R14: 00007f53649d8300 R15: 0000000000022000

Allocated by task 8124:
 __do_kmalloc_node mm/slab.c:3689 [inline]
 __kmalloc_node+0x4c/0x70 mm/slab.c:3696
 kmalloc_node include/linux/slab.h:557 [inline]
 kvmalloc_node+0x61/0xf0 mm/util.c:423
 kvmalloc include/linux/mm.h:577 [inline]
 kvzalloc include/linux/mm.h:585 [inline]
 allocate_hook_entries_size net/netfilter/core.c:60 [inline]
 nf_hook_entries_grow+0x140/0x780 net/netfilter/core.c:127
 __nf_register_net_hook+0x15a/0x480 net/netfilter/core.c:336
 nf_register_net_hook net/netfilter/core.c:463 [inline]
 nf_register_net_hooks+0x4c/0x190 net/netfilter/core.c:479
 synproxy_tg6_check+0x3c1/0x610 net/ipv6/netfilter/ip6t_SYNPROXY.c:478
 xt_check_target+0x26c/0x650 net/netfilter/x_tables.c:1023
 check_target net/ipv6/netfilter/ip6_tables.c:532 [inline]
 find_check_entry.constprop.0+0x7f1/0x9e0 net/ipv6/netfilter/ip6_tables.c:575
 translate_table+0xc46/0x16a0 net/ipv6/netfilter/ip6_tables.c:737
 do_replace net/ipv6/netfilter/ip6_tables.c:1156 [inline]
 do_ip6t_set_ctl+0x29d/0x430 net/ipv6/netfilter/ip6_tables.c:1686
 nf_sockopt net/netfilter/nf_sockopt.c:106 [inline]
 nf_setsockopt+0x6f/0xc0 net/netfilter/nf_sockopt.c:115
 ipv6_setsockopt+0x103/0x160 net/ipv6/ipv6_sockglue.c:945
 rawv6_setsockopt+0x55/0x140 net/ipv6/raw.c:1084
 __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 8118:
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcc/0x210 mm/slab.c:3822
 kvfree+0x59/0x60 mm/util.c:452
 __rcu_reclaim kernel/rcu/rcu.h:236 [inline]
 rcu_do_batch kernel/rcu/tree.c:2584 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:2897 [inline]
 __rcu_process_callbacks kernel/rcu/tree.c:2864 [inline]
 rcu_process_callbacks+0x8ff/0x18b0 kernel/rcu/tree.c:2881
 __do_softirq+0x265/0x980 kernel/softirq.c:292

The buggy address belongs to the object at ffff8880b0ce16c0
 which belongs to the cache kmalloc-1024 of size 1024
The buggy address is located 0 bytes inside of
 1024-byte region [ffff8880b0ce16c0, ffff8880b0ce1ac0)
The buggy address belongs to the page:
page:ffffea0002c33800 count:1 mapcount:0 mapping:ffff88813bff0ac0 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffffea0002c5be88 ffffea0002c38b88 ffff88813bff0ac0
raw: 0000000000000000 ffff8880b0ce0040 0000000100000007 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880b0ce1580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880b0ce1600: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8880b0ce1680: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                           ^
 ffff8880b0ce1700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880b0ce1780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/02/27 11:03 linux-4.19.y 3f8a27f9e27b 45a13a73 .config console log report syz C ci2-linux-4-19 KASAN: use-after-free Read in hooks_validate
2022/12/28 15:09 linux-4.19.y 3f8a27f9e27b 44712fbc .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in hooks_validate
* Struck through repros no longer work on HEAD.