Subject: KASAN: slab-out-of-bounds Read in hsr_debugfs_rename

From: syzbot <[email-masked]>
Date: Fri, 27 Dec 2019 18:25:09 -0800

Hello,

syzbot found the following crash on:

HEAD commit:    3c2f450e Merge git://git.kernel.org/pub/scm/linux/kernel/g..
git tree:       bpf
console output: https://syzkaller.appspot.com/x/log.txt?x=15853866e00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=7f6119e2e3675a73
dashboard link: https://syzkaller.appspot.com/bug?extid=9328206518f08318a5fd
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=106d4751e00000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1775a49ee00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: [email-masked]

8021q: adding VLAN 0 to HW filter on device batadv0
@: renamed from hsr_slave_0
==================================================================
BUG: KASAN: slab-out-of-bounds in hsr_debugfs_rename+0xa8/0xc0  
net/hsr/hsr_debugfs.c:73
Read of size 8 at addr ffff88809f7f4cd8 by task syz-executor679/9217

CPU: 1 PID: 9217 Comm: syz-executor679 Not tainted 5.5.0-rc2-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+0x197/0x210 lib/dump_stack.c:118
  print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
  __kasan_report.cold+0x1b/0x41 mm/kasan/report.c:506
  kasan_report+0x12/0x20 mm/kasan/common.c:639
  __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135
  hsr_debugfs_rename+0xa8/0xc0 net/hsr/hsr_debugfs.c:73
  hsr_netdev_notify+0x6c8/0xa00 net/hsr/hsr_main.c:49
  notifier_call_chain+0xc2/0x230 kernel/notifier.c:83
  __raw_notifier_call_chain kernel/notifier.c:361 [inline]
  raw_notifier_call_chain+0x2e/0x40 kernel/notifier.c:368
  call_netdevice_notifiers_info net/core/dev.c:1893 [inline]
  call_netdevice_notifiers_info+0xba/0x130 net/core/dev.c:1878
  call_netdevice_notifiers_extack net/core/dev.c:1905 [inline]
  call_netdevice_notifiers net/core/dev.c:1919 [inline]
  dev_change_name+0x504/0x930 net/core/dev.c:1270
  do_setlink+0x2d28/0x3720 net/core/rtnetlink.c:2571
  __rtnl_newlink+0xbf0/0x1790 net/core/rtnetlink.c:3238
  rtnl_newlink+0x69/0xa0 net/core/rtnetlink.c:3363
  rtnetlink_rcv_msg+0x45e/0xaf0 net/core/rtnetlink.c:5424
  netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477
  rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:5442
  netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
  netlink_unicast+0x58c/0x7d0 net/netlink/af_netlink.c:1328
  netlink_sendmsg+0x91c/0xea0 net/netlink/af_netlink.c:1917
  sock_sendmsg_nosec net/socket.c:639 [inline]
  sock_sendmsg+0xd7/0x130 net/socket.c:659
  ____sys_sendmsg+0x753/0x880 net/socket.c:2330
  ___sys_sendmsg+0x100/0x170 net/socket.c:2384
  __sys_sendmsg+0x105/0x1d0 net/socket.c:2417
  __do_sys_sendmsg net/socket.c:2426 [inline]
  __se_sys_sendmsg net/socket.c:2424 [inline]
  __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2424
  do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
  entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4425d9
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 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 0f 83 6b 0e fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffd616ed1b8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00000000004425d9
RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000004
RBP: 0000000000000003 R08: 00000000bb1414ac R09: 00000000bb1414ac
R10: 00000000bb1414ac R11: 0000000000000246 R12: 0000000000000004
R13: 0000000000403960 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 9217:
  save_stack+0x23/0x90 mm/kasan/common.c:72
  set_track mm/kasan/common.c:80 [inline]
  __kasan_kmalloc mm/kasan/common.c:513 [inline]
  __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:486
  kasan_kmalloc+0x9/0x10 mm/kasan/common.c:527
  __do_kmalloc_node mm/slab.c:3616 [inline]
  __kmalloc_node+0x4e/0x70 mm/slab.c:3623
  kmalloc_node include/linux/slab.h:579 [inline]
  kvmalloc_node+0x68/0x100 mm/util.c:574
  kvmalloc include/linux/mm.h:655 [inline]
  kvzalloc include/linux/mm.h:663 [inline]
  alloc_netdev_mqs+0x98/0xde0 net/core/dev.c:9731
  rtnl_create_link+0x22d/0xab0 net/core/rtnetlink.c:3042
  __rtnl_newlink+0xfa0/0x1790 net/core/rtnetlink.c:3295
  rtnl_newlink+0x69/0xa0 net/core/rtnetlink.c:3363
  rtnetlink_rcv_msg+0x45e/0xaf0 net/core/rtnetlink.c:5424
  netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477
  rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:5442
  netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
  netlink_unicast+0x58c/0x7d0 net/netlink/af_netlink.c:1328
  netlink_sendmsg+0x91c/0xea0 net/netlink/af_netlink.c:1917
  sock_sendmsg_nosec net/socket.c:639 [inline]
  sock_sendmsg+0xd7/0x130 net/socket.c:659
  __sys_sendto+0x262/0x380 net/socket.c:1985
  __do_sys_sendto net/socket.c:1997 [inline]
  __se_sys_sendto net/socket.c:1993 [inline]
  __x64_sys_sendto+0xe1/0x1a0 net/socket.c:1993
  do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
  entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 0:
(stack is not available)

The buggy address belongs to the object at ffff88809f7f4000
  which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 3288 bytes inside of
  4096-byte region [ffff88809f7f4000, ffff88809f7f5000)
The buggy address belongs to the page:
page:ffffea00027dfd00 refcount:1 mapcount:0 mapping:ffff8880aa402000  
index:0x0 compound_mapcount: 0
raw: 00fffe0000010200 ffffea00028eb488 ffffea0002387b08 ffff8880aa402000
raw: 0000000000000000 ffff88809f7f4000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
  ffff88809f7f4b80: 00 00 00 00 00 00 00 00 07 fc fc fc fc fc fc fc
  ffff88809f7f4c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ffff88809f7f4c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                                                     ^
  ffff88809f7f4d00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
  ffff88809f7f4d80: 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 [email-masked].

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