syzbot


KASAN: use-after-free Read in nf_hook_slow

Status: upstream: reported syz repro on 2020/12/08 20:37
Reported-by: syzbot+663e49fa871bf5aad3fd@syzkaller.appspotmail.com
First crash: 1248d, last: 633d
Fix bisection the fix commit could be any of (bisect log):
  3242aa3a635c Linux 4.14.222
  74766a973637 Linux 4.14.275
  
Last patch testing requests (2)
Created Duration User Patch Repo Result
2023/03/04 07:32 0m retest repro linux-4.14.y error OK
2022/11/24 05:30 11m retest repro linux-4.14.y report log
Fix bisection attempts (13)
Created Duration User Patch Repo Result
2022/04/06 20:19 27m bisect fix linux-4.14.y job log (2)
2022/03/07 19:53 26m bisect fix linux-4.14.y job log (0) log
2022/02/05 11:15 34m bisect fix linux-4.14.y job log (0) log
2022/01/06 10:35 28m bisect fix linux-4.14.y job log (0) log
2021/12/07 10:10 25m bisect fix linux-4.14.y job log (0) log
2021/11/07 09:46 23m bisect fix linux-4.14.y job log (0) log
2021/10/08 09:22 23m bisect fix linux-4.14.y job log (0) log
2021/09/08 08:47 25m bisect fix linux-4.14.y job log (0) log
2021/08/09 08:11 26m bisect fix linux-4.14.y job log (0) log
2021/07/10 07:44 24m bisect fix linux-4.14.y job log (0) log
2021/06/10 07:08 29m bisect fix linux-4.14.y job log (0) log
2021/05/11 05:57 27m bisect fix linux-4.14.y job log (0) log
2021/04/11 05:05 31m bisect fix linux-4.14.y job log (0) log

Sample crash report:
IPv6: ADDRCONF(NETDEV_UP): batadv_slave_1: link is not ready
batman_adv: batadv0: Interface activated: batadv_slave_1
IPv6: ADDRCONF(NETDEV_CHANGE): batadv_slave_1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth1_to_batadv: link becomes ready
==================================================================
BUG: KASAN: use-after-free in nf_hook_slow+0x197/0x1a0 net/netfilter/core.c:466
Read of size 2 at addr ffff88809ca6b480 by task syz-executor.3/9444

CPU: 1 PID: 9444 Comm: syz-executor.3 Not tainted 4.14.222-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:17 [inline]
 dump_stack+0x1b2/0x281 lib/dump_stack.c:58
 print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
 kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:351
 kasan_report mm/kasan/report.c:409 [inline]
 __asan_report_load2_noabort+0x68/0x70 mm/kasan/report.c:428
 nf_hook_slow+0x197/0x1a0 net/netfilter/core.c:466
 nf_hook include/linux/netfilter.h:205 [inline]
 NF_HOOK include/linux/netfilter.h:248 [inline]
 mld_sendpack+0x884/0xea0 net/ipv6/mcast.c:1660
 mld_send_initial_cr.part.0+0xf5/0x140 net/ipv6/mcast.c:2077
 mld_send_initial_cr net/ipv6/mcast.c:1170 [inline]
 mld_dad_timer_expire+0x140/0x520 net/ipv6/mcast.c:2096
 call_timer_fn+0x14a/0x650 kernel/time/timer.c:1280
 expire_timers+0x232/0x4d0 kernel/time/timer.c:1319
 __run_timers kernel/time/timer.c:1637 [inline]
 run_timer_softirq+0x1d5/0x5a0 kernel/time/timer.c:1650
 __do_softirq+0x24d/0x9ff kernel/softirq.c:288
 invoke_softirq kernel/softirq.c:368 [inline]
 irq_exit+0x193/0x240 kernel/softirq.c:409
 exiting_irq arch/x86/include/asm/apic.h:638 [inline]
 smp_apic_timer_interrupt+0x141/0x5e0 arch/x86/kernel/apic/apic.c:1106
 apic_timer_interrupt+0x93/0xa0 arch/x86/entry/entry_64.S:793
 </IRQ>
RIP: 0010:arch_local_irq_restore arch/x86/include/asm/paravirt.h:779 [inline]
RIP: 0010:rcu_read_unlock_special+0x452/0xdd0 kernel/rcu/tree_plugin.h:542
RSP: 0018:ffff88809cf1eda8 EFLAGS: 00000286 ORIG_RAX: ffffffffffffff10
RAX: 1ffffffff11e1251 RBX: ffff88809d7f40c0 RCX: 1ffff11013afe937
RDX: dffffc0000000000 RSI: ffff88809d7f49c0 RDI: 0000000000000286
RBP: ffff88809d7f4444 R08: ffff8880ba42ac30 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000286
R13: ffff88809d7f4446 R14: ffff88809d7f4445 R15: 0000000000000000
 __rcu_read_unlock+0x158/0x160 kernel/rcu/update.c:260
 rcu_read_unlock include/linux/rcupdate.h:684 [inline]
 is_bpf_text_address+0x9b/0x150 kernel/bpf/core.c:458
 kernel_text_address kernel/extable.c:150 [inline]
 kernel_text_address+0xbd/0xf0 kernel/extable.c:120
 __kernel_text_address+0x9/0x30 kernel/extable.c:105
 unwind_get_return_address arch/x86/kernel/unwind_orc.c:252 [inline]
 unwind_get_return_address+0x51/0x90 arch/x86/kernel/unwind_orc.c:247
 __save_stack_trace+0xa0/0x160 arch/x86/kernel/stacktrace.c:45
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
 kmem_cache_alloc+0x124/0x3c0 mm/slab.c:3552
 kmem_cache_zalloc include/linux/slab.h:651 [inline]
 __kernfs_new_node+0x6f/0x470 fs/kernfs/dir.c:632
 kernfs_new_node+0x7b/0xe0 fs/kernfs/dir.c:677
 __kernfs_create_file+0x3d/0x320 fs/kernfs/file.c:989
 sysfs_add_file_mode_ns+0x1e1/0x450 fs/sysfs/file.c:307
 create_files fs/sysfs/group.c:64 [inline]
 internal_create_group+0x22b/0x710 fs/sysfs/group.c:134
 sysfs_create_group fs/sysfs/group.c:156 [inline]
 sysfs_create_groups fs/sysfs/group.c:183 [inline]
 sysfs_create_groups+0x92/0x130 fs/sysfs/group.c:173
 device_add_groups drivers/base/core.c:1064 [inline]
 device_add_attrs drivers/base/core.c:1212 [inline]
 device_add+0x7e5/0x15c0 drivers/base/core.c:1901
 wiphy_register+0x1326/0x1cf0 net/wireless/core.c:809
 ieee80211_register_hw+0x107f/0x2c90 net/mac80211/main.c:1055
 mac80211_hwsim_new_radio+0x186a/0x2740 drivers/net/wireless/mac80211_hwsim.c:2705
 hwsim_new_radio_nl+0x3aa/0x5d0 drivers/net/wireless/mac80211_hwsim.c:3164
 genl_family_rcv_msg+0x572/0xb20 net/netlink/genetlink.c:600
 genl_rcv_msg+0xaf/0x140 net/netlink/genetlink.c:625
 netlink_rcv_skb+0x125/0x390 net/netlink/af_netlink.c:2433
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:636
 netlink_unicast_kernel net/netlink/af_netlink.c:1287 [inline]
 netlink_unicast+0x437/0x610 net/netlink/af_netlink.c:1313
 netlink_sendmsg+0x62e/0xb80 net/netlink/af_netlink.c:1878
 sock_sendmsg_nosec net/socket.c:646 [inline]
 sock_sendmsg+0xb5/0x100 net/socket.c:656
 ___sys_sendmsg+0x6c8/0x800 net/socket.c:2062
 __sys_sendmsg+0xa3/0x120 net/socket.c:2096
 SYSC_sendmsg net/socket.c:2107 [inline]
 SyS_sendmsg+0x27/0x40 net/socket.c:2103
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x465ef9
RSP: 002b:00007fcd07a52188 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 000000000056bf60 RCX: 0000000000465ef9
RDX: 0000000000000000 RSI: 0000000020000040 RDI: 0000000000000004
RBP: 00000000004bcd1c R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000056bf60
R13: 00007ffcf7a43f0f R14: 00007fcd07a52300 R15: 0000000000022000

Allocated by task 8001:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
 __do_kmalloc_node mm/slab.c:3682 [inline]
 __kmalloc_node+0x4c/0x70 mm/slab.c:3689
 kmalloc_node include/linux/slab.h:530 [inline]
 kvmalloc_node+0x46/0xd0 mm/util.c:397
 kvmalloc include/linux/mm.h:531 [inline]
 kvzalloc include/linux/mm.h:539 [inline]
 allocate_hook_entries_size net/netfilter/core.c:82 [inline]
 nf_hook_entries_grow net/netfilter/core.c:125 [inline]
 nf_register_net_hook+0x25d/0xa40 net/netfilter/core.c:277
 nf_register_net_hooks+0x47/0xa0 net/netfilter/core.c:382
 ip6t_register_table+0x1d3/0x280 net/ipv6/netfilter/ip6_tables.c:1799
 ip6table_mangle_table_init net/ipv6/netfilter/ip6table_mangle.c:101 [inline]
 ip6table_mangle_table_init+0x82/0xc0 net/ipv6/netfilter/ip6table_mangle.c:90
 xt_find_table_lock+0x247/0x3d0 net/netfilter/x_tables.c:1110
 get_info+0xf5/0x530 net/ipv6/netfilter/ip6_tables.c:983
 do_ip6t_get_ctl+0x125/0x7d0 net/ipv6/netfilter/ip6_tables.c:1709
 nf_sockopt net/netfilter/nf_sockopt.c:104 [inline]
 nf_getsockopt+0x62/0xc0 net/netfilter/nf_sockopt.c:122
 ipv6_getsockopt+0x146/0x1e0 net/ipv6/ipv6_sockglue.c:1376
 tcp_getsockopt+0x7b/0xc0 net/ipv4/tcp.c:3257
 SYSC_getsockopt net/socket.c:1896 [inline]
 SyS_getsockopt+0x102/0x1c0 net/socket.c:1878
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb

Freed by task 8001:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kfree+0xc9/0x250 mm/slab.c:3815
 kvfree+0x45/0x50 mm/util.c:416
 nf_register_net_hook+0x6c2/0xa40 net/netfilter/core.c:296
 nf_register_net_hooks+0x47/0xa0 net/netfilter/core.c:382
 ip6t_register_table+0x1d3/0x280 net/ipv6/netfilter/ip6_tables.c:1799
 ip6table_raw_table_init net/ipv6/netfilter/ip6table_raw.c:44 [inline]
 ip6table_raw_table_init+0x82/0xc0 net/ipv6/netfilter/ip6table_raw.c:33
 xt_find_table_lock+0x247/0x3d0 net/netfilter/x_tables.c:1110
 get_info+0xf5/0x530 net/ipv6/netfilter/ip6_tables.c:983
 do_ip6t_get_ctl+0x125/0x7d0 net/ipv6/netfilter/ip6_tables.c:1709
 nf_sockopt net/netfilter/nf_sockopt.c:104 [inline]
 nf_getsockopt+0x62/0xc0 net/netfilter/nf_sockopt.c:122
 ipv6_getsockopt+0x146/0x1e0 net/ipv6/ipv6_sockglue.c:1376
 tcp_getsockopt+0x7b/0xc0 net/ipv4/tcp.c:3257
 SYSC_getsockopt net/socket.c:1896 [inline]
 SyS_getsockopt+0x102/0x1c0 net/socket.c:1878
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb

The buggy address belongs to the object at ffff88809ca6b480
 which belongs to the cache kmalloc-128 of size 128
The buggy address is located 0 bytes inside of
 128-byte region [ffff88809ca6b480, ffff88809ca6b500)
The buggy address belongs to the page:
page:ffffea0002729ac0 count:1 mapcount:0 mapping:ffff88809ca6b000 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffff88809ca6b000 0000000000000000 0000000100000015
raw: ffffea00027b3560 ffffea00027a3ae0 ffff88813fe80640 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809ca6b380: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
 ffff88809ca6b400: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
>ffff88809ca6b480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88809ca6b500: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
 ffff88809ca6b580: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/03/02 05:57 linux-4.14.y 3242aa3a635c 183afb6c .config console log report syz ci2-linux-4-14 KASAN: use-after-free Read in nf_hook_slow
2022/08/16 04:51 linux-4.14.y b641242202ed 7a7cb304 .config console log report info ci2-linux-4-14 KASAN: use-after-free Read in nf_hook_slow
2021/03/12 05:05 linux-4.14.y c7150cd2fa8c 429d8a6b .config console log report info ci2-linux-4-14 KASAN: use-after-free Read in nf_hook_slow
2021/02/22 16:29 linux-4.14.y 29c52025152b c26fb06b .config console log report info ci2-linux-4-14 KASAN: use-after-free Read in nf_hook_slow
2020/12/08 20:36 linux-4.14.y 47cbf4cc32db 40cc414d .config console log report info ci2-linux-4-14
* Struck through repros no longer work on HEAD.