[v5.15] KASAN: use-after-free Read in tcp_retransmit_timer (2)

3 views
Skip to first unread message

syzbot

unread,
Oct 23, 2023, 2:56:01 PM10/23/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 00c03985402e Linux 5.15.136
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1633e193680000
kernel config: https://syzkaller.appspot.com/x/.config?x=79895f3f9bd63186
dashboard link: https://syzkaller.appspot.com/bug?extid=9bd95114d8474cd0dfa5
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/878303cc21ca/disk-00c03985.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/78f166268559/vmlinux-00c03985.xz
kernel image: https://storage.googleapis.com/syzbot-assets/509e05cddc3e/bzImage-00c03985.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+9bd951...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in tcp_retransmit_timer+0x6df/0x2810 net/ipv4/tcp_timer.c:531
Read of size 8 at addr ffff888076610258 by task syz-executor.2/9652

CPU: 1 PID: 9652 Comm: syz-executor.2 Not tainted 5.15.136-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/2023
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
print_address_description+0x63/0x3b0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:434 [inline]
kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
tcp_retransmit_timer+0x6df/0x2810 net/ipv4/tcp_timer.c:531
tcp_write_timer_handler+0x1f7/0x9c0 net/ipv4/tcp_timer.c:644
tcp_write_timer+0x12e/0x280 net/ipv4/tcp_timer.c:664
call_timer_fn+0x16d/0x560 kernel/time/timer.c:1421
expire_timers kernel/time/timer.c:1466 [inline]
__run_timers+0x67c/0x890 kernel/time/timer.c:1737
run_timer_softirq+0x63/0xf0 kernel/time/timer.c:1750
__do_softirq+0x3b3/0x93a kernel/softirq.c:558
invoke_softirq kernel/softirq.c:432 [inline]
__irq_exit_rcu+0x155/0x240 kernel/softirq.c:637
irq_exit_rcu+0x5/0x20 kernel/softirq.c:649
sysvec_apic_timer_interrupt+0x91/0xb0 arch/x86/kernel/apic/apic.c:1096
</IRQ>
<TASK>
asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:638
RIP: 0010:lock_acquire+0x252/0x4f0 kernel/locking/lockdep.c:5626
Code: 2b 00 74 08 4c 89 f7 e8 8c 56 67 00 f6 44 24 61 02 0f 85 84 01 00 00 41 f7 c7 00 02 00 00 74 01 fb 48 c7 44 24 40 0e 36 e0 45 <4b> c7 44 25 00 00 00 00 00 43 c7 44 25 09 00 00 00 00 43 c7 44 25
RSP: 0018:ffffc900034ff140 EFLAGS: 00000206
RAX: 0000000000000001 RBX: 1ffff9200069fe34 RCX: 1ffff9200069fdd4
RDX: dffffc0000000000 RSI: ffffffff8a8b1e00 RDI: ffffffff8ad87a40
RBP: ffffc900034ff290 R08: dffffc0000000000 R09: fffffbfff1f79a21
R10: 0000000000000000 R11: dffffc0000000001 R12: 1ffff9200069fe30
R13: dffffc0000000000 R14: ffffc900034ff1a0 R15: 0000000000000246
rcu_lock_acquire+0x20/0x30 include/linux/rcupdate.h:269
rcu_read_lock include/linux/rcupdate.h:696 [inline]
get_mem_cgroup_from_mm+0x31/0x260 mm/memcontrol.c:986
__mem_cgroup_charge+0x12/0x80 mm/memcontrol.c:6776
mem_cgroup_charge include/linux/memcontrol.h:700 [inline]
shmem_add_to_page_cache+0xc22/0x17c0 mm/shmem.c:718
shmem_getpage_gfp+0x1aa1/0x3190 mm/shmem.c:1940
shmem_fault+0x1d7/0x700 mm/shmem.c:2118
__do_fault+0x139/0x340 mm/memory.c:3898
do_read_fault mm/memory.c:4234 [inline]
do_fault mm/memory.c:4362 [inline]
handle_pte_fault mm/memory.c:4621 [inline]
__handle_mm_fault mm/memory.c:4756 [inline]
handle_mm_fault+0x376f/0x5950 mm/memory.c:4854
faultin_page mm/gup.c:976 [inline]
__get_user_pages+0x4ed/0x11d0 mm/gup.c:1197
populate_vma_page_range+0x215/0x2a0 mm/gup.c:1529
__mm_populate+0x2a5/0x4a0 mm/gup.c:1638
mm_populate include/linux/mm.h:2632 [inline]
vm_mmap_pgoff+0x22b/0x2d0 mm/util.c:556
ksys_mmap_pgoff+0x13e/0x780 mm/mmap.c:1624
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7f530ac65ae9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f53091e70c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000009
RAX: ffffffffffffffda RBX: 00007f530ad84f80 RCX: 00007f530ac65ae9
RDX: b635773f06ebbeee RSI: 0000000000b36000 RDI: 0000000020000000
RBP: 00007f530acb147a R08: ffffffffffffffff R09: 0000000000000000
R10: 0000000000008031 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f530ad84f80 R15: 00007ffea5a12848
</TASK>

Allocated by task 3544:
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:434 [inline]
__kasan_slab_alloc+0x8e/0xc0 mm/kasan/common.c:467
kasan_slab_alloc include/linux/kasan.h:254 [inline]
slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
slab_alloc_node mm/slub.c:3220 [inline]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
kmem_cache_zalloc include/linux/slab.h:711 [inline]
net_alloc net/core/net_namespace.c:405 [inline]
copy_net_ns+0x143/0x5d0 net/core/net_namespace.c:460
create_new_namespaces+0x425/0x7a0 kernel/nsproxy.c:110
unshare_nsproxy_namespaces+0x11e/0x170 kernel/nsproxy.c:226
ksys_unshare+0x580/0xb20 kernel/fork.c:3101
__do_sys_unshare kernel/fork.c:3175 [inline]
__se_sys_unshare kernel/fork.c:3173 [inline]
__x64_sys_unshare+0x34/0x40 kernel/fork.c:3173
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

The buggy address belongs to the object at ffff888076610000
which belongs to the cache net_namespace of size 6464
The buggy address is located 600 bytes inside of
6464-byte region [ffff888076610000, ffff888076611940)
The buggy address belongs to the page:
page:ffffea0001d98400 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888076610000 pfn:0x76610
head:ffffea0001d98400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0001f3ec00 0000000300000003 ffff8881400063c0
raw: ffff888076610000 0000000080040002 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3544, ts 188556435788, free_ts 188555054311
prep_new_page mm/page_alloc.c:2426 [inline]
get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
__alloc_pages+0x272/0x700 mm/page_alloc.c:5421
alloc_slab_page mm/slub.c:1775 [inline]
allocate_slab mm/slub.c:1912 [inline]
new_slab+0xbb/0x4b0 mm/slub.c:1975
___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
__slab_alloc mm/slub.c:3095 [inline]
slab_alloc_node mm/slub.c:3186 [inline]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc+0x18e/0x280 mm/slub.c:3233
kmem_cache_zalloc include/linux/slab.h:711 [inline]
net_alloc net/core/net_namespace.c:405 [inline]
copy_net_ns+0x143/0x5d0 net/core/net_namespace.c:460
create_new_namespaces+0x425/0x7a0 kernel/nsproxy.c:110
unshare_nsproxy_namespaces+0x11e/0x170 kernel/nsproxy.c:226
ksys_unshare+0x580/0xb20 kernel/fork.c:3101
__do_sys_unshare kernel/fork.c:3175 [inline]
__se_sys_unshare kernel/fork.c:3173 [inline]
__x64_sys_unshare+0x34/0x40 kernel/fork.c:3173
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1340 [inline]
free_pcp_prepare mm/page_alloc.c:1391 [inline]
free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
free_nonslab_page+0xe4/0x150 mm/slub.c:3535
kfree+0x1cf/0x270 mm/slub.c:4556
skb_free_head net/core/skbuff.c:655 [inline]
skb_release_data+0x73a/0x8a0 net/core/skbuff.c:677
skb_release_all net/core/skbuff.c:742 [inline]
__kfree_skb net/core/skbuff.c:756 [inline]
consume_skb+0xa3/0x140 net/core/skbuff.c:914
skb_free_datagram+0x24/0xe0 net/core/datagram.c:325
netlink_recvmsg+0x5ef/0x1190 net/netlink/af_netlink.c:2002
____sys_recvmsg+0x286/0x530
___sys_recvmsg+0x1ec/0x690 net/socket.c:2690
__sys_recvmsg net/socket.c:2720 [inline]
__do_sys_recvmsg net/socket.c:2730 [inline]
__se_sys_recvmsg net/socket.c:2727 [inline]
__x64_sys_recvmsg+0x1dc/0x2b0 net/socket.c:2727
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

Memory state around the buggy address:
ffff888076610100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888076610180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888076610200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888076610280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888076610300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess):
0: 2b 00 sub (%rax),%eax
2: 74 08 je 0xc
4: 4c 89 f7 mov %r14,%rdi
7: e8 8c 56 67 00 call 0x675698
c: f6 44 24 61 02 testb $0x2,0x61(%rsp)
11: 0f 85 84 01 00 00 jne 0x19b
17: 41 f7 c7 00 02 00 00 test $0x200,%r15d
1e: 74 01 je 0x21
20: fb sti
21: 48 c7 44 24 40 0e 36 movq $0x45e0360e,0x40(%rsp)
28: e0 45
* 2a: 4b c7 44 25 00 00 00 movq $0x0,0x0(%r13,%r12,1) <-- trapping instruction
31: 00 00
33: 43 c7 44 25 09 00 00 movl $0x0,0x9(%r13,%r12,1)
3a: 00 00
3c: 43 rex.XB
3d: c7 .byte 0xc7
3e: 44 rex.R
3f: 25 .byte 0x25


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup
Reply all
Reply to author
Forward
0 new messages