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

Status: upstream: reported on 2022/05/18 14:44
First crash: 90d, last: 90d
similar bugs (6):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: slab-out-of-bounds Read in _decode_session6 23 238d 893d 0/1 auto-closed as invalid on 2022/04/20 21:31
linux-4.14 KASAN: use-after-free Read in _decode_session6 2 815d 823d 0/1 auto-closed as invalid on 2020/09/21 07:45
linux-4.19 KASAN: use-after-free Read in _decode_session6 2 783d 815d 0/1 auto-closed as invalid on 2020/10/22 17:34
android-414 KASAN: use-after-free Read in _decode_session6 1 1433d 1433d 0/1 auto-closed as invalid on 2019/03/12 14:41
upstream KASAN: use-after-free Read in _decode_session6 C done 4 1372d 1440d 14/23 fixed on 2019/11/07 18:45
linux-4.14 KASAN: slab-out-of-bounds Read in _decode_session6 (2) 2 100d 119d 0/1 upstream: reported on 2022/04/20 02:56

Sample crash report:
netlink: 'syz-executor.4': attribute type 4 has an invalid length.
netlink: 24 bytes leftover after parsing attributes in process `syz-executor.4'.
BUG: KASAN: use-after-free in _decode_session6+0xf56/0x1370 net/ipv6/xfrm6_policy.c:137
Read of size 1 at addr ffff8880aa6fabce by task syz-executor.3/8486

CPU: 1 PID: 8486 Comm: syz-executor.3 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
netlink: 'syz-executor.4': attribute type 4 has an invalid length.
 kasan_report mm/kasan/report.c:412 [inline]
 __asan_report_load1_noabort+0x88/0x90 mm/kasan/report.c:430
 _decode_session6+0xf56/0x1370 net/ipv6/xfrm6_policy.c:137
audit: type=1800 audit(1652885037.651:451): pid=8470 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=collect_data cause=failed(directio) comm="syz-executor.1" name="file0" dev="sda1" ino=14156 res=0
 __xfrm_decode_session+0x5a/0x130 net/xfrm/xfrm_policy.c:2299
 xfrm_decode_session_reverse include/net/xfrm.h:1245 [inline]
 icmpv6_route_lookup+0x324/0x4e0 net/ipv6/icmp.c:371
audit: type=1804 audit(1652885037.661:452): pid=8470 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=invalid_pcr cause=open_writers comm="syz-executor.1" name="/root/syzkaller-testdir2249861264/syzkaller.vvWE1T/229/file0" dev="sda1" ino=14156 res=1
 icmp6_send+0x1592/0x22c0 net/ipv6/icmp.c:555
 __icmpv6_send include/linux/icmpv6.h:28 [inline]
 icmpv6_send include/linux/icmpv6.h:49 [inline]
 ip6_link_failure+0x2d/0x4f0 net/ipv6/route.c:2297
 dst_link_failure include/net/dst.h:438 [inline]
 ipip6_tunnel_xmit net/ipv6/sit.c:999 [inline]
 sit_tunnel_xmit+0x19c5/0x28d0 net/ipv6/sit.c:1036
 __netdev_start_xmit include/linux/netdevice.h:4349 [inline]
 netdev_start_xmit include/linux/netdevice.h:4363 [inline]
 xmit_one net/core/dev.c:3256 [inline]
 dev_hard_start_xmit+0x1a8/0x920 net/core/dev.c:3272
 sch_direct_xmit+0x2d6/0xf70 net/sched/sch_generic.c:332
audit: type=1800 audit(1652885038.041:453): pid=8487 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=collect_data cause=failed(directio) comm="syz-executor.1" name="file0" dev="loop1" ino=251 res=0
 qdisc_restart net/sched/sch_generic.c:395 [inline]
 __qdisc_run+0x4d0/0x1640 net/sched/sch_generic.c:403
 __dev_xmit_skb net/core/dev.c:3500 [inline]
 __dev_queue_xmit+0x1518/0x2e00 net/core/dev.c:3807
 neigh_output include/net/neighbour.h:501 [inline]
 ip6_finish_output2+0x113d/0x2290 net/ipv6/ip6_output.c:120
audit: type=1804 audit(1652885038.041:454): pid=8487 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=invalid_pcr cause=open_writers comm="syz-executor.1" name="/root/syzkaller-testdir2249861264/syzkaller.vvWE1T/230/file0/file0" dev="loop1" ino=251 res=1
 ip6_fragment+0x29bb/0x34e0 net/ipv6/ip6_output.c:761
 ip6_finish_output+0x9da/0x10f0 net/ipv6/ip6_output.c:190
 NF_HOOK_COND include/linux/netfilter.h:278 [inline]
 ip6_output+0x205/0x770 net/ipv6/ip6_output.c:209
 dst_output include/net/dst.h:455 [inline]
 ip6_local_out+0xaf/0x170 net/ipv6/output_core.c:160
 ip6_send_skb+0xb3/0x300 net/ipv6/ip6_output.c:1741
 ip6_push_pending_frames+0xbd/0xe0 net/ipv6/ip6_output.c:1761
 rawv6_push_pending_frames net/ipv6/raw.c:618 [inline]
 rawv6_sendmsg+0x2a81/0x36a0 net/ipv6/raw.c:959
 inet_sendmsg+0x132/0x5a0 net/ipv4/af_inet.c:798
 sock_sendmsg_nosec net/socket.c:651 [inline]
 sock_sendmsg+0xc3/0x120 net/socket.c:661
 ___sys_sendmsg+0x7bb/0x8e0 net/socket.c:2227
 __sys_sendmsg net/socket.c:2265 [inline]
 __do_sys_sendmsg net/socket.c:2274 [inline]
 __se_sys_sendmsg net/socket.c:2272 [inline]
 __x64_sys_sendmsg+0x132/0x220 net/socket.c:2272
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
RIP: 0033:0x7f2fde90d0e9
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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f2fdd282168 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f2fdea1ff60 RCX: 00007f2fde90d0e9
RDX: 0000000000000000 RSI: 0000000020000180 RDI: 0000000000000004
RBP: 00007f2fde96708d R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffe38fbb99f R14: 00007f2fdd282300 R15: 0000000000022000

Allocated by task 8140:
 kmem_cache_alloc+0x122/0x370 mm/slab.c:3559
 vm_area_dup kernel/fork.c:329 [inline]
 dup_mmap kernel/fork.c:489 [inline]
 dup_mm kernel/fork.c:1285 [inline]
 copy_mm kernel/fork.c:1341 [inline]
 copy_process.part.0+0x343d/0x8260 kernel/fork.c:1913
 copy_process kernel/fork.c:1710 [inline]
 _do_fork+0x22f/0xf30 kernel/fork.c:2219
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293

Freed by task 7414:
 __cache_free mm/slab.c:3503 [inline]
 kmem_cache_free+0x7f/0x260 mm/slab.c:3765
 remove_vma+0x132/0x170 mm/mmap.c:180
 exit_mmap+0x359/0x530 mm/mmap.c:3104
 __mmput kernel/fork.c:1016 [inline]
 mmput+0x14e/0x4a0 kernel/fork.c:1037
 exit_mm kernel/exit.c:549 [inline]
 do_exit+0xaec/0x2be0 kernel/exit.c:857
 do_group_exit+0x125/0x310 kernel/exit.c:967
 get_signal+0x3f2/0x1f70 kernel/signal.c:2589
 do_signal+0x8f/0x1670 arch/x86/kernel/signal.c:799
 exit_to_usermode_loop+0x204/0x2a0 arch/x86/entry/common.c:163
 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
 do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296

The buggy address belongs to the object at ffff8880aa6fab58
 which belongs to the cache vm_area_struct of size 200
The buggy address is located 118 bytes inside of
 200-byte region [ffff8880aa6fab58, ffff8880aa6fac20)
The buggy address belongs to the page:
page:ffffea0002a9be80 count:1 mapcount:0 mapping:ffff88813be45680 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea0001a0e408 ffffea000277f088 ffff88813be45680
raw: 0000000000000000 ffff8880aa6fa000 000000010000000f 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880aa6faa80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880aa6fab00: fb fb fb fc fc fc fc fc fc fc fc fb fb fb fb fb
>ffff8880aa6fab80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880aa6fac00: fb fb fb fb fc fc fc fc fc fc fc fc fb fb fb fb
 ffff8880aa6fac80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb

Crashes (1):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-linux-4-19 2022/05/18 14:44 linux-4.19.y 3f8a27f9e27b 50c53f39 .config log report info KASAN: use-after-free Read in _decode_session6