KASAN: use-after-free Read in ip_cmsg_recv_offset

24 views
Skip to first unread message

syzbot

unread,
Apr 11, 2019, 8:00:57 PM4/11/19
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 56aae8ee Merge remote-tracking branch 'origin/upstream-f2f..
git tree: android-4.14
console output: https://syzkaller.appspot.com/x/log.txt?x=17d2923a400000
kernel config: https://syzkaller.appspot.com/x/.config?x=a4bc2e53771f6a92
dashboard link: https://syzkaller.appspot.com/bug?extid=00e97a57dd8ad4fbacd0
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12cbfe81400000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=142058e6400000

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

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
==================================================================


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

syzbot

unread,
Apr 14, 2019, 4:51:26 AM4/14/19
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 4fc79c48 Merge remote-tracking branch 'origin/upstream-f2f..
git tree: android-4.9
console output: https://syzkaller.appspot.com/x/log.txt?x=10a1532a400000
kernel config: https://syzkaller.appspot.com/x/.config?x=89798c9613dbe1ae
dashboard link: https://syzkaller.appspot.com/bug?extid=d5f4e8be573ee763ff82
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14a0fac9400000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12d3c4e6400000

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

raw_sendmsg: syz-executor859 forgot to set AF_INET. Fix it!
==================================================================
BUG: KASAN: use-after-free in ip_cmsg_recv_dstaddr
net/ipv4/ip_sockglue.c:152 [inline]
BUG: KASAN: use-after-free in ip_cmsg_recv_offset+0xc59/0xdd0
net/ipv4/ip_sockglue.c:215
Read of size 4 at addr ffff8801d2557420 by task syz-executor859/2056

CPU: 1 PID: 2056 Comm: syz-executor859 Not tainted 4.9.129+ #45
ffff8801ce8875a8 ffffffff81b36939 ffffea0007495580 ffff8801d2557420
0000000000000000 ffff8801d2557420 ffff8801d2590a24 ffff8801ce8875e0
ffffffff8150072d ffff8801d2557420 0000000000000004 0000000000000000
Call Trace:
[<ffffffff81b36939>] __dump_stack lib/dump_stack.c:15 [inline]
[<ffffffff81b36939>] dump_stack+0xc1/0x128 lib/dump_stack.c:51
[<ffffffff8150072d>] print_address_description+0x6c/0x234
mm/kasan/report.c:256
[<ffffffff81500b37>] kasan_report_error mm/kasan/report.c:355 [inline]
[<ffffffff81500b37>] kasan_report.cold.6+0x242/0x2fe mm/kasan/report.c:412
[<ffffffff814f2d24>] __asan_report_load4_noabort+0x14/0x20
mm/kasan/report.c:432
[<ffffffff824a95c9>] ip_cmsg_recv_dstaddr net/ipv4/ip_sockglue.c:152
[inline]
[<ffffffff824a95c9>] ip_cmsg_recv_offset+0xc59/0xdd0
net/ipv4/ip_sockglue.c:215
[<ffffffff82549117>] ip_cmsg_recv include/net/ip.h:612 [inline]
[<ffffffff82549117>] raw_recvmsg+0x577/0x660 net/ipv4/raw.c:769
[<ffffffff825824ee>] inet_recvmsg+0x23e/0x4c0 net/ipv4/af_inet.c:801
[<ffffffff8228ddd6>] sock_recvmsg_nosec net/socket.c:750 [inline]
[<ffffffff8228ddd6>] sock_recvmsg+0xc6/0x110 net/socket.c:757
[<ffffffff8228e06a>] sock_read_iter+0x24a/0x360 net/socket.c:834
[<ffffffff815073a8>] do_iter_readv_writev+0x2f8/0x4b0 fs/read_write.c:693
[<ffffffff8150af9a>] do_readv_writev+0x2fa/0x7b0 fs/read_write.c:871
[<ffffffff8150b4d4>] vfs_readv+0x84/0xc0 fs/read_write.c:897
[<ffffffff8150b5f6>] do_readv+0xe6/0x260 fs/read_write.c:923
[<ffffffff8150ee57>] SYSC_readv fs/read_write.c:1010 [inline]
[<ffffffff8150ee57>] SyS_readv+0x27/0x30 fs/read_write.c:1007
[<ffffffff810056ef>] do_syscall_64+0x19f/0x550 arch/x86/entry/common.c:285
[<ffffffff82802d13>] entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Allocated by task 2056:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
save_stack mm/kasan/kasan.c:505 [inline]
set_track mm/kasan/kasan.c:517 [inline]
kasan_kmalloc.part.1+0x62/0xf0 mm/kasan/kasan.c:609
kasan_kmalloc+0xaf/0xc0 mm/kasan/kasan.c:594
kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:547
slab_post_alloc_hook mm/slab.h:417 [inline]
slab_alloc_node mm/slub.c:2715 [inline]
slab_alloc mm/slub.c:2723 [inline]
__kmalloc_track_caller+0xf0/0x2d0 mm/slub.c:4232
__kmalloc_reserve.isra.5+0x33/0xc0 net/core/skbuff.c:138
__alloc_skb+0x11a/0x5b0 net/core/skbuff.c:231
alloc_skb include/linux/skbuff.h:919 [inline]
sock_wmalloc+0x9e/0xe0 net/core/sock.c:1772
__ip_append_data.isra.2+0x20e7/0x2930 net/ipv4/ip_output.c:1039
ip_append_data.part.4+0xe4/0x150 net/ipv4/ip_output.c:1231
ip_append_data+0x68/0x80 net/ipv4/ip_output.c:1220
raw_sendmsg+0xb74/0x2480 net/ipv4/raw.c:652
inet_sendmsg+0x203/0x4d0 net/ipv4/af_inet.c:770
sock_sendmsg_nosec net/socket.c:648 [inline]
sock_sendmsg+0xbb/0x110 net/socket.c:658
SYSC_sendto net/socket.c:1683 [inline]
SyS_sendto+0x220/0x370 net/socket.c:1651
do_syscall_64+0x19f/0x550 arch/x86/entry/common.c:285
entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Freed by task 2056:
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
save_stack mm/kasan/kasan.c:505 [inline]
set_track mm/kasan/kasan.c:517 [inline]
kasan_slab_free+0xac/0x190 mm/kasan/kasan.c:582
slab_free_hook mm/slub.c:1355 [inline]
slab_free_freelist_hook mm/slub.c:1377 [inline]
slab_free mm/slub.c:2958 [inline]
kfree+0xfb/0x310 mm/slub.c:3878
skb_free_head+0x8b/0xb0 net/core/skbuff.c:580
pskb_expand_head+0x457/0x8a0 net/core/skbuff.c:1246
__pskb_pull_tail+0xc7/0x1240 net/core/skbuff.c:1615
pskb_may_pull include/linux/skbuff.h:1966 [inline]
ip_cmsg_recv_dstaddr net/ipv4/ip_sockglue.c:142 [inline]
ip_cmsg_recv_offset+0xbb0/0xdd0 net/ipv4/ip_sockglue.c:215
ip_cmsg_recv include/net/ip.h:612 [inline]
raw_recvmsg+0x577/0x660 net/ipv4/raw.c:769
inet_recvmsg+0x23e/0x4c0 net/ipv4/af_inet.c:801
sock_recvmsg_nosec net/socket.c:750 [inline]
sock_recvmsg+0xc6/0x110 net/socket.c:757
sock_read_iter+0x24a/0x360 net/socket.c:834
do_iter_readv_writev+0x2f8/0x4b0 fs/read_write.c:693
do_readv_writev+0x2fa/0x7b0 fs/read_write.c:871
vfs_readv+0x84/0xc0 fs/read_write.c:897
do_readv+0xe6/0x260 fs/read_write.c:923
SYSC_readv fs/read_write.c:1010 [inline]
SyS_readv+0x27/0x30 fs/read_write.c:1007
do_syscall_64+0x19f/0x550 arch/x86/entry/common.c:285
entry_SYSCALL_64_after_swapgs+0x5d/0xdb

The buggy address belongs to the object at ffff8801d2557400
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 32 bytes inside of
512-byte region [ffff8801d2557400, ffff8801d2557600)
The buggy address belongs to the page:
page:ffffea0007495580 count:1 mapcount:0 mapping: (null) index:0x0
compound_mapcount: 0
flags: 0x4000000000004080(slab|head)
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801d2557300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801d2557380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ffff8801d2557400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8801d2557480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801d2557500: 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