KASAN: use-after-free Read in rtnl_newlink

8 views
Skip to first unread message

syzbot

unread,
May 21, 2020, 8:38:14 PM5/21/20
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 1bab61d3 Linux 4.19.124
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=14999b81100000
kernel config: https://syzkaller.appspot.com/x/.config?x=e95e3ce854b90b1b
dashboard link: https://syzkaller.appspot.com/bug?extid=d293ff4bc139bc55ff94
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+d293ff...@syzkaller.appspotmail.com

x_tables: ip_tables: TPROXY target: used from hooks FORWARD, but only usable from PREROUTING
x_tables: ip_tables: TPROXY target: used from hooks FORWARD, but only usable from PREROUTING
==================================================================
BUG: KASAN: use-after-free in rtnl_newlink+0x13b0/0x1440 net/core/rtnetlink.c:3149
Read of size 1 at addr ffff888093da8ce8 by task syz-executor.1/27108

CPU: 1 PID: 27108 Comm: syz-executor.1 Not tainted 4.19.124-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+0x1fc/0x2fe lib/dump_stack.c:118
print_address_description.cold+0x54/0x222 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+0x88/0x2b9 mm/kasan/report.c:396
rtnl_newlink+0x13b0/0x1440 net/core/rtnetlink.c:3149
rtnetlink_rcv_msg+0x453/0xb80 net/core/rtnetlink.c:4777
netlink_rcv_skb+0x160/0x410 net/netlink/af_netlink.c:2455
netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
netlink_unicast+0x4d7/0x6a0 net/netlink/af_netlink.c:1344
netlink_sendmsg+0x6e3/0xcc0 net/netlink/af_netlink.c:1909
sock_sendmsg_nosec net/socket.c:622 [inline]
sock_sendmsg+0xc3/0x120 net/socket.c:632
___sys_sendmsg+0x803/0x920 net/socket.c:2115
__sys_sendmsg+0xec/0x1b0 net/socket.c:2153
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45ca29
Code: 0d b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 db b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f6dba355c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000500f40 RCX: 000000000045ca29
RDX: 0000000000000000 RSI: 0000000020000040 RDI: 0000000000000003
RBP: 000000000078bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 0000000000000a04 R14: 00000000004ccdcc R15: 00007f6dba3566d4

Allocated by task 27108:
__do_kmalloc_node mm/slab.c:3689 [inline]
__kmalloc_node+0x4c/0x70 mm/slab.c:3696
kmalloc_node include/linux/slab.h:557 [inline]
kvmalloc_node+0xb4/0xf0 mm/util.c:423
kvmalloc include/linux/mm.h:577 [inline]
kvzalloc include/linux/mm.h:585 [inline]
alloc_netdev_mqs+0x97/0xd50 net/core/dev.c:9127
rtnl_create_link+0x1d4/0xa30 net/core/rtnetlink.c:2869
rtnl_newlink+0xe1a/0x1440 net/core/rtnetlink.c:3131
rtnetlink_rcv_msg+0x453/0xb80 net/core/rtnetlink.c:4777
netlink_rcv_skb+0x160/0x410 net/netlink/af_netlink.c:2455
netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
netlink_unicast+0x4d7/0x6a0 net/netlink/af_netlink.c:1344
netlink_sendmsg+0x6e3/0xcc0 net/netlink/af_netlink.c:1909
sock_sendmsg_nosec net/socket.c:622 [inline]
sock_sendmsg+0xc3/0x120 net/socket.c:632
___sys_sendmsg+0x803/0x920 net/socket.c:2115
__sys_sendmsg+0xec/0x1b0 net/socket.c:2153
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 27108:
__cache_free mm/slab.c:3503 [inline]
kfree+0xce/0x220 mm/slab.c:3822
kvfree+0x59/0x60 mm/util.c:452
netdev_freemem net/core/dev.c:9081 [inline]
free_netdev+0x36d/0x420 net/core/dev.c:9232
device_release+0x76/0x210 drivers/base/core.c:1061
kobject_cleanup lib/kobject.c:662 [inline]
kobject_release lib/kobject.c:691 [inline]
kref_put include/linux/kref.h:70 [inline]
kobject_put+0x17c/0x270 lib/kobject.c:708
put_device drivers/base/core.c:2251 [inline]
device_unregister+0x24/0x30 drivers/base/core.c:2363
register_netdevice+0xbb0/0xf70 net/core/dev.c:8766
nsim_newlink+0x162/0x1c0 drivers/net/netdevsim/netdev.c:555
rtnl_newlink+0xf03/0x1440 net/core/rtnetlink.c:3141
rtnetlink_rcv_msg+0x453/0xb80 net/core/rtnetlink.c:4777
netlink_rcv_skb+0x160/0x410 net/netlink/af_netlink.c:2455
netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
netlink_unicast+0x4d7/0x6a0 net/netlink/af_netlink.c:1344
netlink_sendmsg+0x6e3/0xcc0 net/netlink/af_netlink.c:1909
sock_sendmsg_nosec net/socket.c:622 [inline]
sock_sendmsg+0xc3/0x120 net/socket.c:632
___sys_sendmsg+0x803/0x920 net/socket.c:2115
__sys_sendmsg+0xec/0x1b0 net/socket.c:2153
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff888093da8780
which belongs to the cache kmalloc-8192 of size 8192
The buggy address is located 1384 bytes inside of
8192-byte region [ffff888093da8780, ffff888093daa780)
The buggy address belongs to the page:
page:ffffea00024f6a00 count:1 mapcount:0 mapping:ffff88812c3d5080 index:0x0 compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffffea0002411408 ffffea000126f908 ffff88812c3d5080
raw: 0000000000000000 ffff888093da8780 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff888093da8b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888093da8c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888093da8c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888093da8d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888093da8d80: 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 syzk...@googlegroups.com.

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

syzbot

unread,
Feb 20, 2022, 12:13:17 PM2/20/22
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 3f8a27f9e27b Linux 4.19.211
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=10eaa602700000
kernel config: https://syzkaller.appspot.com/x/.config?x=9b9277b418617afe
dashboard link: https://syzkaller.appspot.com/bug?extid=d293ff4bc139bc55ff94
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=171ed2fa700000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16f204ca700000

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

netlink: 8 bytes leftover after parsing attributes in process `syz-executor467'.
netlink: 8 bytes leftover after parsing attributes in process `syz-executor467'.
==================================================================
BUG: KASAN: use-after-free in rtnl_newlink+0x1530/0x15c0 net/core/rtnetlink.c:3149
Read of size 1 at addr ffff8880b065c9a8 by task syz-executor467/8104

CPU: 1 PID: 8104 Comm: syz-executor467 Not tainted 4.19.211-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+0x1fc/0x2ef lib/dump_stack.c:118
print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
kasan_report mm/kasan/report.c:412 [inline]
__asan_report_load1_noabort+0x88/0x90 mm/kasan/report.c:430
rtnl_newlink+0x1530/0x15c0 net/core/rtnetlink.c:3149
rtnetlink_rcv_msg+0x453/0xb80 net/core/rtnetlink.c:4782
netlink_rcv_skb+0x160/0x440 net/netlink/af_netlink.c:2463
netlink_unicast_kernel net/netlink/af_netlink.c:1325 [inline]
netlink_unicast+0x4d5/0x690 net/netlink/af_netlink.c:1351
netlink_sendmsg+0x6c3/0xc50 net/netlink/af_netlink.c:1917
sock_sendmsg_nosec net/socket.c:651 [inline]
sock_sendmsg+0xc3/0x120 net/socket.c:661
___sys_sendmsg+0x7bb/0x8e0 net/socket.c:2227
__sys_sendmsg net/socket.c:2265 [inline]
__do_sys_sendmsg net/socket.c:2274 [inline]
__se_sys_sendmsg net/socket.c:2272 [inline]
__x64_sys_sendmsg+0x132/0x220 net/socket.c:2272
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f3ed255dbc9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 14 00 00 90 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 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe4ce02188 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00007f3ed255dbc9
RDX: 0000000000000000 RSI: 0000000020000040 RDI: 0000000000000004
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f3ed2520e20
R13: 0000000000000000 R14: 00007ffe4ce021b0 R15: 00007ffe4ce021a0

Allocated by task 8104:
__do_kmalloc_node mm/slab.c:3689 [inline]
__kmalloc_node+0x4c/0x70 mm/slab.c:3696
kmalloc_node include/linux/slab.h:557 [inline]
kvmalloc_node+0xb4/0xf0 mm/util.c:423
kvmalloc include/linux/mm.h:577 [inline]
kvzalloc include/linux/mm.h:585 [inline]
alloc_netdev_mqs+0x97/0xd50 net/core/dev.c:9152
rtnl_create_link+0x1d4/0xa40 net/core/rtnetlink.c:2869
rtnl_newlink+0xf45/0x15c0 net/core/rtnetlink.c:3131
rtnetlink_rcv_msg+0x453/0xb80 net/core/rtnetlink.c:4782
netlink_rcv_skb+0x160/0x440 net/netlink/af_netlink.c:2463
netlink_unicast_kernel net/netlink/af_netlink.c:1325 [inline]
netlink_unicast+0x4d5/0x690 net/netlink/af_netlink.c:1351
netlink_sendmsg+0x6c3/0xc50 net/netlink/af_netlink.c:1917
sock_sendmsg_nosec net/socket.c:651 [inline]
sock_sendmsg+0xc3/0x120 net/socket.c:661
___sys_sendmsg+0x7bb/0x8e0 net/socket.c:2227
__sys_sendmsg net/socket.c:2265 [inline]
__do_sys_sendmsg net/socket.c:2274 [inline]
__se_sys_sendmsg net/socket.c:2272 [inline]
__x64_sys_sendmsg+0x132/0x220 net/socket.c:2272
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8104:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
kvfree+0x59/0x60 mm/util.c:452
netdev_freemem net/core/dev.c:9106 [inline]
free_netdev+0x364/0x410 net/core/dev.c:9257
device_release+0x76/0x210 drivers/base/core.c:1076
kobject_cleanup lib/kobject.c:662 [inline]
kobject_release lib/kobject.c:691 [inline]
kref_put include/linux/kref.h:70 [inline]
kobject_put+0x28b/0x5d0 lib/kobject.c:708
put_device drivers/base/core.c:2267 [inline]
device_unregister+0x35/0xc0 drivers/base/core.c:2379
register_netdevice+0x901/0x10f0 net/core/dev.c:8791
nsim_newlink+0x162/0x1c0 drivers/net/netdevsim/netdev.c:555
rtnl_newlink+0x1030/0x15c0 net/core/rtnetlink.c:3141
rtnetlink_rcv_msg+0x453/0xb80 net/core/rtnetlink.c:4782
netlink_rcv_skb+0x160/0x440 net/netlink/af_netlink.c:2463
netlink_unicast_kernel net/netlink/af_netlink.c:1325 [inline]
netlink_unicast+0x4d5/0x690 net/netlink/af_netlink.c:1351
netlink_sendmsg+0x6c3/0xc50 net/netlink/af_netlink.c:1917
sock_sendmsg_nosec net/socket.c:651 [inline]
sock_sendmsg+0xc3/0x120 net/socket.c:661
___sys_sendmsg+0x7bb/0x8e0 net/socket.c:2227
__sys_sendmsg net/socket.c:2265 [inline]
__do_sys_sendmsg net/socket.c:2274 [inline]
__se_sys_sendmsg net/socket.c:2272 [inline]
__x64_sys_sendmsg+0x132/0x220 net/socket.c:2272
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880b065c440
which belongs to the cache kmalloc-8192 of size 8192
The buggy address is located 1384 bytes inside of
8192-byte region [ffff8880b065c440, ffff8880b065e440)
The buggy address belongs to the page:
page:ffffea0002c19700 count:1 mapcount:0 mapping:ffff88813bff2080 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffffea0002539c08 ffff88813bff1b48 ffff88813bff2080
raw: 0000000000000000 ffff8880b065c440 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880b065c880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880b065c900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880b065c980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880b065ca00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880b065ca80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Reply all
Reply to author
Forward
0 new messages