syzbot


KASAN: use-after-free Read in ip_cmsg_recv_offset

Status: fixed on 2018/10/11 14:33
Subsystems: net
[Documentation on labels]
Fix commit: 64199fc0a46b net-backports: ipv4: fix use-after-free in ip_cmsg_recv_dstaddr()
First crash: 2035d, last: 2032d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-49 KASAN: use-after-free Read in ip_cmsg_recv_offset C 2 2023d 1838d 0/3 public: reported C repro on 2019/04/14 08:51
android-414 KASAN: use-after-free Read in ip_cmsg_recv_offset C 11 2017d 1840d 0/1 public: reported C repro on 2019/04/12 00:00

Sample crash report:
raw_sendmsg: syz-executor599 forgot to set AF_INET. Fix it!
==================================================================
BUG: KASAN: use-after-free in ip_cmsg_recv_dstaddr net/ipv4/ip_sockglue.c:167 [inline]
BUG: KASAN: use-after-free in ip_cmsg_recv_offset+0x12be/0x1390 net/ipv4/ip_sockglue.c:230
Read of size 4 at addr ffff8801d8ae35a0 by task syz-executor599/5559

CPU: 1 PID: 5559 Comm: syz-executor599 Not tainted 4.19.0-rc5+ #38
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+0x1c4/0x2b4 lib/dump_stack.c:113
 print_address_description.cold.8+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
 ip_cmsg_recv_dstaddr net/ipv4/ip_sockglue.c:167 [inline]
 ip_cmsg_recv_offset+0x12be/0x1390 net/ipv4/ip_sockglue.c:230
 ip_cmsg_recv include/net/ip.h:679 [inline]
 raw_recvmsg+0x71d/0x8b0 net/ipv4/raw.c:797
 inet_recvmsg+0x181/0x6d0 net/ipv4/af_inet.c:830
 sock_recvmsg_nosec net/socket.c:794 [inline]
 sock_recvmsg+0xd0/0x110 net/socket.c:801
 sock_read_iter+0x39b/0x570 net/socket.c:878
 call_read_iter include/linux/fs.h:1802 [inline]
 do_iter_readv_writev+0x77c/0xa80 fs/read_write.c:678
 do_iter_read+0x26e/0x650 fs/read_write.c:922
 vfs_readv+0x175/0x1c0 fs/read_write.c:986
 do_readv+0x11a/0x310 fs/read_write.c:1019
 __do_sys_readv fs/read_write.c:1106 [inline]
 __se_sys_readv fs/read_write.c:1103 [inline]
 __x64_sys_readv+0x75/0xb0 fs/read_write.c:1103
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x446469
Code: e8 2c b3 02 00 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 2b 09 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f95a2e5fda8 EFLAGS: 00000293 ORIG_RAX: 0000000000000013
RAX: ffffffffffffffda RBX: 00000000006dbc28 RCX: 0000000000446469
RDX: 0000000000000001 RSI: 0000000020000500 RDI: 0000000000000003
RBP: 00000000006dbc20 R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000006e R11: 0000000000000293 R12: 00000000006dbc2c
R13: 00000000004ae560 R14: 0000000020001300 R15: 00000000006dbd2c

Allocated by task 5559:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 __do_kmalloc_node mm/slab.c:3682 [inline]
 __kmalloc_node_track_caller+0x47/0x70 mm/slab.c:3696
 __kmalloc_reserve.isra.39+0x41/0xe0 net/core/skbuff.c:137
 __alloc_skb+0x155/0x770 net/core/skbuff.c:205
 alloc_skb include/linux/skbuff.h:995 [inline]
 __ip_append_data.isra.47+0x21d6/0x29b0 net/ipv4/ip_output.c:988
 ip_append_data.part.48+0xef/0x170 net/ipv4/ip_output.c:1196
 ip_append_data+0x6d/0x90 net/ipv4/ip_output.c:1185
 raw_sendmsg+0x1220/0x4380 net/ipv4/raw.c:671
 inet_sendmsg+0x1a1/0x690 net/ipv4/af_inet.c:798
 sock_sendmsg_nosec net/socket.c:621 [inline]
 sock_sendmsg+0xd5/0x120 net/socket.c:631
 __sys_sendto+0x3d7/0x670 net/socket.c:1788
 __do_sys_sendto net/socket.c:1800 [inline]
 __se_sys_sendto net/socket.c:1796 [inline]
 __x64_sys_sendto+0xe1/0x1a0 net/socket.c:1796
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 5559:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xcf/0x230 mm/slab.c:3813
 skb_free_head+0x99/0xc0 net/core/skbuff.c:550
 pskb_expand_head+0x3bb/0x10f0 net/core/skbuff.c:1493
 __pskb_pull_tail+0x156/0x1890 net/core/skbuff.c:1890
 pskb_may_pull include/linux/skbuff.h:2119 [inline]
 ip_cmsg_recv_dstaddr net/ipv4/ip_sockglue.c:157 [inline]
 ip_cmsg_recv_offset+0x113b/0x1390 net/ipv4/ip_sockglue.c:230
 ip_cmsg_recv include/net/ip.h:679 [inline]
 raw_recvmsg+0x71d/0x8b0 net/ipv4/raw.c:797
 inet_recvmsg+0x181/0x6d0 net/ipv4/af_inet.c:830
 sock_recvmsg_nosec net/socket.c:794 [inline]
 sock_recvmsg+0xd0/0x110 net/socket.c:801
 sock_read_iter+0x39b/0x570 net/socket.c:878
 call_read_iter include/linux/fs.h:1802 [inline]
 do_iter_readv_writev+0x77c/0xa80 fs/read_write.c:678
 do_iter_read+0x26e/0x650 fs/read_write.c:922
 vfs_readv+0x175/0x1c0 fs/read_write.c:986
 do_readv+0x11a/0x310 fs/read_write.c:1019
 __do_sys_readv fs/read_write.c:1106 [inline]
 __se_sys_readv fs/read_write.c:1103 [inline]
 __x64_sys_readv+0x75/0xb0 fs/read_write.c:1103
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8801d8ae3580
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 32 bytes inside of
 512-byte region [ffff8801d8ae3580, ffff8801d8ae3780)
The buggy address belongs to the page:
page:ffffea000762b8c0 count:1 mapcount:0 mapping:ffff8801da800940 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffffea00075f2708 ffffea0007555488 ffff8801da800940
raw: 0000000000000000 ffff8801d8ae3080 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801d8ae3480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d8ae3500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8801d8ae3580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff8801d8ae3600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d8ae3680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (9):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/09/29 12:04 upstream e704966c45e4 41e4b329 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2018/09/29 11:12 upstream e704966c45e4 41e4b329 .config console log report syz C ci-upstream-kasan-gce
2018/09/29 11:11 upstream e704966c45e4 41e4b329 .config console log report syz C ci-upstream-kasan-gce-root
2018/09/29 11:06 upstream e704966c45e4 41e4b329 .config console log report syz C ci-upstream-kasan-gce-smack-root
2018/09/29 11:27 upstream e704966c45e4 41e4b329 .config console log report syz C ci-upstream-kasan-gce-386
2018/09/29 11:09 net-old 05c5e9ff22e3 41e4b329 .config console log report syz C ci-upstream-net-this-kasan-gce
2018/09/29 11:09 net-next-old 5362700c942b 41e4b329 .config console log report syz C ci-upstream-net-kasan-gce
2018/09/29 11:33 linux-next 4794a36bf08d 41e4b329 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/10/01 21:47 upstream 17b57b1883c1 e06f7713 .config console log report ci-upstream-kasan-gce-root
* Struck through repros no longer work on HEAD.