KASAN: use-after-free Read in tipc_udp_xmit

6 views
Skip to first unread message

syzbot

unread,
Aug 15, 2021, 2:20:29 PM8/15/21
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 59456c9cc40c Linux 4.19.204
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=13a3f181300000
kernel config: https://syzkaller.appspot.com/x/.config?x=a84b4514346e13dc
dashboard link: https://syzkaller.appspot.com/bug?extid=88458b50d3fe169b97b5
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)

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

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

EXT4-fs (loop4): Invalid log cluster size: 33554432
Enabling of bearer <udp:syz0> rejected, already enabled
Disabling bearer <udp:syz0>
==================================================================
BUG: KASAN: use-after-free in tipc_udp_xmit+0x96b/0xc10 net/tipc/udp_media.c:193
Read of size 8 at addr ffff88804d3b10e0 by task systemd-udevd/4706

CPU: 0 PID: 4706 Comm: systemd-udevd Not tainted 4.19.204-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: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_load8_noabort+0x88/0x90 mm/kasan/report.c:433
tipc_udp_xmit+0x96b/0xc10 net/tipc/udp_media.c:193
tipc_udp_send_msg+0x279/0x490 net/tipc/udp_media.c:248
tipc_bearer_xmit_skb+0x15b/0x330 net/tipc/bearer.c:518
tipc_disc_timeout+0x855/0xc90 net/tipc/discover.c:332
call_timer_fn+0x177/0x700 kernel/time/timer.c:1338
expire_timers+0x243/0x4e0 kernel/time/timer.c:1375
__run_timers kernel/time/timer.c:1696 [inline]
run_timer_softirq+0x21c/0x670 kernel/time/timer.c:1709
__do_softirq+0x265/0x980 kernel/softirq.c:292
invoke_softirq kernel/softirq.c:372 [inline]
irq_exit+0x215/0x260 kernel/softirq.c:412
exiting_irq arch/x86/include/asm/apic.h:536 [inline]
smp_apic_timer_interrupt+0x136/0x550 arch/x86/kernel/apic/apic.c:1098
apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:894
</IRQ>
RIP: 0010:__devcgroup_check_permission+0x147/0x3c0 security/device_cgroup.c:812
Code: ff df 49 8b 5f 28 48 8d bb 40 01 00 00 48 89 fa 48 c1 ea 03 0f b6 04 02 84 c0 74 08 3c 03 0f 8e 51 02 00 00 8b 83 40 01 00 00 <bf> 01 00 00 00 44 0f bf fd 45 0f bf e4 48 8d ab 30 01 00 00 89 c6
RSP: 0018:ffff888098b17808 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff13
RAX: 0000000000000001 RBX: ffff88809908b000 RCX: ffffffff8346e2a1
RDX: 1ffff11013211628 RSI: ffffffff8346e036 RDI: ffff88809908b140
RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000005 R11: 0000000000000000 R12: 0000000000000002
R13: 0000000000000007 R14: 0000000000000005 R15: ffff8880992c44c0
devcgroup_check_permission include/linux/device_cgroup.h:32 [inline]
devcgroup_inode_permission include/linux/device_cgroup.h:54 [inline]
__blkdev_get+0x7e8/0x1480 fs/block_dev.c:1465
blkdev_get+0xb0/0x940 fs/block_dev.c:1627
EXT4-fs (loop4): inodes count not valid: 32 vs 256
blkdev_open+0x202/0x290 fs/block_dev.c:1788
do_dentry_open+0x4aa/0x1160 fs/open.c:796
do_last fs/namei.c:3421 [inline]
path_openat+0x793/0x2df0 fs/namei.c:3537
do_filp_open+0x18c/0x3f0 fs/namei.c:3567
do_sys_open+0x3b3/0x520 fs/open.c:1085
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f825b41b840
Code: 73 01 c3 48 8b 0d 68 77 20 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 89 bb 20 00 00 75 10 b8 02 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 1e f6 ff ff 48 89 04 24
RSP: 002b:00007ffd1a16bc28 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 00007ffd1a16bcd0 RCX: 00007f825b41b840
RDX: 0000563bf0d10fe3 RSI: 00000000000a0800 RDI: 0000563bf1a3c510
RBP: 00007ffd1a16c200 R08: 0000563bf0d10670 R09: 0000000000000010
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffd1a16bdd0
R13: 0000563bf1a27010 R14: 0000563bf1a2ced0 R15: 00007ffd1a16bca0

Allocated by task 13439:
kmem_cache_alloc+0x122/0x370 mm/slab.c:3559
sock_alloc_inode+0x19/0x250 net/socket.c:244
alloc_inode+0x5d/0x180 fs/inode.c:211
new_inode_pseudo+0x14/0xe0 fs/inode.c:911
sock_alloc+0x3c/0x260 net/socket.c:567
__sock_create+0xba/0x740 net/socket.c:1327
udp_sock_create6+0xd1/0x550 net/ipv6/ip6_udp_tunnel.c:22
udp_sock_create include/net/udp_tunnel.h:61 [inline]
tipc_udp_enable+0xb48/0x14d0 net/tipc/udp_media.c:734
tipc_enable_bearer+0x70f/0xbe0 net/tipc/bearer.c:317
__tipc_nl_bearer_enable+0x2e2/0x3d0 net/tipc/bearer.c:916
tipc_nl_bearer_enable+0x1e/0x30 net/tipc/bearer.c:925
genl_family_rcv_msg+0x642/0xc40 net/netlink/genetlink.c:602
genl_rcv_msg+0xbf/0x160 net/netlink/genetlink.c:627
netlink_rcv_skb+0x160/0x440 net/netlink/af_netlink.c:2457
genl_rcv+0x24/0x40 net/netlink/genetlink.c:638
netlink_unicast_kernel net/netlink/af_netlink.c:1320 [inline]
netlink_unicast+0x4d5/0x690 net/netlink/af_netlink.c:1346
netlink_sendmsg+0x6bb/0xc40 net/netlink/af_netlink.c:1911
sock_sendmsg_nosec net/socket.c:651 [inline]
sock_sendmsg+0xc3/0x120 net/socket.c:661
___sys_sendmsg+0x7bb/0x8e0 net/socket.c:2225
__sys_sendmsg net/socket.c:2263 [inline]
__do_sys_sendmsg net/socket.c:2272 [inline]
__se_sys_sendmsg net/socket.c:2270 [inline]
__x64_sys_sendmsg+0x132/0x220 net/socket.c:2270
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 7231:
__cache_free mm/slab.c:3503 [inline]
kmem_cache_free+0x7f/0x260 mm/slab.c:3765
destroy_inode+0xb9/0x110 fs/inode.c:268
iput_final fs/inode.c:1555 [inline]
iput+0x4f1/0x860 fs/inode.c:1581
__sock_release net/socket.c:611 [inline]
sock_release+0x174/0x1d0 net/socket.c:619
cleanup_bearer+0x1bb/0x280 net/tipc/udp_media.c:775
process_one_work+0x864/0x1570 kernel/workqueue.c:2153
worker_thread+0x64c/0x1130 kernel/workqueue.c:2296
kthread+0x33f/0x460 kernel/kthread.c:259
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

The buggy address belongs to the object at ffff88804d3b10c0
which belongs to the cache sock_inode_cache of size 992
The buggy address is located 32 bytes inside of
992-byte region [ffff88804d3b10c0, ffff88804d3b14a0)
The buggy address belongs to the page:
page:ffffea000134ec40 count:1 mapcount:0 mapping:ffff88823b33a6c0 index:0xffff88804d3b1ffd
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea000236e0c8 ffffea00009bafc8 ffff88823b33a6c0
raw: ffff88804d3b1ffd ffff88804d3b10c0 0000000100000003 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88804d3b0f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88804d3b1000: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88804d3b1080: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
^
ffff88804d3b1100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88804d3b1180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess), 1 bytes skipped:
0: df 49 8b fisttps -0x75(%rcx)
3: 5f pop %rdi
4: 28 48 8d sub %cl,-0x73(%rax)
7: bb 40 01 00 00 mov $0x140,%ebx
c: 48 89 fa mov %rdi,%rdx
f: 48 c1 ea 03 shr $0x3,%rdx
13: 0f b6 04 02 movzbl (%rdx,%rax,1),%eax
17: 84 c0 test %al,%al
19: 74 08 je 0x23
1b: 3c 03 cmp $0x3,%al
1d: 0f 8e 51 02 00 00 jle 0x274
23: 8b 83 40 01 00 00 mov 0x140(%rbx),%eax
29: bf 01 00 00 00 mov $0x1,%edi <-- trapping instruction
2e: 44 0f bf fd movswl %bp,%r15d
32: 45 0f bf e4 movswl %r12w,%r12d
36: 48 8d ab 30 01 00 00 lea 0x130(%rbx),%rbp
3d: 89 c6 mov %eax,%esi


---
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.

syzbot

unread,
Aug 15, 2021, 7:38:18 PM8/15/21
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 59456c9cc40c Linux 4.19.204
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=145b3e19300000
kernel config: https://syzkaller.appspot.com/x/.config?x=a84b4514346e13dc
dashboard link: https://syzkaller.appspot.com/bug?extid=88458b50d3fe169b97b5
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=112874a6300000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=166ad641300000

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

Disabling bearer <udp:syz0>
New replicast peer: fe80:0000:0000:0000:0000:0000:0000:0000
Enabled bearer <udp:syz0>, priority 10
Disabling bearer <udp:syz0>
==================================================================
BUG: KASAN: use-after-free in tipc_udp_xmit+0xa7d/0xc10 net/tipc/udp_media.c:200
Read of size 8 at addr ffff88808a56a5a0 by task swapper/1/0

CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.19.204-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: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_load8_noabort+0x88/0x90 mm/kasan/report.c:433
tipc_udp_xmit+0xa7d/0xc10 net/tipc/udp_media.c:200
tipc_udp_send_msg+0x279/0x490 net/tipc/udp_media.c:248
tipc_bearer_xmit_skb+0x15b/0x330 net/tipc/bearer.c:518
tipc_disc_timeout+0x855/0xc90 net/tipc/discover.c:332
call_timer_fn+0x177/0x700 kernel/time/timer.c:1338
expire_timers+0x243/0x4e0 kernel/time/timer.c:1375
__run_timers kernel/time/timer.c:1696 [inline]
run_timer_softirq+0x21c/0x670 kernel/time/timer.c:1709
__do_softirq+0x265/0x980 kernel/softirq.c:292
invoke_softirq kernel/softirq.c:372 [inline]
irq_exit+0x215/0x260 kernel/softirq.c:412
exiting_irq arch/x86/include/asm/apic.h:536 [inline]
smp_apic_timer_interrupt+0x136/0x550 arch/x86/kernel/apic/apic.c:1098
apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:894
</IRQ>
RIP: 0010:native_safe_halt+0xe/0x10 arch/x86/include/asm/irqflags.h:61
Code: 48 89 df e8 d4 59 7f f9 e9 2e ff ff ff 48 89 df e8 c7 59 7f f9 eb 82 90 90 90 90 90 e9 07 00 00 00 0f 00 2d b4 77 4e 00 fb f4 <c3> 90 e9 07 00 00 00 0f 00 2d a4 77 4e 00 f4 c3 90 90 41 56 41 55
RSP: 0018:ffff8880b5a9fd40 EFLAGS: 00000286 ORIG_RAX: ffffffffffffff13
RAX: 1ffffffff13e305c RBX: dffffc0000000000 RCX: 0000000000000000
RDX: dffffc0000000000 RSI: 0000000000000001 RDI: ffff8880b5a86c44
RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff89f182d0
R13: 1ffff11016b53fb2 R14: 0000000000000000 R15: 0000000000000000
arch_safe_halt arch/x86/include/asm/paravirt.h:94 [inline]
default_idle+0x49/0x310 arch/x86/kernel/process.c:557
cpuidle_idle_call kernel/sched/idle.c:153 [inline]
do_idle+0x2ec/0x4b0 kernel/sched/idle.c:263
cpu_startup_entry+0xc5/0xe0 kernel/sched/idle.c:369
start_secondary+0x435/0x5c0 arch/x86/kernel/smpboot.c:271
secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243

Allocated by task 8712:
Freed by task 8306:
__cache_free mm/slab.c:3503 [inline]
kmem_cache_free+0x7f/0x260 mm/slab.c:3765
destroy_inode+0xb9/0x110 fs/inode.c:268
iput_final fs/inode.c:1555 [inline]
iput+0x4f1/0x860 fs/inode.c:1581
__sock_release net/socket.c:611 [inline]
sock_release+0x174/0x1d0 net/socket.c:619
cleanup_bearer+0x1bb/0x280 net/tipc/udp_media.c:775
process_one_work+0x864/0x1570 kernel/workqueue.c:2153
worker_thread+0x64c/0x1130 kernel/workqueue.c:2296
kthread+0x33f/0x460 kernel/kthread.c:259
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

The buggy address belongs to the object at ffff88808a56a580
which belongs to the cache sock_inode_cache of size 992
The buggy address is located 32 bytes inside of
992-byte region [ffff88808a56a580, ffff88808a56a960)
The buggy address belongs to the page:
page:ffffea0002295a80 count:1 mapcount:0 mapping:ffff88823b33a6c0 index:0xffff88808a56affd
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea0002295948 ffffea0002295ac8 ffff88823b33a6c0
raw: ffff88808a56affd ffff88808a56a100 0000000100000003 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88808a56a480: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff88808a56a500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88808a56a580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88808a56a600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88808a56a680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess):
0: 48 89 df mov %rbx,%rdi
3: e8 d4 59 7f f9 callq 0xf97f59dc
8: e9 2e ff ff ff jmpq 0xffffff3b
d: 48 89 df mov %rbx,%rdi
10: e8 c7 59 7f f9 callq 0xf97f59dc
15: eb 82 jmp 0xffffff99
17: 90 nop
18: 90 nop
19: 90 nop
1a: 90 nop
1b: 90 nop
1c: e9 07 00 00 00 jmpq 0x28
21: 0f 00 2d b4 77 4e 00 verw 0x4e77b4(%rip) # 0x4e77dc
28: fb sti
29: f4 hlt
2a: c3 retq <-- trapping instruction
2b: 90 nop
2c: e9 07 00 00 00 jmpq 0x38
31: 0f 00 2d a4 77 4e 00 verw 0x4e77a4(%rip) # 0x4e77dc
38: f4 hlt
39: c3 retq
3a: 90 nop
3b: 90 nop
3c: 41 56 push %r14
3e: 41 55 push %r13

Reply all
Reply to author
Forward
0 new messages