Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: use-after-free Read in ip6_pol_route
==================================================================
BUG: KASAN: use-after-free in rt6_get_pcpu_route net/ipv6/route.c:1394 [inline]
BUG: KASAN: use-after-free in ip6_pol_route+0x12cd/0x15c0 net/ipv6/route.c:2256
Read of size 4 at addr ffff88810ff8b2f8 by task kworker/0:3/377
CPU: 0 PID: 377 Comm: kworker/0:3 Not tainted 5.10.117-syzkaller-986967-g0974b8411a58-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events linkwatch_event
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
print_address_description+0x81/0x3c0 mm/kasan/report.c:233
__kasan_report mm/kasan/report.c:419 [inline]
kasan_report+0x1a4/0x1f0 mm/kasan/report.c:436
__asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:308
rt6_get_pcpu_route net/ipv6/route.c:1394 [inline]
ip6_pol_route+0x12cd/0x15c0 net/ipv6/route.c:2256
ip6_pol_route_input+0x54/0x80 net/ipv6/route.c:2280
pol_lookup_func include/net/ip6_fib.h:593 [inline]
fib6_rule_lookup+0x259/0x600 net/ipv6/fib6_rules.c:115
ip6_route_input_lookup net/ipv6/route.c:2292 [inline]
ip6_route_input+0x736/0xb30 net/ipv6/route.c:2461
ip6_rcv_finish_core net/ipv6/ip6_input.c:63 [inline]
ip6_rcv_finish net/ipv6/ip6_input.c:74 [inline]
NF_HOOK include/linux/netfilter.h:304 [inline]
ipv6_rcv+0x260/0x550 net/ipv6/ip6_input.c:297
__netif_receive_skb_one_core net/core/dev.c:5361 [inline]
__netif_receive_skb+0x1c5/0x500 net/core/dev.c:5475
process_backlog+0x352/0x690 net/core/dev.c:6381
napi_poll+0x1a3/0x650 net/core/dev.c:6832
net_rx_action+0x387/0x970 net/core/dev.c:6902
__do_softirq+0x27e/0x596 kernel/softirq.c:305
asm_call_irq_on_stack+0xf/0x20
</IRQ>
__run_on_irqstack arch/x86/include/asm/irq_stack.h:26 [inline]
run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:77 [inline]
do_softirq_own_stack+0x60/0x80 arch/x86/kernel/irq_64.c:77
do_softirq+0xca/0x110 kernel/softirq.c:355
__local_bh_enable_ip+0x70/0x80 kernel/softirq.c:190
__raw_read_unlock_bh include/linux/rwlock_api_smp.h:251 [inline]
_raw_read_unlock_bh+0x29/0x30 kernel/locking/spinlock.c:279
ipv6_mc_up+0x238/0x2c0 net/ipv6/mcast.c:2569
ipv6_find_idev net/ipv6/addrconf.c:489 [inline]
addrconf_add_dev+0x1ab/0x620 net/ipv6/addrconf.c:2509
addrconf_dev_config+0x237/0x570 net/ipv6/addrconf.c:3389
addrconf_notify+0x8d9/0xe90 net/ipv6/addrconf.c:3635
notifier_call_chain kernel/notifier.c:83 [inline]
raw_notifier_call_chain+0x9e/0x110 kernel/notifier.c:410
call_netdevice_notifiers_info net/core/dev.c:2054 [inline]
netdev_state_change+0x1ba/0x280 net/core/dev.c:1484
linkwatch_do_dev+0xfe/0x140 net/core/link_watch.c:167
__linkwatch_run_queue+0x4f5/0x7f0 net/core/link_watch.c:213
linkwatch_event+0x4c/0x60 net/core/link_watch.c:252
process_one_work+0x726/0xc10 kernel/workqueue.c:2296
worker_thread+0xb27/0x1550 kernel/workqueue.c:2442
kthread+0x349/0x3d0 kernel/kthread.c:313
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296
Allocated by task 377:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track mm/kasan/common.c:46 [inline]
set_alloc_info mm/kasan/common.c:428 [inline]
__kasan_slab_alloc+0xb2/0xe0 mm/kasan/common.c:461
kasan_slab_alloc include/linux/kasan.h:259 [inline]
slab_post_alloc_hook mm/slab.h:583 [inline]
slab_alloc_node mm/slub.c:2956 [inline]
slab_alloc mm/slub.c:2964 [inline]
kmem_cache_alloc+0x16c/0x300 mm/slub.c:2969
dst_alloc+0x187/0x590 net/core/dst.c:93
ip6_dst_alloc net/ipv6/route.c:339 [inline]
ip6_rt_pcpu_alloc net/ipv6/route.c:1367 [inline]
rt6_make_pcpu_route net/ipv6/route.c:1415 [inline]
ip6_pol_route+0xd06/0x15c0 net/ipv6/route.c:2259
ip6_pol_route_input+0x54/0x80 net/ipv6/route.c:2280
pol_lookup_func include/net/ip6_fib.h:593 [inline]
fib6_rule_lookup+0x259/0x600 net/ipv6/fib6_rules.c:115
ip6_route_input_lookup net/ipv6/route.c:2292 [inline]
ip6_route_input+0x736/0xb30 net/ipv6/route.c:2461
ip6_rcv_finish_core net/ipv6/ip6_input.c:63 [inline]
ip6_rcv_finish net/ipv6/ip6_input.c:74 [inline]
NF_HOOK include/linux/netfilter.h:304 [inline]
ipv6_rcv+0x260/0x550 net/ipv6/ip6_input.c:297
__netif_receive_skb_one_core net/core/dev.c:5361 [inline]
__netif_receive_skb+0x1c5/0x500 net/core/dev.c:5475
process_backlog+0x352/0x690 net/core/dev.c:6381
napi_poll+0x1a3/0x650 net/core/dev.c:6832
net_rx_action+0x387/0x970 net/core/dev.c:6902
__do_softirq+0x27e/0x596 kernel/softirq.c:305
Freed by task 377:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4c/0x80 mm/kasan/common.c:46
kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:357
____kasan_slab_free+0x121/0x160 mm/kasan/common.c:360
__kasan_slab_free+0x11/0x20 mm/kasan/common.c:368
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:1604 [inline]
slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1630
slab_free mm/slub.c:3212 [inline]
kmem_cache_free+0xa9/0x1f0 mm/slub.c:3228
dst_destroy+0x244/0x330 net/core/dst.c:129
dst_release_immediate+0x90/0xe0 net/core/dst.c:194
rt_fibinfo_free_cpus+0xf6/0x1c0 net/ipv4/fib_semantics.c:204
fib_nh_common_release+0x8d/0x240 net/ipv4/fib_semantics.c:216
fib_nh_release net/ipv4/fib_semantics.c:228 [inline]
free_fib_info_rcu+0x98/0x190 net/ipv4/fib_semantics.c:240
rcu_do_batch+0x59e/0xc40 kernel/rcu/tree.c:2485
rcu_core+0x59b/0xe30 kernel/rcu/tree.c:2726
rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2739
__do_softirq+0x27e/0x596 kernel/softirq.c:305
The buggy address belongs to the object at ffff88810ff8b280
which belongs to the cache ip6_dst_cache of size 240
The buggy address is located 120 bytes inside of
240-byte region [ffff88810ff8b280, ffff88810ff8b370)
The buggy address belongs to the page:
page:ffffea00043fe2c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10ff8b
flags: 0x8000000000000200(slab)
raw: 8000000000000200 dead000000000100 dead000000000122 ffff88810ae12780
raw: 0000000000000000 00000000000c000c 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 377, ts 39819635610, free_ts 38073197990
set_page_owner include/linux/page_owner.h:35 [inline]
post_alloc_hook mm/page_alloc.c:2385 [inline]
prep_new_page mm/page_alloc.c:2391 [inline]
get_page_from_freelist+0x745/0x760 mm/page_alloc.c:4067
__alloc_pages_nodemask+0x3b6/0x890 mm/page_alloc.c:5117
alloc_slab_page mm/slub.c:1815 [inline]
allocate_slab+0x78/0x540 mm/slub.c:1817
new_slab mm/slub.c:1878 [inline]
new_slab_objects mm/slub.c:2637 [inline]
___slab_alloc+0x131/0x2e0 mm/slub.c:2800
__slab_alloc+0x63/0xa0 mm/slub.c:2840
slab_alloc_node mm/slub.c:2922 [inline]
slab_alloc mm/slub.c:2964 [inline]
kmem_cache_alloc+0x1ef/0x300 mm/slub.c:2969
dst_alloc+0x187/0x590 net/core/dst.c:93
ip6_dst_alloc net/ipv6/route.c:339 [inline]
icmp6_dst_alloc+0xfb/0x5a0 net/ipv6/route.c:3160
mld_sendpack+0x49a/0xaf0 net/ipv6/mcast.c:1665
mld_send_cr net/ipv6/mcast.c:1972 [inline]
mld_ifc_timer_expire+0x85b/0xc50 net/ipv6/mcast.c:2471
call_timer_fn+0x35/0x270 kernel/time/timer.c:1420
expire_timers+0x21b/0x3a0 kernel/time/timer.c:1465
__run_timers+0x598/0x6f0 kernel/time/timer.c:1759
run_timer_softirq+0x69/0xf0 kernel/time/timer.c:1772
__do_softirq+0x27e/0x596 kernel/softirq.c:305
asm_call_irq_on_stack+0xf/0x20
page last free stack trace:
reset_page_owner include/linux/page_owner.h:28 [inline]
free_pages_prepare mm/page_alloc.c:1331 [inline]
__free_pages_ok+0x7f8/0x830 mm/page_alloc.c:1611
free_the_page mm/page_alloc.c:5178 [inline]
__free_pages+0x2d2/0x4c0 mm/page_alloc.c:5184
__free_slab+0xd3/0x190 mm/slub.c:1903
free_slab mm/slub.c:1918 [inline]
discard_slab mm/slub.c:1924 [inline]
unfreeze_partials+0x17d/0x1b0 mm/slub.c:2418
put_cpu_partial+0xc8/0x190 mm/slub.c:2454
__slab_free+0x2d8/0x3a0 mm/slub.c:3104
do_slab_free mm/slub.c:3200 [inline]
___cache_free+0x11f/0x140 mm/slub.c:3219
qlink_free+0x38/0x40 mm/kasan/quarantine.c:146
qlist_free_all+0x4c/0xc0 mm/kasan/quarantine.c:165
kasan_quarantine_reduce+0x15a/0x170 mm/kasan/quarantine.c:272
__kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:438
kasan_slab_alloc include/linux/kasan.h:259 [inline]
slab_post_alloc_hook mm/slab.h:583 [inline]
slab_alloc_node mm/slub.c:2956 [inline]
slab_alloc mm/slub.c:2964 [inline]
kmem_cache_alloc+0x16c/0x300 mm/slub.c:2969
kmem_cache_alloc_node include/linux/slab.h:423 [inline]
__alloc_skb+0x7e/0x580 net/core/skbuff.c:199
alloc_skb include/linux/skbuff.h:1101 [inline]
netlink_alloc_large_skb net/netlink/af_netlink.c:1185 [inline]
netlink_sendmsg+0x7a4/0xd00 net/netlink/af_netlink.c:1909
sock_sendmsg_nosec net/socket.c:652 [inline]
sock_sendmsg net/socket.c:672 [inline]
__sys_sendto+0x541/0x700 net/socket.c:1982
__do_sys_sendto net/socket.c:1994 [inline]
__se_sys_sendto net/socket.c:1990 [inline]
__x64_sys_sendto+0xe5/0x100 net/socket.c:1990
Memory state around the buggy address:
ffff88810ff8b180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88810ff8b200: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc
>ffff88810ff8b280: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88810ff8b300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
ffff88810ff8b380: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
==================================================================
general protection fault, probably for non-canonical address 0xdffffc000000000f: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000078-0x000000000000007f]
CPU: 0 PID: 386 Comm: kworker/0:5 Tainted: G B 5.10.117-syzkaller-986967-g0974b8411a58-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: ipv6_addrconf addrconf_dad_work
RIP: 0010:rt6_get_pcpu_route net/ipv6/route.c:1394 [inline]
RIP: 0010:ip6_pol_route+0x741/0x15c0 net/ipv6/route.c:2256
Code: e8 54 c1 7d fd 48 8b 03 65 4c 8b 30 31 ff 4c 89 f6 e8 33 f3 43 fd 4d 85 f6 0f 84 a7 00 00 00 49 8d 5e 78 48 89 d8 48 c1 e8 03 <42> 8a 04 28 84 c0 0f 85 68 0b 00 00 44 8b 3b 31 ff 44 89 fe e8 56
RSP: 0018:ffffc90000007580 EFLAGS: 00010206
RAX: 000000000000000f RBX: 0000000000000079 RCX: 0000000080000301
RDX: ffff888103ff8000 RSI: 0000000000000001 RDI: 0000000000000000
RBP: ffffc90000007718 R08: ffffffff8428c43d R09: ffff8881108c2000
R10: ffffc90000007500 R11: 1ffff92000000ece R12: ffff88810cad1340
R13: dffffc0000000000 R14: 0000000000000001 R15: ffffc90000007670
FS: 0000000000000000(0000) GS:ffff8881f7200000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fd728f38922 CR3: 000000010c3f4000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<IRQ>
ip6_pol_route_input+0x54/0x80 net/ipv6/route.c:2280
pol_lookup_func include/net/ip6_fib.h:593 [inline]
fib6_rule_lookup+0x259/0x600 net/ipv6/fib6_rules.c:115
ip6_route_input_lookup net/ipv6/route.c:2292 [inline]
ip6_route_input+0x736/0xb30 net/ipv6/route.c:2461
ip6_rcv_finish_core net/ipv6/ip6_input.c:63 [inline]
ip6_rcv_finish net/ipv6/ip6_input.c:74 [inline]
NF_HOOK include/linux/netfilter.h:304 [inline]
ipv6_rcv+0x260/0x550 net/ipv6/ip6_input.c:297
__netif_receive_skb_one_core net/core/dev.c:5361 [inline]
__netif_receive_skb+0x1c5/0x500 net/core/dev.c:5475
process_backlog+0x352/0x690 net/core/dev.c:6381
napi_poll+0x1a3/0x650 net/core/dev.c:6832
net_rx_action+0x387/0x970 net/core/dev.c:6902
__do_softirq+0x27e/0x596 kernel/softirq.c:305
asm_call_irq_on_stack+0xf/0x20
</IRQ>
__run_on_irqstack arch/x86/include/asm/irq_stack.h:26 [inline]
run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:77 [inline]
do_softirq_own_stack+0x60/0x80 arch/x86/kernel/irq_64.c:77
do_softirq+0xca/0x110 kernel/softirq.c:355
__local_bh_enable_ip+0x70/0x80 kernel/softirq.c:190
local_bh_enable+0x1f/0x30 include/linux/bottom_half.h:32
rcu_read_unlock_bh include/linux/rcupdate.h:740 [inline]
ip6_finish_output2+0x1094/0x1950 net/ipv6/ip6_output.c:146
__ip6_finish_output+0x653/0x810 net/ipv6/ip6_output.c:210
ip6_finish_output+0x1c9/0x1e0 net/ipv6/ip6_output.c:220
NF_HOOK_COND include/linux/netfilter.h:293 [inline]
ip6_output+0x211/0x4c0 net/ipv6/ip6_output.c:243
dst_output include/net/dst.h:443 [inline]
NF_HOOK include/linux/netfilter.h:304 [inline]
ndisc_send_skb+0x6fe/0xc10 net/ipv6/ndisc.c:508
ndisc_send_ns+0x629/0x810 net/ipv6/ndisc.c:650
addrconf_dad_work+0xba6/0x15d0 net/ipv6/addrconf.c:4165
process_one_work+0x726/0xc10 kernel/workqueue.c:2296
worker_thread+0xb27/0x1550 kernel/workqueue.c:2442
kthread+0x349/0x3d0 kernel/kthread.c:313
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296
Modules linked in:
---[ end trace f8aa0e220c2dcc15 ]---
RIP: 0010:rt6_get_pcpu_route net/ipv6/route.c:1394 [inline]
RIP: 0010:ip6_pol_route+0x741/0x15c0 net/ipv6/route.c:2256
Code: e8 54 c1 7d fd 48 8b 03 65 4c 8b 30 31 ff 4c 89 f6 e8 33 f3 43 fd 4d 85 f6 0f 84 a7 00 00 00 49 8d 5e 78 48 89 d8 48 c1 e8 03 <42> 8a 04 28 84 c0 0f 85 68 0b 00 00 44 8b 3b 31 ff 44 89 fe e8 56
RSP: 0018:ffffc90000007580 EFLAGS: 00010206
RAX: 000000000000000f RBX: 0000000000000079 RCX: 0000000080000301
RDX: ffff888103ff8000 RSI: 0000000000000001 RDI: 0000000000000000
RBP: ffffc90000007718 R08: ffffffff8428c43d R09: ffff8881108c2000
R10: ffffc90000007500 R11: 1ffff92000000ece R12: ffff88810cad1340
R13: dffffc0000000000 R14: 0000000000000001 R15: ffffc90000007670
FS: 0000000000000000(0000) GS:ffff8881f7200000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fd728f38922 CR3: 000000010c3f4000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: e8 54 c1 7d fd callq 0xfd7dc159
5: 48 8b 03 mov (%rbx),%rax
8: 65 4c 8b 30 mov %gs:(%rax),%r14
c: 31 ff xor %edi,%edi
e: 4c 89 f6 mov %r14,%rsi
11: e8 33 f3 43 fd callq 0xfd43f349
16: 4d 85 f6 test %r14,%r14
19: 0f 84 a7 00 00 00 je 0xc6
1f: 49 8d 5e 78 lea 0x78(%r14),%rbx
23: 48 89 d8 mov %rbx,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 42 8a 04 28 mov (%rax,%r13,1),%al <-- trapping instruction
2e: 84 c0 test %al,%al
30: 0f 85 68 0b 00 00 jne 0xb9e
36: 44 8b 3b mov (%rbx),%r15d
39: 31 ff xor %edi,%edi
3b: 44 89 fe mov %r15d,%esi
3e: e8 .byte 0xe8
3f: 56 push %rsi
Tested on:
commit: 0974b841 Merge 5.10.117 into android12-5.10-lts
git tree: android12-5.10-lts
console output:
https://syzkaller.appspot.com/x/log.txt?x=17c01fc3f00000
kernel config:
https://syzkaller.appspot.com/x/.config?x=b9b19582654944dd
dashboard link:
https://syzkaller.appspot.com/bug?extid=badfd07a93cffefd7317
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
patch:
https://syzkaller.appspot.com/x/patch.diff?x=121e2b8df00000