KASAN: slab-out-of-bounds Read in tun_net_xmit

22 views
Skip to first unread message

syzbot

unread,
Apr 10, 2019, 12:04:11 PM4/10/19
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 7d2d5fc1 Merge 4.14.91 into android-4.14
git tree: android-4.14
console output: https://syzkaller.appspot.com/x/log.txt?x=1207f757400000
kernel config: https://syzkaller.appspot.com/x/.config?x=c184a4faf24e0c0c
dashboard link: https://syzkaller.appspot.com/bug?extid=159d91b9d655a16c32cb
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=131ed1fd400000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13390fdd400000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+159d91...@syzkaller.appspotmail.com

urandom_read: 1 callbacks suppressed
random: sshd: uninitialized urandom read (32 bytes read)
audit: type=1400 audit(1546193831.052:8): avc: denied { map } for
pid=1783 comm="syz-executor910" path="/root/syz-executor910660043"
dev="sda1" ino=16482 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
==================================================================
BUG: KASAN: slab-out-of-bounds in __ptr_ring_produce
include/linux/ptr_ring.h:109 [inline]
BUG: KASAN: slab-out-of-bounds in ptr_ring_produce
include/linux/ptr_ring.h:132 [inline]
BUG: KASAN: slab-out-of-bounds in skb_array_produce
include/linux/skb_array.h:48 [inline]
BUG: KASAN: slab-out-of-bounds in tun_net_xmit+0xf18/0x1010
drivers/net/tun.c:916
Read of size 8 at addr ffff8881c6efa650 by task syz-executor910/1786

CPU: 1 PID: 1786 Comm: syz-executor910 Not tainted 4.14.91+ #30
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0xb9/0x11b lib/dump_stack.c:53
print_address_description+0x60/0x22b mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report.cold.6+0x11b/0x2dd mm/kasan/report.c:409
__ptr_ring_produce include/linux/ptr_ring.h:109 [inline]
ptr_ring_produce include/linux/ptr_ring.h:132 [inline]
skb_array_produce include/linux/skb_array.h:48 [inline]
tun_net_xmit+0xf18/0x1010 drivers/net/tun.c:916
__netdev_start_xmit include/linux/netdevice.h:4030 [inline]
netdev_start_xmit include/linux/netdevice.h:4039 [inline]
xmit_one net/core/dev.c:3009 [inline]
dev_hard_start_xmit+0x191/0x890 net/core/dev.c:3025
sch_direct_xmit+0x280/0x520 net/sched/sch_generic.c:186
__dev_xmit_skb net/core/dev.c:3218 [inline]
__dev_queue_xmit+0x16fd/0x1f40 net/core/dev.c:3493
neigh_hh_output include/net/neighbour.h:490 [inline]
neigh_output include/net/neighbour.h:498 [inline]
ip6_finish_output2+0x1136/0x1f90 net/ipv6/ip6_output.c:120
ip6_finish_output+0x62e/0xb10 net/ipv6/ip6_output.c:154
NF_HOOK_COND include/linux/netfilter.h:239 [inline]
ip6_output+0x1dd/0x680 net/ipv6/ip6_output.c:171
dst_output include/net/dst.h:459 [inline]
ip6_local_out+0x94/0x170 net/ipv6/output_core.c:176
ip6_send_skb+0x98/0x2e0 net/ipv6/ip6_output.c:1686
udp_v6_send_skb+0x4e3/0xe70 net/ipv6/udp.c:1081
udpv6_sendmsg+0x1f07/0x2510 net/ipv6/udp.c:1353
inet_sendmsg+0x168/0x540 net/ipv4/af_inet.c:781
sock_sendmsg_nosec net/socket.c:645 [inline]
sock_sendmsg+0xb5/0x100 net/socket.c:655
SYSC_sendto net/socket.c:1762 [inline]
SyS_sendto+0x211/0x340 net/socket.c:1730
do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x441ba9
RSP: 002b:00007ffeef0893f8 EFLAGS: 00000212 ORIG_RAX: 000000000000002c
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000441ba9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 0000000000008470 R08: 00000000200001c0 R09: 000000000000001c
R10: 0000000000000000 R11: 0000000000000212 R12: 0000000000000000
R13: 0000000000402990 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 1785:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc.part.1+0x4f/0xd0 mm/kasan/kasan.c:551
__kmalloc+0x153/0x340 mm/slub.c:3760
__kmalloc_node include/linux/slab.h:356 [inline]
kmalloc_node include/linux/slab.h:530 [inline]
kvmalloc_node+0x42/0xd0 mm/util.c:397
kvmalloc include/linux/mm.h:531 [inline]
kvmalloc_array include/linux/mm.h:547 [inline]
__ptr_ring_init_queue_alloc include/linux/ptr_ring.h:455 [inline]
ptr_ring_resize_multiple include/linux/ptr_ring.h:613 [inline]
skb_array_resize_multiple include/linux/skb_array.h:200 [inline]
tun_queue_resize drivers/net/tun.c:2815 [inline]
tun_device_event+0x450/0xc50 drivers/net/tun.c:2833
notifier_call_chain+0x114/0x1b0 kernel/notifier.c:93
call_netdevice_notifiers+0x6e/0xa0 net/core/dev.c:1687
dev_ifsioc+0x735/0x840 net/core/dev_ioctl.c:311
dev_ioctl+0x25f/0xce0 net/core/dev_ioctl.c:566
sock_do_ioctl+0x92/0xb0 net/socket.c:980
sock_ioctl+0x263/0x430 net/socket.c:1070
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:500 [inline]
do_vfs_ioctl+0x1a0/0x1030 fs/ioctl.c:684
SYSC_ioctl fs/ioctl.c:701 [inline]
SyS_ioctl+0x7e/0xb0 fs/ioctl.c:692
do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 0:
(stack is not available)

The buggy address belongs to the object at ffff8881c6efa648
which belongs to the cache kmalloc-8 of size 8
The buggy address is located 0 bytes to the right of
8-byte region [ffff8881c6efa648, ffff8881c6efa650)
The buggy address belongs to the page:
page:ffffea00071bbe80 count:1 mapcount:0 mapping: (null) index:0x0
flags: 0x4000000000000100(slab)
raw: 4000000000000100 0000000000000000 0000000000000000 0000000180aa00aa
raw: dead000000000100 dead000000000200 ffff8881da803c00 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8881c6efa500: fc fc fb fc fc fb fc fc fb fc fc fb fc fc fb fc
ffff8881c6efa580: fc fb fc fc fb fc fc fb fc fc fb fc fc 00 fc fc
> ffff8881c6efa600: 00 fc fc fb fc fc fb fc fc 00 fc fc fc fc fc fc
^
ffff8881c6efa680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8881c6efa700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================


---
This bug 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 bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Apr 14, 2019, 5:28:15 AM4/14/19
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 63a812bb ANDROID: x86_64_cuttlefish_defconfig: Disable KPTI
git tree: android-4.9
console output: https://syzkaller.appspot.com/x/log.txt?x=13499e57800000
kernel config: https://syzkaller.appspot.com/x/.config?x=499a13c4e119010c
dashboard link: https://syzkaller.appspot.com/bug?extid=90fe1fb263d3c28f8ad7
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=100d2e57800000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+90fe1f...@syzkaller.appspotmail.com

IPVS: Creating netns size=2536 id=2
IPVS: Creating netns size=2536 id=3
IPVS: Creating netns size=2536 id=4
IPVS: Creating netns size=2536 id=5
==================================================================
BUG: KASAN: slab-out-of-bounds in __ptr_ring_produce
include/linux/ptr_ring.h:107 [inline]
BUG: KASAN: slab-out-of-bounds in ptr_ring_produce
include/linux/ptr_ring.h:130 [inline]
BUG: KASAN: slab-out-of-bounds in skb_array_produce
include/linux/skb_array.h:48 [inline]
BUG: KASAN: slab-out-of-bounds in tun_net_xmit+0x10bd/0x1180
drivers/net/tun.c:920
Read of size 8 at addr ffff8801cb159b78 by task swapper/1/0

CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.9.98-g63a812b #20
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
ffff8801db3073e8 ffffffff81eb0e89 ffffea00072c5640 ffff8801cb159b78
0000000000000000 ffff8801cb159b78 ffff8801d97ab848 ffff8801db307420
ffffffff815652cb ffff8801cb159b78 0000000000000008 0000000000000000
Call Trace:
<IRQ> [ 23.911932] [<ffffffff81eb0e89>] __dump_stack
lib/dump_stack.c:15 [inline]
<IRQ> [ 23.911932] [<ffffffff81eb0e89>] dump_stack+0xc1/0x128
lib/dump_stack.c:51
[<ffffffff815652cb>] print_address_description+0x6c/0x234
mm/kasan/report.c:256
[<ffffffff815656d5>] kasan_report_error mm/kasan/report.c:355 [inline]
[<ffffffff815656d5>] kasan_report.cold.6+0x242/0x2fe mm/kasan/report.c:412
[<ffffffff81539354>] __asan_report_load8_noabort+0x14/0x20
mm/kasan/report.c:433
[<ffffffff82814a4d>] __ptr_ring_produce include/linux/ptr_ring.h:107
[inline]
[<ffffffff82814a4d>] ptr_ring_produce include/linux/ptr_ring.h:130 [inline]
[<ffffffff82814a4d>] skb_array_produce include/linux/skb_array.h:48
[inline]
[<ffffffff82814a4d>] tun_net_xmit+0x10bd/0x1180 drivers/net/tun.c:920
[<ffffffff830858b7>] __netdev_start_xmit include/linux/netdevice.h:4062
[inline]
[<ffffffff830858b7>] netdev_start_xmit include/linux/netdevice.h:4071
[inline]
[<ffffffff830858b7>] xmit_one net/core/dev.c:2955 [inline]
[<ffffffff830858b7>] dev_hard_start_xmit+0x197/0x8b0 net/core/dev.c:2971
[<ffffffff8311e64c>] sch_direct_xmit+0x2bc/0x590
net/sched/sch_generic.c:182
[<ffffffff830879d2>] __dev_xmit_skb net/core/dev.c:3151 [inline]
[<ffffffff830879d2>] __dev_queue_xmit+0x1742/0x2080 net/core/dev.c:3419
[<ffffffff83088327>] dev_queue_xmit+0x17/0x20 net/core/dev.c:3484
[<ffffffff8309ca55>] neigh_direct_output+0x15/0x20
net/core/neighbour.c:1362
[<ffffffff83552c18>] dst_neigh_output include/net/dst.h:470 [inline]
[<ffffffff83552c18>] ip6_finish_output2+0x8a8/0x1d00
net/ipv6/ip6_output.c:119
[<ffffffff8355c3f8>] ip6_finish_output+0x3b8/0x760
net/ipv6/ip6_output.c:145
[<ffffffff8355c993>] NF_HOOK_COND include/linux/netfilter.h:246 [inline]
[<ffffffff8355c993>] ip6_output+0x1f3/0x6e0 net/ipv6/ip6_output.c:162
[<ffffffff835dda36>] dst_output include/net/dst.h:507 [inline]
[<ffffffff835dda36>] NF_HOOK_THRESH.constprop.41+0x286/0x450
include/linux/netfilter.h:232
[<ffffffff835de249>] NF_HOOK include/linux/netfilter.h:255 [inline]
[<ffffffff835de249>] mld_sendpack+0x649/0xbd0 net/ipv6/mcast.c:1660
[<ffffffff835dff7a>] mld_send_cr net/ipv6/mcast.c:1956 [inline]
[<ffffffff835dff7a>] mld_ifc_timer_expire+0x3ba/0x740 net/ipv6/mcast.c:2454
[<ffffffff812969d3>] call_timer_fn+0x163/0x6e0 kernel/time/timer.c:1319
[<ffffffff8129db37>] expire_timers kernel/time/timer.c:1359 [inline]
[<ffffffff8129db37>] __run_timers kernel/time/timer.c:1658 [inline]
[<ffffffff8129db37>] run_timer_softirq+0x1047/0x1590
kernel/time/timer.c:1684
[<ffffffff839fb23b>] __do_softirq+0x20b/0x937 kernel/softirq.c:284
[<ffffffff81149037>] invoke_softirq kernel/softirq.c:364 [inline]
[<ffffffff81149037>] irq_exit+0x147/0x190 kernel/softirq.c:405
[<ffffffff839f9e21>] exiting_irq arch/x86/include/asm/apic.h:659 [inline]
[<ffffffff839f9e21>] smp_apic_timer_interrupt+0x81/0xa0
arch/x86/kernel/apic/apic.c:960
[<ffffffff839f5fb0>] apic_timer_interrupt+0xa0/0xb0
arch/x86/entry/entry_64.S:648
<EOI> [ 24.295915] [<ffffffff839f3286>] ? native_safe_halt+0x6/0x10
arch/x86/include/asm/irqflags.h:53
[<ffffffff839f28c5>] arch_safe_halt arch/x86/include/asm/paravirt.h:104
[inline]
[<ffffffff839f28c5>] default_idle+0x55/0x360 arch/x86/kernel/process.c:295
[<ffffffff81069fa0>] arch_cpu_idle+0x10/0x20 arch/x86/kernel/process.c:286
[<ffffffff839f36e5>] default_idle_call+0x45/0x60 kernel/sched/idle.c:97
[<ffffffff81220e65>] cpuidle_idle_call kernel/sched/idle.c:155 [inline]
[<ffffffff81220e65>] cpu_idle_loop kernel/sched/idle.c:248 [inline]
[<ffffffff81220e65>] cpu_startup_entry+0x2b5/0x380 kernel/sched/idle.c:303
[<ffffffff810ad1f3>] start_secondary+0x323/0x400
arch/x86/kernel/smpboot.c:254

Allocated by task 3845:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
save_stack+0x43/0xd0 mm/kasan/kasan.c:505
set_track mm/kasan/kasan.c:517 [inline]
kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:609
__kmalloc+0x11d/0x300 mm/slub.c:3741
kmalloc_array include/linux/slab.h:582 [inline]
kcalloc include/linux/slab.h:593 [inline]
__ptr_ring_init_queue_alloc include/linux/ptr_ring.h:356 [inline]
ptr_ring_resize_multiple include/linux/ptr_ring.h:445 [inline]
skb_array_resize_multiple include/linux/skb_array.h:169 [inline]
tun_queue_resize drivers/net/tun.c:2521 [inline]
tun_device_event+0x3e3/0xa10 drivers/net/tun.c:2539
notifier_call_chain+0xb4/0x1d0 kernel/notifier.c:93
__raw_notifier_call_chain kernel/notifier.c:394 [inline]
raw_notifier_call_chain+0x2d/0x40 kernel/notifier.c:401
call_netdevice_notifiers_info+0x55/0x70 net/core/dev.c:1647
call_netdevice_notifiers+0x70/0xa0 net/core/dev.c:1663
do_setlink+0xc3b/0x30d0 net/core/rtnetlink.c:2048
rtnl_group_changelink net/core/rtnetlink.c:2414 [inline]
rtnl_newlink+0xbd0/0x1550 net/core/rtnetlink.c:2562
rtnetlink_rcv_msg+0x49c/0x650 net/core/rtnetlink.c:4059
netlink_rcv_skb+0x145/0x370 net/netlink/af_netlink.c:2356
rtnetlink_rcv+0x2a/0x40 net/core/rtnetlink.c:4065
netlink_unicast_kernel net/netlink/af_netlink.c:1278 [inline]
netlink_unicast+0x4d8/0x6f0 net/netlink/af_netlink.c:1304
netlink_sendmsg+0x78b/0xc10 net/netlink/af_netlink.c:1850
sock_sendmsg_nosec net/socket.c:635 [inline]
sock_sendmsg+0xcc/0x110 net/socket.c:645
___sys_sendmsg+0x6fc/0x840 net/socket.c:1969
__sys_sendmsg+0xd9/0x190 net/socket.c:2003
SYSC_sendmsg net/socket.c:2014 [inline]
SyS_sendmsg+0x2d/0x50 net/socket.c:2010
do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Freed by task 2070:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
save_stack+0x43/0xd0 mm/kasan/kasan.c:505
set_track mm/kasan/kasan.c:517 [inline]
kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:582
slab_free_hook mm/slub.c:1355 [inline]
slab_free_freelist_hook mm/slub.c:1377 [inline]
slab_free mm/slub.c:2958 [inline]
kfree+0xfb/0x310 mm/slub.c:3878
kernfs_fop_write+0x181/0x460 fs/kernfs/file.c:330
__vfs_write+0x115/0x580 fs/read_write.c:507
vfs_write+0x187/0x530 fs/read_write.c:557
SYSC_write fs/read_write.c:604 [inline]
SyS_write+0xd9/0x1c0 fs/read_write.c:596
do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
entry_SYSCALL_64_after_swapgs+0x5d/0xdb

The buggy address belongs to the object at ffff8801cb159b70
which belongs to the cache kmalloc-8 of size 8
The buggy address is located 0 bytes to the right of
8-byte region [ffff8801cb159b70, ffff8801cb159b78)
The buggy address belongs to the page:
page:ffffea00072c5640 count:1 mapcount:0 mapping: (null) index:0x0
flags: 0x8000000000000080(slab)
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801cb159a00: fc 00 fc fc 00 fc fc 00 fc fc 00 fc fc 00 fc fc
ffff8801cb159a80: 00 fc fc 00 fc fc 00 fc fc fb fc fc fb fc fc 00
> ffff8801cb159b00: fc fc 00 fc fc 00 fc fc 00 fc fc 00 fc fc 00 fc
^
ffff8801cb159b80: fc fb fc fc fb fc fc 00 fc fc 00 fc fc 00 fc fc
ffff8801cb159c00: 00 fc fc 00 fc fc 00 fc fc 00 fc fc 04 fc fc fb
Reply all
Reply to author
Forward
0 new messages