syzbot


KASAN: use-after-free Read in hooks_validate

Status: auto-closed as invalid on 2021/09/07 00:40
Reported-by: syzbot+607ebbd3b72f5db07d51@syzkaller.appspotmail.com
First crash: 1304d, last: 1304d
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 1090d 1288d 0/28 auto-closed as invalid on 2022/09/19 14:29
linux-4.19 KASAN: use-after-free Read in hooks_validate (2) C error 2 706d 1010d 0/1 upstream: reported C repro on 2022/02/27 11:03

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 ffff8880b2835680 by task syz-executor.0/6767

CPU: 1 PID: 6767 Comm: syz-executor.0 Not tainted 4.19.190-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:1901
 __do_sys_setsockopt net/socket.c:1912 [inline]
 __se_sys_setsockopt net/socket.c:1909 [inline]
 __x64_sys_setsockopt+0xba/0x150 net/socket.c:1909
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4665f9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f67a0578188 EFLAGS: 00000246 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 000000000056bf60 RCX: 00000000004665f9
RDX: 0000000000000040 RSI: 0000000000000029 RDI: 0000000000000004
RBP: 00000000004bfce1 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000020000440 R11: 0000000000000246 R12: 000000000056bf60
R13: 00007ffdf38c49ff R14: 00007f67a0578300 R15: 0000000000022000

Allocated by task 6767:
 __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:1901
 __do_sys_setsockopt net/socket.c:1912 [inline]
 __se_sys_setsockopt net/socket.c:1909 [inline]
 __x64_sys_setsockopt+0xba/0x150 net/socket.c:1909
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 15131:
 __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 ffff8880b2835680
 which belongs to the cache kmalloc-1024 of size 1024
The buggy address is located 0 bytes inside of
 1024-byte region [ffff8880b2835680, ffff8880b2835a80)
The buggy address belongs to the page:
page:ffffea0002ca0d00 count:1 mapcount:0 mapping:ffff88813bff0ac0 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffffea0000e31788 ffffea00027a8588 ffff88813bff0ac0
raw: 0000000000000000 ffff8880b2834000 0000000100000007 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880b2835580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880b2835600: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880b2835680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8880b2835700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880b2835780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/05/10 00:39 linux-4.19.y 3c8c23092588 bc5434be .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in hooks_validate
* Struck through repros no longer work on HEAD.