linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* KASAN: use-after-free Read in macvlan_dev_get_iflink
@ 2020-06-28  2:47 syzbot
  2020-07-23 17:06 ` syzbot
  2020-07-23 20:08 ` Cong Wang
  0 siblings, 2 replies; 4+ messages in thread
From: syzbot @ 2020-06-28  2:47 UTC (permalink / raw)
  To: davem, kuba, linux-kernel, netdev, syzkaller-bugs

Hello,

syzbot found the following crash on:

HEAD commit:    1590a2e1 Merge tag 'acpi-5.8-rc3' of git://git.kernel.org/..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1070059b100000
kernel config:  https://syzkaller.appspot.com/x/.config?x=20c907630cbdbe5
dashboard link: https://syzkaller.appspot.com/bug?extid=95eec132c4bd9b1d8430
compiler:       clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1559e6e5100000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16aadd29100000

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

==================================================================
BUG: KASAN: use-after-free in macvlan_dev_get_iflink+0x6a/0x70 drivers/net/macvlan.c:1137
Read of size 4 at addr ffff88808b62a100 by task syz-executor984/7033

CPU: 0 PID: 7033 Comm: syz-executor984 Not tainted 5.8.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+0x1f0/0x31e lib/dump_stack.c:118
 print_address_description+0x66/0x5a0 mm/kasan/report.c:383
 __kasan_report mm/kasan/report.c:513 [inline]
 kasan_report+0x132/0x1d0 mm/kasan/report.c:530
 macvlan_dev_get_iflink+0x6a/0x70 drivers/net/macvlan.c:1137
 default_operstate net/core/link_watch.c:41 [inline]
 rfc2863_policy+0x11f/0x2a0 net/core/link_watch.c:53
 linkwatch_do_dev+0x3a/0x160 net/core/link_watch.c:160
 netdev_wait_allrefs net/core/dev.c:9678 [inline]
 netdev_run_todo+0x2c8/0xc90 net/core/dev.c:9774
 rtnl_unlock net/core/rtnetlink.c:112 [inline]
 rtnetlink_rcv_msg+0x890/0xd40 net/core/rtnetlink.c:5461
 netlink_rcv_skb+0x190/0x3a0 net/netlink/af_netlink.c:2469
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x786/0x940 net/netlink/af_netlink.c:1329
 netlink_sendmsg+0xa57/0xd70 net/netlink/af_netlink.c:1918
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg net/socket.c:672 [inline]
 ____sys_sendmsg+0x519/0x800 net/socket.c:2352
 ___sys_sendmsg net/socket.c:2406 [inline]
 __sys_sendmsg+0x2b1/0x360 net/socket.c:2439
 do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:359
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x446e69
Code: Bad RIP value.
RSP: 002b:00007f7fa3a46d98 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00000000006dbc98 RCX: 0000000000446e69
RDX: 0000000000000000 RSI: 0000000020000080 RDI: 0000000000000006
RBP: 00000000006dbc90 R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000000a R11: 0000000000000246 R12: 00000000006dbc9c
R13: 0000000000000000 R14: 0000000000000000 R15: 0705001000000048

Allocated by task 7001:
 save_stack mm/kasan/common.c:48 [inline]
 set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc+0x103/0x140 mm/kasan/common.c:494
 kmalloc_node include/linux/slab.h:578 [inline]
 kvmalloc_node+0x81/0x110 mm/util.c:574
 kvmalloc include/linux/mm.h:753 [inline]
 kvzalloc include/linux/mm.h:761 [inline]
 alloc_netdev_mqs+0x86/0xf90 net/core/dev.c:9938
 rtnl_create_link+0x242/0x9c0 net/core/rtnetlink.c:3067
 __rtnl_newlink net/core/rtnetlink.c:3329 [inline]
 rtnl_newlink+0x12a2/0x1bf0 net/core/rtnetlink.c:3397
 rtnetlink_rcv_msg+0x889/0xd40 net/core/rtnetlink.c:5460
 netlink_rcv_skb+0x190/0x3a0 net/netlink/af_netlink.c:2469
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x786/0x940 net/netlink/af_netlink.c:1329
 netlink_sendmsg+0xa57/0xd70 net/netlink/af_netlink.c:1918
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg net/socket.c:672 [inline]
 ____sys_sendmsg+0x519/0x800 net/socket.c:2352
 ___sys_sendmsg net/socket.c:2406 [inline]
 __sys_sendmsg+0x2b1/0x360 net/socket.c:2439
 do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:359
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 7001:
 save_stack mm/kasan/common.c:48 [inline]
 set_track mm/kasan/common.c:56 [inline]
 kasan_set_free_info mm/kasan/common.c:316 [inline]
 __kasan_slab_free+0x114/0x170 mm/kasan/common.c:455
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x10a/0x220 mm/slab.c:3757
 device_release+0x70/0x1a0 drivers/base/core.c:1555
 kobject_cleanup lib/kobject.c:693 [inline]
 kobject_release lib/kobject.c:722 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x15b/0x220 lib/kobject.c:739
 netdev_run_todo+0xb17/0xc90 net/core/dev.c:9797
 rtnl_unlock net/core/rtnetlink.c:112 [inline]
 rtnetlink_rcv_msg+0x890/0xd40 net/core/rtnetlink.c:5461
 netlink_rcv_skb+0x190/0x3a0 net/netlink/af_netlink.c:2469
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x786/0x940 net/netlink/af_netlink.c:1329
 netlink_sendmsg+0xa57/0xd70 net/netlink/af_netlink.c:1918
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg net/socket.c:672 [inline]
 ____sys_sendmsg+0x519/0x800 net/socket.c:2352
 ___sys_sendmsg net/socket.c:2406 [inline]
 __sys_sendmsg+0x2b1/0x360 net/socket.c:2439
 do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:359
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff88808b62a000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 256 bytes inside of
 4096-byte region [ffff88808b62a000, ffff88808b62b000)
The buggy address belongs to the page:
page:ffffea00022d8a80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 head:ffffea00022d8a80 order:1 compound_mapcount:0
flags: 0xfffe0000010200(slab|head)
raw: 00fffe0000010200 ffffea0002a12288 ffffea0002462c08 ffff8880aa402000
raw: 0000000000000000 ffff88808b62a000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88808b62a000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88808b62a080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88808b62a100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88808b62a180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88808b62a200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: KASAN: use-after-free Read in macvlan_dev_get_iflink
  2020-06-28  2:47 KASAN: use-after-free Read in macvlan_dev_get_iflink syzbot
@ 2020-07-23 17:06 ` syzbot
  2020-07-23 20:08 ` Cong Wang
  1 sibling, 0 replies; 4+ messages in thread
From: syzbot @ 2020-07-23 17:06 UTC (permalink / raw)
  To: andriin, ap420073, ast, bpf, daniel, davem, hawk, john.fastabend,
	kafai, kpsingh, kuba, linux-kernel, netdev, songliubraving,
	syzkaller-bugs, xiyou.wangcong, yhs

syzbot has bisected this issue to:

commit 1a33e10e4a95cb109ff1145098175df3113313ef
Author: Cong Wang <xiyou.wangcong@gmail.com>
Date:   Sun May 3 05:22:19 2020 +0000

    net: partially revert dynamic lockdep key changes

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=17663aef100000
start commit:   1590a2e1 Merge tag 'acpi-5.8-rc3' of git://git.kernel.org/..
git tree:       upstream
final oops:     https://syzkaller.appspot.com/x/report.txt?x=14e63aef100000
console output: https://syzkaller.appspot.com/x/log.txt?x=10e63aef100000
kernel config:  https://syzkaller.appspot.com/x/.config?x=20c907630cbdbe5
dashboard link: https://syzkaller.appspot.com/bug?extid=95eec132c4bd9b1d8430
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1559e6e5100000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16aadd29100000

Reported-by: syzbot+95eec132c4bd9b1d8430@syzkaller.appspotmail.com
Fixes: 1a33e10e4a95 ("net: partially revert dynamic lockdep key changes")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: KASAN: use-after-free Read in macvlan_dev_get_iflink
  2020-06-28  2:47 KASAN: use-after-free Read in macvlan_dev_get_iflink syzbot
  2020-07-23 17:06 ` syzbot
@ 2020-07-23 20:08 ` Cong Wang
  2020-07-23 21:20   ` syzbot
  1 sibling, 1 reply; 4+ messages in thread
From: Cong Wang @ 2020-07-23 20:08 UTC (permalink / raw)
  To: syzbot
  Cc: David Miller, Jakub Kicinski, LKML,
	Linux Kernel Network Developers, syzkaller-bugs

#syz test: https://github.com/congwang/linux.git net

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: KASAN: use-after-free Read in macvlan_dev_get_iflink
  2020-07-23 20:08 ` Cong Wang
@ 2020-07-23 21:20   ` syzbot
  0 siblings, 0 replies; 4+ messages in thread
From: syzbot @ 2020-07-23 21:20 UTC (permalink / raw)
  To: davem, kuba, linux-kernel, netdev, syzkaller-bugs, xiyou.wangcong

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in macvlan_get_link_net

general protection fault, probably for non-canonical address 0xdffffc00000000b3: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000598-0x000000000000059f]
CPU: 0 PID: 8229 Comm: syz-executor.0 Not tainted 5.8.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:read_pnet include/net/net_namespace.h:330 [inline]
RIP: 0010:dev_net include/linux/netdevice.h:2261 [inline]
RIP: 0010:macvlan_get_link_net+0x43/0x60 drivers/net/macvlan.c:1667
Code: c6 f0 0b 00 00 4c 89 f0 48 c1 e8 03 42 80 3c 38 00 74 08 4c 89 f7 e8 dc cb d6 fc bb 98 05 00 00 49 03 1e 48 89 d8 48 c1 e8 03 <42> 80 3c 38 00 74 08 48 89 df e8 be cb d6 fc 48 8b 03 5b 41 5e 41
RSP: 0018:ffffc90004e47110 EFLAGS: 00010202
RAX: 00000000000000b3 RBX: 0000000000000598 RCX: ffff88808f57c040
RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff888089dc8000
RBP: ffffc90004e47228 R08: ffffffff866c14ae R09: fffffbfff12b7531
R10: fffffbfff12b7531 R11: 0000000000000000 R12: 1ffff110113b904b
R13: ffff888089dc825f R14: ffff888089dc8bf0 R15: dffffc0000000000
FS:  00007f40720ea700(0000) GS:ffff8880ae800000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005623955cb160 CR3: 000000009dc8e000 CR4: 00000000001406f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 rtnl_fill_link_netnsid net/core/rtnetlink.c:1569 [inline]
 rtnl_fill_ifinfo+0x3355/0x4650 net/core/rtnetlink.c:1758
 rtmsg_ifinfo_build_skb+0xe2/0x180 net/core/rtnetlink.c:3706
 rollback_registered_many+0xc9b/0x14a0 net/core/dev.c:8972
 unregister_netdevice_many+0x46/0x260 net/core/dev.c:10113
 __rtnl_newlink net/core/rtnetlink.c:3381 [inline]
 rtnl_newlink+0x1876/0x1c10 net/core/rtnetlink.c:3398
 rtnetlink_rcv_msg+0x889/0xd40 net/core/rtnetlink.c:5461
 netlink_rcv_skb+0x190/0x3a0 net/netlink/af_netlink.c:2469
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x786/0x940 net/netlink/af_netlink.c:1329
 netlink_sendmsg+0xa57/0xd70 net/netlink/af_netlink.c:1918
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg net/socket.c:672 [inline]
 ____sys_sendmsg+0x519/0x800 net/socket.c:2352
 ___sys_sendmsg net/socket.c:2406 [inline]
 __sys_sendmsg+0x2b1/0x360 net/socket.c:2439
 do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:384
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x45cb99
Code: Bad RIP value.
RSP: 002b:00007f40720e9c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000502680 RCX: 000000000045cb99
RDX: 0000000000000000 RSI: 0000000020000080 RDI: 0000000000000006
RBP: 000000000078bfa0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 0000000000000a40 R14: 00000000004cd2f6 R15: 00007f40720ea6d4
Modules linked in:
---[ end trace 45c7e0a1442252cb ]---
RIP: 0010:read_pnet include/net/net_namespace.h:330 [inline]
RIP: 0010:dev_net include/linux/netdevice.h:2261 [inline]
RIP: 0010:macvlan_get_link_net+0x43/0x60 drivers/net/macvlan.c:1667
Code: c6 f0 0b 00 00 4c 89 f0 48 c1 e8 03 42 80 3c 38 00 74 08 4c 89 f7 e8 dc cb d6 fc bb 98 05 00 00 49 03 1e 48 89 d8 48 c1 e8 03 <42> 80 3c 38 00 74 08 48 89 df e8 be cb d6 fc 48 8b 03 5b 41 5e 41
RSP: 0018:ffffc90004e47110 EFLAGS: 00010202
RAX: 00000000000000b3 RBX: 0000000000000598 RCX: ffff88808f57c040
RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff888089dc8000
RBP: ffffc90004e47228 R08: ffffffff866c14ae R09: fffffbfff12b7531
R10: fffffbfff12b7531 R11: 0000000000000000 R12: 1ffff110113b904b
R13: ffff888089dc825f R14: ffff888089dc8bf0 R15: dffffc0000000000
FS:  00007f40720ea700(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005623955cb160 CR3: 000000009dc8e000 CR4: 00000000001406e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


Tested on:

commit:         9506a941 net: fix a race condition in dev_get_iflink()
git tree:       https://github.com/congwang/linux.git net
console output: https://syzkaller.appspot.com/x/log.txt?x=1569d430900000
kernel config:  https://syzkaller.appspot.com/x/.config?x=b1a5a263f7a540cb
dashboard link: https://syzkaller.appspot.com/bug?extid=95eec132c4bd9b1d8430
compiler:       clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81)


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-23 21:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-28  2:47 KASAN: use-after-free Read in macvlan_dev_get_iflink syzbot
2020-07-23 17:06 ` syzbot
2020-07-23 20:08 ` Cong Wang
2020-07-23 21:20   ` syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).