KASAN: use-after-free Read in ip6_fragment

26 views
Skip to first unread message

syzbot

unread,
Aug 18, 2019, 2:34:06 AM8/18/19
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 5d8bfdf8 UPSTREAM: drm/virtio: Fix cache entry creation ra..
git tree: android-4.14
console output: https://syzkaller.appspot.com/x/log.txt?x=10d25c4c600000
kernel config: https://syzkaller.appspot.com/x/.config?x=ebced6c15132b98
dashboard link: https://syzkaller.appspot.com/bug?extid=f80f56cb7b8d07aa3c40
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+f80f56...@syzkaller.appspotmail.com

audit: type=1400 audit(1566106390.073:50): avc: denied { read } for
pid=9110 comm="syz-executor.3"
path="/root/syzkaller-testdir073528355/syzkaller.HWYgm5/49/bus" dev="sda1"
ino=17057 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=system_u:object_r:lvm_control_t:s0 tclass=file permissive=1
binder: 9139:9153 Acquire 1 refcount change on invalid ref 3 ret -22
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0
sclass=netlink_route_socket pig=9126 comm=syz-executor.2
==================================================================
binder: 9139:9153 got reply transaction with no transaction stack
BUG: KASAN: use-after-free in ip6_dst_idev include/net/ip6_fib.h:147
[inline]
BUG: KASAN: use-after-free in ip6_fragment+0x2d4a/0x2f30
net/ipv6/ip6_output.c:768
Read of size 8 at addr ffff8881d0acbf18 by task syz-executor.2/9136

CPU: 0 PID: 9136 Comm: syz-executor.2 Not tainted 4.14.139+ #34
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0xca/0x134 lib/dump_stack.c:53
print_address_description+0x60/0x226 mm/kasan/report.c:187
binder: 9139:9153 transaction failed 29201/-71, size 0-0 line 3036
__kasan_report.cold+0x1a/0x41 mm/kasan/report.c:316
ip6_dst_idev include/net/ip6_fib.h:147 [inline]
ip6_fragment+0x2d4a/0x2f30 net/ipv6/ip6_output.c:768
ip6_finish_output+0x66d/0xb40 net/ipv6/ip6_output.c:152
NF_HOOK_COND include/linux/netfilter.h:239 [inline]
ip6_output+0x1dc/0x680 net/ipv6/ip6_output.c:171
dst_output include/net/dst.h:462 [inline]
ip6_local_out+0x98/0x170 net/ipv6/output_core.c:178
ip6_send_skb+0x9b/0x2f0 net/ipv6/ip6_output.c:1688
udp_v6_send_skb+0x4e2/0xe80 net/ipv6/udp.c:1081
udp_v6_push_pending_frames+0x224/0x330 net/ipv6/udp.c:1114
audit: type=1400 audit(1566106390.253:51): avc: denied { open } for
pid=9110 comm="syz-executor.3"
path="/root/syzkaller-testdir073528355/syzkaller.HWYgm5/49/bus" dev="sda1"
ino=17057 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=system_u:object_r:lvm_control_t:s0 tclass=file permissive=1
udpv6_sendmsg+0x194b/0x2500 net/ipv6/udp.c:1380
inet_sendmsg+0x15b/0x520 net/ipv4/af_inet.c:760
audit: type=1400 audit(1566106390.253:52): avc: denied { relabelfrom }
for pid=9110 comm="syz-executor.3" name="bus" dev="sda1" ino=17057
scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=system_u:object_r:lvm_control_t:s0 tclass=file permissive=1
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xb7/0x100 net/socket.c:656
sock_write_iter+0x20f/0x360 net/socket.c:925
call_write_iter include/linux/fs.h:1788 [inline]
new_sync_write fs/read_write.c:471 [inline]
__vfs_write+0x401/0x5a0 fs/read_write.c:484
vfs_write+0x17f/0x4d0 fs/read_write.c:546
SYSC_write fs/read_write.c:594 [inline]
SyS_write+0x102/0x250 fs/read_write.c:586
do_syscall_64+0x19b/0x520 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x459829
RSP: 002b:00007fc16e9f6c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000459829
RDX: 000000000000ffdc RSI: 0000000020000200 RDI: 0000000000000004
RBP: 000000000075bfc8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fc16e9f76d4
R13: 00000000004c995e R14: 00000000004e0fc8 R15: 00000000ffffffff

Allocated by task 7905:
save_stack mm/kasan/common.c:76 [inline]
set_track mm/kasan/common.c:85 [inline]
__kasan_kmalloc.part.0+0x53/0xc0 mm/kasan/common.c:495
slab_post_alloc_hook mm/slab.h:439 [inline]
slab_alloc_node mm/slub.c:2758 [inline]
slab_alloc mm/slub.c:2766 [inline]
kmem_cache_alloc+0xd2/0x2e0 mm/slub.c:2771
dst_alloc+0xe6/0x1a0 net/core/dst.c:107
__ip6_dst_alloc+0x2e/0x50 net/ipv6/route.c:355
ip6_rt_pcpu_alloc net/ipv6/route.c:1034 [inline]
rt6_make_pcpu_route net/ipv6/route.c:1064 [inline]
ip6_pol_route+0xfed/0x26d0 net/ipv6/route.c:1189
fib6_rule_lookup+0x1e9/0x420 net/ipv6/fib6_rules.c:87
ip6_route_output include/net/ip6_route.h:81 [inline]
ip6_dst_lookup_tail+0xdab/0x16f0 net/ipv6/ip6_output.c:975
ip6_dst_lookup_flow+0xac/0x210 net/ipv6/ip6_output.c:1098
tcp_v6_connect+0xd30/0x1a70 net/ipv6/tcp_ipv6.c:255
__inet_stream_connect+0x6c0/0xbb0 net/ipv4/af_inet.c:616
tcp_sendmsg_fastopen net/ipv4/tcp.c:1153 [inline]
tcp_sendmsg_locked+0x21c7/0x31e0 net/ipv4/tcp.c:1199
tcp_sendmsg+0x2b/0x40 net/ipv4/tcp.c:1446
inet_sendmsg+0x15b/0x520 net/ipv4/af_inet.c:760
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xb7/0x100 net/socket.c:656
SYSC_sendto net/socket.c:1763 [inline]
SyS_sendto+0x1de/0x2f0 net/socket.c:1731
do_syscall_64+0x19b/0x520 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7
0xffffffffffffffff

Freed by task 9136:
save_stack mm/kasan/common.c:76 [inline]
set_track mm/kasan/common.c:85 [inline]
__kasan_slab_free+0x164/0x210 mm/kasan/common.c:457
slab_free_hook mm/slub.c:1403 [inline]
slab_free_freelist_hook mm/slub.c:1430 [inline]
slab_free mm/slub.c:3005 [inline]
kmem_cache_free+0xcb/0x340 mm/slub.c:3021
dst_destroy+0x1cc/0x2d0 net/core/dst.c:138
__rcu_reclaim kernel/rcu/rcu.h:195 [inline]
rcu_do_batch kernel/rcu/tree.c:2699 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:2962 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2929 [inline]
rcu_process_callbacks+0x59f/0xf60 kernel/rcu/tree.c:2946
__do_softirq+0x234/0x9ec kernel/softirq.c:288

The buggy address belongs to the object at ffff8881d0acbdc0
which belongs to the cache ip6_dst_cache of size 384
The buggy address is located 344 bytes inside of
384-byte region [ffff8881d0acbdc0, ffff8881d0acbf40)
The buggy address belongs to the page:
page:ffffea000742b280 count:1 mapcount:0 mapping: (null)
index:0xffff8881d0acbc00 compound_mapcount: 0
flags: 0x4000000000010200(slab|head)
raw: 4000000000010200 0000000000000000 ffff8881d0acbc00 0000000180120011
raw: ffffea000704e500 0000000d0000000d ffff8881d1422a00 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8881d0acbe00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8881d0acbe80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff8881d0acbf00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff8881d0acbf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8881d0acc000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================
binder: undelivered TRANSACTION_ERROR: 29201
binder: 9139:9148 Acquire 1 refcount change on invalid ref 3 ret -22
binder: 9139:9141 Acquire 1 refcount change on invalid ref 0 ret -22
netlink: 8 bytes leftover after parsing attributes in process
`syz-executor.2'.
binder: 9139:9148 got reply transaction with no transaction stack
SELinux: unrecognized netlink message: protocol=0 nlmsg_type=0
sclass=netlink_route_socket pig=9163 comm=syz-executor.2
binder: 9139:9148 transaction failed 29201/-71, size 0-0 line 3036
audit: type=1400 audit(1566106390.913:53): avc: denied { getattr } for
pid=6523 comm="syz-executor.3"
path="/root/syzkaller-testdir073528355/syzkaller.HWYgm5/49/bus" dev="sda1"
ino=17057 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=system_u:object_r:lvm_control_t:s0 tclass=file permissive=1
binder: undelivered TRANSACTION_ERROR: 29201


---
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,
Oct 7, 2019, 4:21:07 AM10/7/19
to syzkaller-a...@googlegroups.com
syzbot has found a reproducer for the following crash on:

HEAD commit: 9674240f Merge 4.14.147 into android-4.14
git tree: android-4.14
console output: https://syzkaller.appspot.com/x/log.txt?x=14894e63600000
kernel config: https://syzkaller.appspot.com/x/.config?x=5c9951899591bd6e
dashboard link: https://syzkaller.appspot.com/bug?extid=f80f56cb7b8d07aa3c40
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=143ecdb7600000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10adeb0b600000

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

hrtimer: interrupt took 36333 ns
==================================================================
BUG: KASAN: use-after-free in ip6_dst_idev include/net/ip6_fib.h:147
[inline]
BUG: KASAN: use-after-free in ip6_fragment+0x2d4a/0x2f30
net/ipv6/ip6_output.c:768
Read of size 8 at addr ffff8881c57c7118 by task syz-executor742/2396

CPU: 1 PID: 2396 Comm: syz-executor742 Not tainted 4.14.147+ #0
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0xca/0x134 lib/dump_stack.c:53
print_address_description+0x60/0x226 mm/kasan/report.c:187
__kasan_report.cold+0x1a/0x41 mm/kasan/report.c:316
ip6_dst_idev include/net/ip6_fib.h:147 [inline]
ip6_fragment+0x2d4a/0x2f30 net/ipv6/ip6_output.c:768
ip6_finish_output+0x66d/0xb40 net/ipv6/ip6_output.c:152
NF_HOOK_COND include/linux/netfilter.h:239 [inline]
ip6_output+0x1dc/0x680 net/ipv6/ip6_output.c:171
dst_output include/net/dst.h:462 [inline]
ip6_local_out+0x98/0x170 net/ipv6/output_core.c:178
ip6_send_skb+0x9b/0x2f0 net/ipv6/ip6_output.c:1688
udp_v6_send_skb+0x4e2/0xe80 net/ipv6/udp.c:1081
udp_v6_push_pending_frames+0x224/0x330 net/ipv6/udp.c:1114
udpv6_sendmsg+0x194b/0x2500 net/ipv6/udp.c:1380
inet_sendmsg+0x15b/0x520 net/ipv4/af_inet.c:760
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xb7/0x100 net/socket.c:656
SYSC_sendto net/socket.c:1763 [inline]
SyS_sendto+0x1de/0x2f0 net/socket.c:1731
do_syscall_64+0x19b/0x520 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x447c79
RSP: 002b:00007f983ea1bda8 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
RAX: ffffffffffffffda RBX: 00000000006ddc28 RCX: 0000000000447c79
RDX: 000000000000ffb3 RSI: 00000000200003c0 RDI: 0000000000000004
RBP: 00000000006ddc20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000004000000 R11: 0000000000000246 R12: 00000000006ddc2c
R13: 00007ffca1d278ff R14: 00007f983ea1c9c0 R15: 00000000006ddc2c

Allocated by task 2396:
save_stack mm/kasan/common.c:76 [inline]
set_track mm/kasan/common.c:85 [inline]
__kasan_kmalloc.part.0+0x53/0xc0 mm/kasan/common.c:501
slab_post_alloc_hook mm/slab.h:439 [inline]
slab_alloc_node mm/slub.c:2792 [inline]
slab_alloc mm/slub.c:2800 [inline]
kmem_cache_alloc+0xee/0x360 mm/slub.c:2805
dst_alloc+0xe6/0x1a0 net/core/dst.c:107
__ip6_dst_alloc+0x2e/0x50 net/ipv6/route.c:355
ip6_rt_pcpu_alloc net/ipv6/route.c:1034 [inline]
rt6_make_pcpu_route net/ipv6/route.c:1064 [inline]
ip6_pol_route+0xfed/0x26d0 net/ipv6/route.c:1189
fib6_rule_lookup+0xdb/0x420 net/ipv6/fib6_rules.c:83
ip6_route_output include/net/ip6_route.h:81 [inline]
ip6_dst_lookup_tail+0xdab/0x16f0 net/ipv6/ip6_output.c:975
ip6_dst_lookup_flow+0xac/0x210 net/ipv6/ip6_output.c:1098
ip6_sk_dst_lookup_flow+0x397/0x540 net/ipv6/ip6_output.c:1129
udpv6_sendmsg+0x1833/0x2500 net/ipv6/udp.c:1329
inet_sendmsg+0x15b/0x520 net/ipv4/af_inet.c:760
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xb7/0x100 net/socket.c:656
SYSC_sendto net/socket.c:1763 [inline]
SyS_sendto+0x1de/0x2f0 net/socket.c:1731
do_syscall_64+0x19b/0x520 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7
0xffffffffffffffff

Freed by task 7:
save_stack mm/kasan/common.c:76 [inline]
set_track mm/kasan/common.c:85 [inline]
__kasan_slab_free+0x164/0x210 mm/kasan/common.c:463
slab_free_hook mm/slub.c:1407 [inline]
slab_free_freelist_hook mm/slub.c:1458 [inline]
slab_free mm/slub.c:3039 [inline]
kmem_cache_free+0xd7/0x3b0 mm/slub.c:3055
dst_destroy+0x1cc/0x2d0 net/core/dst.c:138
__rcu_reclaim kernel/rcu/rcu.h:195 [inline]
rcu_do_batch kernel/rcu/tree.c:2699 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:2962 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2929 [inline]
rcu_process_callbacks+0x59f/0xf60 kernel/rcu/tree.c:2946
__do_softirq+0x234/0x9ec kernel/softirq.c:288

The buggy address belongs to the object at ffff8881c57c6fc0
which belongs to the cache ip6_dst_cache of size 384
The buggy address is located 344 bytes inside of
384-byte region [ffff8881c57c6fc0, ffff8881c57c7140)
The buggy address belongs to the page:
page:ffffea000715f180 count:1 mapcount:0 mapping: (null) index:0x0
compound_mapcount: 0
flags: 0x4000000000010200(slab|head)
raw: 4000000000010200 0000000000000000 0000000000000000 0000000180120012
raw: dead000000000100 dead000000000200 ffff8881d1947c00 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8881c57c7000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8881c57c7080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff8881c57c7100: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff8881c57c7180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8881c57c7200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Reply all
Reply to author
Forward
0 new messages