KASAN: use-after-free Read in vlan_dev_get_iflink

33 views
Skip to first unread message

syzbot

unread,
Jul 23, 2020, 2:12:24 PM7/23/20
to ap42...@gmail.com, da...@davemloft.net, edum...@google.com, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com, xiyou.w...@gmail.com
Hello,

syzbot found the following issue on:

HEAD commit: 8c26c87b Merge tag 'sound-5.8-rc7' of git://git.kernel.org..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=128af5ef100000
kernel config: https://syzkaller.appspot.com/x/.config?x=f87a5e4232fdb267
dashboard link: https://syzkaller.appspot.com/bug?extid=d702fd2351989927037c
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1567cae8900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=150631b4900000

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

==================================================================
BUG: KASAN: use-after-free in vlan_dev_get_iflink+0x5f/0x70 net/8021q/vlan_dev.c:767
Read of size 4 at addr ffff888094a76100 by task syz-executor015/9454

CPU: 1 PID: 9454 Comm: syz-executor015 Not tainted 5.8.0-rc6-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+0x18f/0x20d lib/dump_stack.c:118
print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383
__kasan_report mm/kasan/report.c:513 [inline]
kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
vlan_dev_get_iflink+0x5f/0x70 net/8021q/vlan_dev.c:767
dev_get_iflink+0x73/0xe0 net/core/dev.c:814
rfc2863_policy+0x243/0x2e0 net/core/link_watch.c:41
linkwatch_do_dev+0x2a/0x180 net/core/link_watch.c:160
linkwatch_forget_dev+0x16a/0x200 net/core/link_watch.c:237
netdev_wait_allrefs net/core/dev.c:9678 [inline]
netdev_run_todo+0x258/0xac0 net/core/dev.c:9774
rtnl_unlock net/core/rtnetlink.c:112 [inline]
rtnetlink_rcv_msg+0x45b/0xad0 net/core/rtnetlink.c:5461
netlink_rcv_skb+0x15a/0x430 net/netlink/af_netlink.c:2469
netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1329
netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1918
sock_sendmsg_nosec net/socket.c:652 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:672
____sys_sendmsg+0x6e8/0x810 net/socket.c:2352
___sys_sendmsg+0xf3/0x170 net/socket.c:2406
__sys_sendmsg+0xe5/0x1b0 net/socket.c:2439
do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x446cf9
Code: Bad RIP value.
RSP: 002b:00007f4a27e29d98 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00000000006dbc78 RCX: 0000000000446cf9
RDX: 0000000000000000 RSI: 0000000020000080 RDI: 0000000000000006
RBP: 00000000006dbc70 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dbc7c
R13: 0000000040000000 R14: 0000001000000000 R15: 0705001000000048

Allocated by task 9440:
save_stack+0x1b/0x40 mm/kasan/common.c:48
set_track mm/kasan/common.c:56 [inline]
__kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494
kmalloc_node include/linux/slab.h:578 [inline]
kvmalloc_node+0x61/0xf0 mm/util.c:574
kvmalloc include/linux/mm.h:753 [inline]
kvzalloc include/linux/mm.h:761 [inline]
alloc_netdev_mqs+0x97/0xdc0 net/core/dev.c:9938
rtnl_create_link+0x219/0xad0 net/core/rtnetlink.c:3067
__rtnl_newlink+0xfa0/0x1730 net/core/rtnetlink.c:3329
rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3397
rtnetlink_rcv_msg+0x44e/0xad0 net/core/rtnetlink.c:5460
netlink_rcv_skb+0x15a/0x430 net/netlink/af_netlink.c:2469
netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1329
netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1918
sock_sendmsg_nosec net/socket.c:652 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:672
____sys_sendmsg+0x6e8/0x810 net/socket.c:2352
___sys_sendmsg+0xf3/0x170 net/socket.c:2406
__sys_sendmsg+0xe5/0x1b0 net/socket.c:2439
do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 9461:
save_stack+0x1b/0x40 mm/kasan/common.c:48
set_track mm/kasan/common.c:56 [inline]
kasan_set_free_info mm/kasan/common.c:316 [inline]
__kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455
__cache_free mm/slab.c:3426 [inline]
kfree+0x103/0x2c0 mm/slab.c:3757
kvfree+0x42/0x50 mm/util.c:603
device_release+0x71/0x200 drivers/base/core.c:1579
kobject_cleanup lib/kobject.c:693 [inline]
kobject_release lib/kobject.c:722 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x1c0/0x270 lib/kobject.c:739
netdev_run_todo+0x765/0xac0 net/core/dev.c:9797
rtnl_unlock net/core/rtnetlink.c:112 [inline]
rtnetlink_rcv_msg+0x45b/0xad0 net/core/rtnetlink.c:5461
netlink_rcv_skb+0x15a/0x430 net/netlink/af_netlink.c:2469
netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1329
netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1918
sock_sendmsg_nosec net/socket.c:652 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:672
____sys_sendmsg+0x6e8/0x810 net/socket.c:2352
___sys_sendmsg+0xf3/0x170 net/socket.c:2406
__sys_sendmsg+0xe5/0x1b0 net/socket.c:2439
do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
entry_SYSCALL_64_after_hwframe+0x44/0xa9

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

Memory state around the buggy address:
ffff888094a76000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888094a76080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888094a76100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888094a76180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888094a76200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
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 can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

Cong Wang

unread,
Jul 23, 2020, 4:09:06 PM7/23/20
to syzbot, Taehee Yoo, David Miller, Eric Dumazet, Jakub Kicinski, LKML, Linux Kernel Network Developers, syzkaller-bugs

syzbot

unread,
Jul 23, 2020, 5:30:08 PM7/23/20
to ap42...@gmail.com, da...@davemloft.net, edum...@google.com, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com, xiyou.w...@gmail.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in vlan_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: 1 PID: 8207 Comm: syz-executor.3 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:vlan_get_link_net+0x46/0x70 net/8021q/vlan_netlink.c:279
Code: fa 48 c1 ea 03 80 3c 02 00 75 2e 48 8b 9b 70 0c 00 00 48 b8 00 00 00 00 00 fc ff df 48 8d bb 98 05 00 00 48 89 fa 48 c1 ea 03 <80> 3c 02 00 75 10 48 8b 83 98 05 00 00 5b c3 e8 86 1f 63 fa eb cb
RSP: 0018:ffffc90004706eb8 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffff888092c85230
RDX: 00000000000000b3 RSI: ffffffff874ffe39 RDI: 0000000000000598
RBP: 0000000000000000 R08: 0000000000000000 R09: ffffffff8a7b8647
R10: 0000000000000000 R11: 0000000000000000 R12: ffffc90004706f80
R13: 0000000000000030 R14: ffff8880930ba900 R15: ffff8880930cc000
FS: 00007f4a9113a700(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005643b6ad2140 CR3: 000000009335e000 CR4: 00000000001406e0
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+0x1bc5/0x3c40 net/core/rtnetlink.c:1758
rtmsg_ifinfo_build_skb+0xcd/0x1a0 net/core/rtnetlink.c:3706
rollback_registered_many+0xb7d/0xf60 net/core/dev.c:8972
unregister_netdevice_many.part.0+0x1a/0x2f0 net/core/dev.c:10113
unregister_netdevice_many+0x36/0x50 net/core/dev.c:10112
__rtnl_newlink+0x13bd/0x1750 net/core/rtnetlink.c:3381
rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3398
rtnetlink_rcv_msg+0x44e/0xad0 net/core/rtnetlink.c:5461
netlink_rcv_skb+0x15a/0x430 net/netlink/af_netlink.c:2469
netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1329
netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1918
sock_sendmsg_nosec net/socket.c:652 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:672
____sys_sendmsg+0x6e8/0x810 net/socket.c:2352
___sys_sendmsg+0xf3/0x170 net/socket.c:2406
__sys_sendmsg+0xe5/0x1b0 net/socket.c:2439
do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x45c1f9
Code: Bad RIP value.
RSP: 002b:00007f4a91139c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 000000000002b580 RCX: 000000000045c1f9
RDX: 0000000000000000 RSI: 0000000020000080 RDI: 0000000000000006
RBP: 000000000078bfe0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000078bfac
R13: 00007ffc004cce8f R14: 00007f4a9113a9c0 R15: 000000000078bfac
Modules linked in:
---[ end trace e42f7b565341dee6 ]---
RIP: 0010:read_pnet include/net/net_namespace.h:330 [inline]
RIP: 0010:dev_net include/linux/netdevice.h:2261 [inline]
RIP: 0010:vlan_get_link_net+0x46/0x70 net/8021q/vlan_netlink.c:279
Code: fa 48 c1 ea 03 80 3c 02 00 75 2e 48 8b 9b 70 0c 00 00 48 b8 00 00 00 00 00 fc ff df 48 8d bb 98 05 00 00 48 89 fa 48 c1 ea 03 <80> 3c 02 00 75 10 48 8b 83 98 05 00 00 5b c3 e8 86 1f 63 fa eb cb
RSP: 0018:ffffc90004706eb8 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffff888092c85230
RDX: 00000000000000b3 RSI: ffffffff874ffe39 RDI: 0000000000000598
RBP: 0000000000000000 R08: 0000000000000000 R09: ffffffff8a7b8647
R10: 0000000000000000 R11: 0000000000000000 R12: ffffc90004706f80
R13: 0000000000000030 R14: ffff8880930ba900 R15: ffff8880930cc000
FS: 00007f4a9113a700(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005643b6ad2140 CR3: 000000009335e000 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=158bd540900000
kernel config: https://syzkaller.appspot.com/x/.config?x=dddbcb5a9f4192db

syzbot

unread,
Jul 23, 2020, 11:48:05 PM7/23/20
to syzkall...@googlegroups.com, xiyou.w...@gmail.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: use-after-free Read in vlan_dev_get_iflink

==================================================================
BUG: KASAN: use-after-free in vlan_dev_get_iflink+0x5f/0x70 net/8021q/vlan_dev.c:767
Read of size 4 at addr ffff88808c768100 by task kworker/1:107/2894

CPU: 1 PID: 2894 Comm: kworker/1:107 Not tainted 5.8.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events linkwatch_event
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x18f/0x20d lib/dump_stack.c:118
print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383
__kasan_report mm/kasan/report.c:513 [inline]
kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
vlan_dev_get_iflink+0x5f/0x70 net/8021q/vlan_dev.c:767
dev_get_iflink+0x73/0xe0 net/core/dev.c:814
rfc2863_policy+0x2ae/0x330 net/core/link_watch.c:44
linkwatch_do_dev+0x2a/0x180 net/core/link_watch.c:163
__linkwatch_run_queue+0x1ea/0x630 net/core/link_watch.c:215
linkwatch_event+0x4a/0x60 net/core/link_watch.c:254
process_one_work+0x94c/0x1670 kernel/workqueue.c:2269
worker_thread+0x64c/0x1120 kernel/workqueue.c:2415
kthread+0x3b5/0x4a0 kernel/kthread.c:291
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293

Allocated by task 22862:
save_stack+0x1b/0x40 mm/kasan/common.c:48
set_track mm/kasan/common.c:56 [inline]
__kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494
kmalloc_node include/linux/slab.h:578 [inline]
kvmalloc_node+0x61/0xf0 mm/util.c:574
kvmalloc include/linux/mm.h:753 [inline]
kvzalloc include/linux/mm.h:761 [inline]
alloc_netdev_mqs+0x97/0xdc0 net/core/dev.c:9938
rtnl_create_link+0x219/0xad0 net/core/rtnetlink.c:3067
__rtnl_newlink+0xfa0/0x1750 net/core/rtnetlink.c:3329
rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3398
rtnetlink_rcv_msg+0x44e/0xad0 net/core/rtnetlink.c:5461
netlink_rcv_skb+0x15a/0x430 net/netlink/af_netlink.c:2469
netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1329
netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1918
sock_sendmsg_nosec net/socket.c:652 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:672
____sys_sendmsg+0x6e8/0x810 net/socket.c:2352
___sys_sendmsg+0xf3/0x170 net/socket.c:2406
__sys_sendmsg+0xe5/0x1b0 net/socket.c:2439
do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 22933:
save_stack+0x1b/0x40 mm/kasan/common.c:48
set_track mm/kasan/common.c:56 [inline]
kasan_set_free_info mm/kasan/common.c:316 [inline]
__kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455
__cache_free mm/slab.c:3426 [inline]
kfree+0x103/0x2c0 mm/slab.c:3757
kvfree+0x42/0x50 mm/util.c:603
device_release+0x71/0x200 drivers/base/core.c:1559
kobject_cleanup lib/kobject.c:693 [inline]
kobject_release lib/kobject.c:722 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x1c0/0x270 lib/kobject.c:739
netdev_run_todo+0x765/0xac0 net/core/dev.c:9797
rtnl_unlock net/core/rtnetlink.c:112 [inline]
rtnetlink_rcv_msg+0x45b/0xad0 net/core/rtnetlink.c:5462
netlink_rcv_skb+0x15a/0x430 net/netlink/af_netlink.c:2469
netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1329
netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1918
sock_sendmsg_nosec net/socket.c:652 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:672
____sys_sendmsg+0x6e8/0x810 net/socket.c:2352
___sys_sendmsg+0xf3/0x170 net/socket.c:2406
__sys_sendmsg+0xe5/0x1b0 net/socket.c:2439
do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
entry_SYSCALL_64_after_hwframe+0x44/0xa9

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

Memory state around the buggy address:
ffff88808c768000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88808c768080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88808c768100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88808c768180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88808c768200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


Tested on:

commit: 3bdc5455 qrtr: orphan skb before queuing in xmit
console output: https://syzkaller.appspot.com/x/log.txt?x=131de3a0900000

syzbot

unread,
Jul 24, 2020, 6:21:08 AM7/24/20
to syzkall...@googlegroups.com, xiyou.w...@gmail.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+d702fd...@syzkaller.appspotmail.com

Tested on:

commit: ddb32108 qrtr: orphan skb before queuing in xmit
Note: testing is done by a robot and is best-effort only.

syzbot

unread,
Sep 27, 2022, 8:32:31 AM9/27/22
to syzkall...@googlegroups.com
Auto-closing this bug as obsolete.
No recent activity, existing reproducers are no longer triggering the issue.
Reply all
Reply to author
Forward
0 new messages