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

From: syzbot
Date: Thu Feb 21 2019 - 09:47:12 EST


Hello,

syzbot found the following crash on:

HEAD commit: b71acb0e3721 Merge branch 'linus' of git://git.kernel.org/..
git tree: net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=1672a39b400000
kernel config: https://syzkaller.appspot.com/x/.config?x=b03c5892bb940c76
dashboard link: https://syzkaller.appspot.com/bug?extid=ec03ae3a032901d10434
compiler: gcc (GCC) 9.0.0 20181231 (experimental)

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

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+ec03ae3a032901d10434@xxxxxxxxxxxxxxxxxxxxxxxxx

kernel msg: ebtables bug: please report to author: EBT_ENTRY_OR_ENTRIES shouldn't be set in distinguisher
==================================================================
BUG: KASAN: slab-out-of-bounds in atomic_read include/asm-generic/atomic-instrumented.h:21 [inline]
BUG: KASAN: slab-out-of-bounds in atomic_fetch_add_unless include/linux/atomic.h:575 [inline]
BUG: KASAN: slab-out-of-bounds in atomic_add_unless include/linux/atomic.h:597 [inline]
BUG: KASAN: slab-out-of-bounds in dst_hold_safe include/net/dst.h:308 [inline]
BUG: KASAN: slab-out-of-bounds in ip6_hold_safe+0xca/0x620 net/ipv6/route.c:1021
Read of size 4 at addr ffff88806b399ccc by task ksoftirqd/1/16

CPU: 1 PID: 16 Comm: ksoftirqd/1 Not tainted 4.20.0+ #3
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+0x1db/0x2d0 lib/dump_stack.c:113
print_address_description.cold+0x7c/0x20d mm/kasan/report.c:256
kasan_report_error mm/kasan/report.c:354 [inline]
kasan_report mm/kasan/report.c:412 [inline]
kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:396
check_memory_region_inline mm/kasan/kasan.c:260 [inline]
check_memory_region+0x123/0x190 mm/kasan/kasan.c:267
kasan_check_read+0x11/0x20 mm/kasan/kasan.c:272
atomic_read include/asm-generic/atomic-instrumented.h:21 [inline]
atomic_fetch_add_unless include/linux/atomic.h:575 [inline]
atomic_add_unless include/linux/atomic.h:597 [inline]
dst_hold_safe include/net/dst.h:308 [inline]
ip6_hold_safe+0xca/0x620 net/ipv6/route.c:1021
rt6_get_pcpu_route net/ipv6/route.c:1241 [inline]
ip6_pol_route+0x3a3/0x1490 net/ipv6/route.c:1890
ip6_pol_route_input+0x65/0x80 net/ipv6/route.c:1909
fib6_rule_lookup+0x12f/0x870 net/ipv6/fib6_rules.c:118
ip6_route_input_lookup+0xb7/0xd0 net/ipv6/route.c:1921
ip6_route_input+0x79b/0xe00 net/ipv6/route.c:2056
ip6_rcv_finish_core.isra.0+0x204/0x720 net/ipv6/ip6_input.c:63
ip6_rcv_finish+0x109/0x330 net/ipv6/ip6_input.c:74
NF_HOOK include/linux/netfilter.h:289 [inline]
NF_HOOK include/linux/netfilter.h:283 [inline]
ipv6_rcv+0x113/0x650 net/ipv6/ip6_input.c:272
__netif_receive_skb_one_core+0x160/0x210 net/core/dev.c:4973
__netif_receive_skb+0x2c/0x1c0 net/core/dev.c:5083
process_backlog+0x206/0x750 net/core/dev.c:5923
napi_poll net/core/dev.c:6346 [inline]
net_rx_action+0x76d/0x1930 net/core/dev.c:6412
__do_softirq+0x30b/0xb11 kernel/softirq.c:292
run_ksoftirqd kernel/softirq.c:654 [inline]
run_ksoftirqd+0x8e/0x110 kernel/softirq.c:646
smpboot_thread_fn+0x6ab/0xa10 kernel/smpboot.c:164
kthread+0x357/0x430 kernel/kthread.c:246
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352

Allocated by task 3862:
save_stack+0x45/0xd0 mm/kasan/kasan.c:448
set_track mm/kasan/kasan.c:460 [inline]
kasan_kmalloc mm/kasan/kasan.c:553 [inline]
kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:531
kasan_slab_alloc+0xf/0x20 mm/kasan/kasan.c:490
kmem_cache_alloc+0x12e/0x700 mm/slab.c:3554
getname_flags fs/namei.c:140 [inline]
getname_flags+0xd6/0x5b0 fs/namei.c:129
user_path_at_empty+0x2f/0x50 fs/namei.c:2608
do_readlinkat+0x141/0x400 fs/stat.c:397
__do_sys_readlink fs/stat.c:430 [inline]
__se_sys_readlink fs/stat.c:427 [inline]
__x64_sys_readlink+0x78/0xb0 fs/stat.c:427
do_syscall_64+0x1a3/0x800 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 3862:
save_stack+0x45/0xd0 mm/kasan/kasan.c:448
set_track mm/kasan/kasan.c:460 [inline]
__kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
__cache_free mm/slab.c:3498 [inline]
kmem_cache_free+0x86/0x260 mm/slab.c:3760
putname+0xef/0x130 fs/namei.c:261
filename_lookup+0x359/0x530 fs/namei.c:2357
user_path_at_empty+0x43/0x50 fs/namei.c:2608
do_readlinkat+0x141/0x400 fs/stat.c:397
__do_sys_readlink fs/stat.c:430 [inline]
__se_sys_readlink fs/stat.c:427 [inline]
__x64_sys_readlink+0x78/0xb0 fs/stat.c:427
do_syscall_64+0x1a3/0x800 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88806b398440
which belongs to the cache names_cache of size 4096
The buggy address is located 2188 bytes to the right of
4096-byte region [ffff88806b398440, ffff88806b399440)
The buggy address belongs to the page:
page:ffffea0001ace600 count:1 mapcount:0 mapping:ffff88812c2bec40 index:0x0 compound_mapcount: 0
flags: 0x1fffc0000010200(slab|head)
raw: 01fffc0000010200 ffffea0002310008 ffffea0002a06988 ffff88812c2bec40
raw: 0000000000000000 ffff88806b398440 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88806b399b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88806b399c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88806b399c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
^
ffff88806b399d00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88806b399d80: 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 syzkaller@xxxxxxxxxxxxxxxxx

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