syzbot


KASAN: use-after-free Read in tipc_udp_nl_dump_remoteip

Status: fixed on 2019/12/13 00:31
Subsystems: tipc
[Documentation on labels]
Reported-by: syzbot+dbe02e13bcce52bcf182@syzkaller.appspotmail.com
Fix commit: ab5b526da048 net: genetlink: always allocate separate attrs for dumpit ops
First crash: 1889d, last: 1888d
Cause bisection: introduced by (bisect log) :
commit 057af70713445fad2459aa348c9c2c4ecf7db938
Author: Jiri Pirko <jiri@mellanox.com>
Date: Sat Oct 5 18:04:39 2019 +0000

  net: tipc: have genetlink code to parse the attrs during dumpit

Crash: KASAN: use-after-free Read in tipc_udp_nl_dump_remoteip (log)
Repro: C syz .config
  
Discussions (2)
Title Replies (including bot) Last reply
[patch net-next] net: genetlink: always allocate separate attrs for dumpit ops, 2 (2) 2019/10/09 01:05
KASAN: use-after-free Read in tipc_udp_nl_dump_remoteip 0 (2) 2019/10/08 21:06
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in tipc_udp_nl_dump_remoteip (2) tipc C 9 1610d 1630d 15/28 fixed on 2020/07/20 08:03

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in nla_parse_nested_deprecated include/net/netlink.h:1166 [inline]
BUG: KASAN: use-after-free in tipc_udp_nl_dump_remoteip+0xc19/0xc20 net/tipc/udp_media.c:459
Read of size 2 at addr ffff888090c0f2d4 by task syz-executor616/8990

CPU: 1 PID: 8990 Comm: syz-executor616 Not tainted 5.4.0-rc1+ #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+0x172/0x1f0 lib/dump_stack.c:113
 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:634
 __asan_report_load2_noabort+0x14/0x20 mm/kasan/generic_report.c:130
 nla_parse_nested_deprecated include/net/netlink.h:1166 [inline]
 tipc_udp_nl_dump_remoteip+0xc19/0xc20 net/tipc/udp_media.c:459
 genl_lock_dumpit+0x86/0xc0 net/netlink/genetlink.c:529
 netlink_dump+0x558/0xfb0 net/netlink/af_netlink.c:2244
 __netlink_dump_start+0x5b1/0x7d0 net/netlink/af_netlink.c:2352
 genl_family_rcv_msg_dumpit net/netlink/genetlink.c:614 [inline]
 genl_family_rcv_msg net/netlink/genetlink.c:710 [inline]
 genl_rcv_msg+0xc9b/0x1000 net/netlink/genetlink.c:730
 netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477
 genl_rcv+0x29/0x40 net/netlink/genetlink.c:741
 netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
 netlink_unicast+0x531/0x710 net/netlink/af_netlink.c:1328
 netlink_sendmsg+0x8a5/0xd60 net/netlink/af_netlink.c:1917
 sock_sendmsg_nosec net/socket.c:637 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:657
 ___sys_sendmsg+0x803/0x920 net/socket.c:2311
 __sys_sendmsg+0x105/0x1d0 net/socket.c:2356
 __do_sys_sendmsg net/socket.c:2365 [inline]
 __se_sys_sendmsg net/socket.c:2363 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2363
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x445279
Code: e8 ac e8 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 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 0b cd fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fffac1fc178 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000445279
RDX: 0000000000000000 RSI: 0000000020000200 RDI: 0000000000000005
RBP: 0000000000010907 R08: 0000000000000000 R09: 00000000004002e0
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000402410
R13: 00000000004024a0 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 8992:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 __kasan_kmalloc mm/kasan/common.c:510 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:483
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:524
 __do_kmalloc_node mm/slab.c:3615 [inline]
 __kmalloc_node_track_caller+0x4e/0x70 mm/slab.c:3629
 __kmalloc_reserve.isra.0+0x40/0xf0 net/core/skbuff.c:141
 __alloc_skb+0x10b/0x5e0 net/core/skbuff.c:209
 alloc_skb include/linux/skbuff.h:1049 [inline]
 netlink_alloc_large_skb net/netlink/af_netlink.c:1174 [inline]
 netlink_sendmsg+0x972/0xd60 net/netlink/af_netlink.c:1892
 sock_sendmsg_nosec net/socket.c:637 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:657
 ___sys_sendmsg+0x803/0x920 net/socket.c:2311
 __sys_sendmsg+0x105/0x1d0 net/socket.c:2356
 __do_sys_sendmsg net/socket.c:2365 [inline]
 __se_sys_sendmsg net/socket.c:2363 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2363
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8992:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 kasan_set_free_info mm/kasan/common.c:332 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:471
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:480
 __cache_free mm/slab.c:3425 [inline]
 kfree+0x10a/0x2c0 mm/slab.c:3756
 skb_free_head+0x93/0xb0 net/core/skbuff.c:591
 skb_release_data+0x42d/0x7c0 net/core/skbuff.c:611
 skb_release_all+0x4d/0x60 net/core/skbuff.c:665
 __kfree_skb net/core/skbuff.c:679 [inline]
 consume_skb net/core/skbuff.c:838 [inline]
 consume_skb+0xfb/0x3b0 net/core/skbuff.c:832
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x539/0x710 net/netlink/af_netlink.c:1328
 netlink_sendmsg+0x8a5/0xd60 net/netlink/af_netlink.c:1917
 sock_sendmsg_nosec net/socket.c:637 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:657
 ___sys_sendmsg+0x803/0x920 net/socket.c:2311
 __sys_sendmsg+0x105/0x1d0 net/socket.c:2356
 __do_sys_sendmsg net/socket.c:2365 [inline]
 __se_sys_sendmsg net/socket.c:2363 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2363
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff888090c0f2c0
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 20 bytes inside of
 512-byte region [ffff888090c0f2c0, ffff888090c0f4c0)
The buggy address belongs to the page:
page:ffffea00024303c0 refcount:1 mapcount:0 mapping:ffff8880aa400a80 index:0xffff888090c0fa40
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea0002441548 ffffea0002430608 ffff8880aa400a80
raw: ffff888090c0fa40 ffff888090c0f040 0000000100000005 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888090c0f180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888090c0f200: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff888090c0f280: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                                 ^
 ffff888090c0f300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888090c0f380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/10/07 04:49 net-next-old 056ddc38e941 f3f7d9c8 .config console log report syz C ci-upstream-net-kasan-gce
2019/10/08 12:58 net-next-old 940f13821528 28ac6e64 .config console log report ci-upstream-net-kasan-gce
2019/10/07 04:21 net-next-old 056ddc38e941 f3f7d9c8 .config console log report ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.