syzbot


KASAN: use-after-free Read in ip_cmsg_recv_offset

Status: public: reported C repro on 2019/04/12 00:00
Reported-by: syzbot+00e97a57dd8ad4fbacd0@syzkaller.appspotmail.com
First crash: 2245d, last: 2227d
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 2233d 2048d 0/3 public: reported C repro on 2019/04/14 08:51
upstream KASAN: use-after-free Read in ip_cmsg_recv_offset net C 9 2242d 2245d 11/28 fixed on 2018/10/11 14:33

Sample crash report:
raw_sendmsg: syz-executor044 forgot to set AF_INET. Fix it!
==================================================================
BUG: KASAN: use-after-free in ip_cmsg_recv_dstaddr net/ipv4/ip_sockglue.c:165 [inline]
BUG: KASAN: use-after-free in ip_cmsg_recv_offset+0xcc6/0xde0 net/ipv4/ip_sockglue.c:228
Read of size 4 at addr ffff8801d21ce020 by task syz-executor044/1827

CPU: 1 PID: 1827 Comm: syz-executor044 Not tainted 4.14.72+ #11
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0xb9/0x11b lib/dump_stack.c:53
 print_address_description+0x60/0x22b mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report.cold.6+0x11b/0x2dd mm/kasan/report.c:409
 ip_cmsg_recv_dstaddr net/ipv4/ip_sockglue.c:165 [inline]
 ip_cmsg_recv_offset+0xcc6/0xde0 net/ipv4/ip_sockglue.c:228
 ip_cmsg_recv include/net/ip.h:634 [inline]
 raw_recvmsg+0x552/0x6d0 net/ipv4/raw.c:791
 inet_recvmsg+0x147/0x560 net/ipv4/af_inet.c:812
 sock_recvmsg_nosec net/socket.c:818 [inline]
 sock_recvmsg+0xc0/0x100 net/socket.c:825
 sock_read_iter+0x239/0x340 net/socket.c:902
 call_read_iter include/linux/fs.h:1776 [inline]
 do_iter_readv_writev+0x473/0x560 fs/read_write.c:676
 do_iter_read+0x212/0x580 fs/read_write.c:920
 vfs_readv+0xe6/0x150 fs/read_write.c:984
 do_readv+0xcc/0x240 fs/read_write.c:1017
 do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x446579
RSP: 002b:00007f033dba0da8 EFLAGS: 00000293 ORIG_RAX: 0000000000000013
RAX: ffffffffffffffda RBX: 00000000006dbc28 RCX: 0000000000446579
RDX: 0000000000000001 RSI: 0000000020000500 RDI: 0000000000000003
RBP: 00000000006dbc20 R08: 000000000000006e R09: 0000000000000000
R10: 000000000000006e R11: 0000000000000293 R12: 00000000006dbc2c
R13: 00000000004ae620 R14: 0000000020001300 R15: 0000000000000000

Allocated by task 1820:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc.part.1+0x4f/0xd0 mm/kasan/kasan.c:551
 slab_post_alloc_hook mm/slab.h:442 [inline]
 slab_alloc_node mm/slub.c:2723 [inline]
 slab_alloc mm/slub.c:2731 [inline]
 __kmalloc_track_caller+0x104/0x300 mm/slub.c:4288
 __kmalloc_reserve.isra.8+0x2f/0xc0 net/core/skbuff.c:137
 __alloc_skb+0x105/0x550 net/core/skbuff.c:205
 alloc_skb include/linux/skbuff.h:980 [inline]
 sock_wmalloc+0xa5/0xf0 net/core/sock.c:1927
 __ip_append_data.isra.2+0x1983/0x2020 net/ipv4/ip_output.c:978
 ip_append_data.part.4+0xd8/0x150 net/ipv4/ip_output.c:1173
 ip_append_data+0x5a/0x80 net/ipv4/ip_output.c:1162
 raw_sendmsg+0xa33/0x2470 net/ipv4/raw.c:663
 inet_sendmsg+0x168/0x540 net/ipv4/af_inet.c:781
 sock_sendmsg_nosec net/socket.c:645 [inline]
 sock_sendmsg+0xb5/0x100 net/socket.c:655
 SYSC_sendto net/socket.c:1762 [inline]
 SyS_sendto+0x211/0x340 net/socket.c:1730
 do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 1827:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0xac/0x190 mm/kasan/kasan.c:524
 slab_free_hook mm/slub.c:1389 [inline]
 slab_free_freelist_hook mm/slub.c:1410 [inline]
 slab_free mm/slub.c:2966 [inline]
 kfree+0xf5/0x310 mm/slub.c:3897
 skb_free_head+0x83/0xa0 net/core/skbuff.c:550
 pskb_expand_head+0x553/0xb30 net/core/skbuff.c:1491
 __pskb_pull_tail+0xca/0x1500 net/core/skbuff.c:1887
 pskb_may_pull include/linux/skbuff.h:2116 [inline]
 ip_cmsg_recv_dstaddr net/ipv4/ip_sockglue.c:155 [inline]
 ip_cmsg_recv_offset+0xbe2/0xde0 net/ipv4/ip_sockglue.c:228
 ip_cmsg_recv include/net/ip.h:634 [inline]
 raw_recvmsg+0x552/0x6d0 net/ipv4/raw.c:791
 inet_recvmsg+0x147/0x560 net/ipv4/af_inet.c:812
 sock_recvmsg_nosec net/socket.c:818 [inline]
 sock_recvmsg+0xc0/0x100 net/socket.c:825
 sock_read_iter+0x239/0x340 net/socket.c:902
 call_read_iter include/linux/fs.h:1776 [inline]
 do_iter_readv_writev+0x473/0x560 fs/read_write.c:676
 do_iter_read+0x212/0x580 fs/read_write.c:920
 vfs_readv+0xe6/0x150 fs/read_write.c:984
 do_readv+0xcc/0x240 fs/read_write.c:1017
 do_syscall_64+0x19b/0x4b0 arch/x86/entry/common.c:289
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff8801d21ce000
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 32 bytes inside of
 512-byte region [ffff8801d21ce000, ffff8801d21ce200)
The buggy address belongs to the page:
page:ffffea0007487380 count:1 mapcount:0 mapping:          (null) index:0x0 compound_mapcount: 0
flags: 0x4000000000008100(slab|head)
raw: 4000000000008100 0000000000000000 0000000000000000 00000001000c000c
raw: ffffea000748f000 0000000400000004 ffff8801da802c00 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801d21cdf00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8801d21cdf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8801d21ce000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff8801d21ce080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d21ce100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (11):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/09/29 10:41 android-4.14 56aae8ee7423 41e4b329 .config console log report syz C ci-android-414-kasan-gce-root
2018/10/16 16:38 android-4.14 48091d94336e 1ba7fd7e .config console log report ci-android-414-kasan-gce-root
2018/10/16 09:11 android-4.14 48091d94336e 8cd30605 .config console log report ci-android-414-kasan-gce-root
2018/10/11 17:55 android-4.14 b7e40c3d444a ba6ddb43 .config console log report ci-android-414-kasan-gce-root
2018/10/11 10:34 android-4.14 b7e40c3d444a 5f818b4b .config console log report ci-android-414-kasan-gce-root
2018/10/07 01:04 android-4.14 d33692e8014d 8b311eaf .config console log report ci-android-414-kasan-gce-root
2018/10/03 02:08 android-4.14 ff9973a5da5e 0f3e0261 .config console log report ci-android-414-kasan-gce-root
2018/10/02 03:41 android-4.14 e6fa8a2046e5 e06f7713 .config console log report ci-android-414-kasan-gce-root
2018/10/01 10:35 android-4.14 84ae3e35e1ce 48a50c6b .config console log report ci-android-414-kasan-gce-root
2018/09/30 22:24 android-4.14 84ae3e35e1ce 41e4b329 .config console log report ci-android-414-kasan-gce-root
2018/09/29 10:07 android-4.14 56aae8ee7423 41e4b329 .config console log report ci-android-414-kasan-gce-root
* Struck through repros no longer work on HEAD.