KASAN: use-after-free Read in u32_destroy_key

11 views
Skip to first unread message

syzbot

unread,
Jun 8, 2020, 9:13:13 PM6/8/20
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: c6db52a8 Linux 4.14.183
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=13ee6dfe100000
kernel config: https://syzkaller.appspot.com/x/.config?x=98bbe4d18401ff4
dashboard link: https://syzkaller.appspot.com/bug?extid=4effaa8c391c52e99ecd
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+4effaa...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in u32_destroy_key.constprop.0+0x1a7/0x1e0 net/sched/cls_u32.c:405
Read of size 4 at addr ffff8880953f8b98 by task kworker/u4:3/234

CPU: 0 PID: 234 Comm: kworker/u4:3 Not tainted 4.14.183-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: tc_filter_workqueue u32_delete_key_freepf_work
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x283 lib/dump_stack.c:58
print_address_description.cold+0x54/0x1dc mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report mm/kasan/report.c:409 [inline]
kasan_report.cold+0xa9/0x2b9 mm/kasan/report.c:393
u32_destroy_key.constprop.0+0x1a7/0x1e0 net/sched/cls_u32.c:405
u32_delete_key_freepf_work+0x1c/0x22 net/sched/cls_u32.c:456
process_one_work+0x7c0/0x14c0 kernel/workqueue.c:2116
worker_thread+0x5d7/0x1080 kernel/workqueue.c:2250
kthread+0x30d/0x420 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

Allocated by task 5023:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc.part.0+0x4f/0xd0 mm/kasan/kasan.c:551
kmem_cache_alloc_trace+0x14d/0x3f0 mm/slab.c:3618
kmalloc include/linux/slab.h:488 [inline]
kzalloc include/linux/slab.h:661 [inline]
u32_init+0x3e9/0x890 net/sched/cls_u32.c:367
tcf_proto_create net/sched/cls_api.c:166 [inline]
tc_ctl_tfilter+0xa68/0x18e7 net/sched/cls_api.c:677
rtnetlink_rcv_msg+0x3be/0xb10 net/core/rtnetlink.c:4315
netlink_rcv_skb+0x127/0x370 net/netlink/af_netlink.c:2433
netlink_unicast_kernel net/netlink/af_netlink.c:1287 [inline]
netlink_unicast+0x437/0x610 net/netlink/af_netlink.c:1313
netlink_sendmsg+0x64a/0xbb0 net/netlink/af_netlink.c:1878
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xb5/0x100 net/socket.c:656
___sys_sendmsg+0x349/0x840 net/socket.c:2062
__sys_sendmmsg+0x129/0x330 net/socket.c:2152
SYSC_sendmmsg net/socket.c:2183 [inline]
SyS_sendmmsg+0x2f/0x50 net/socket.c:2178
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

Freed by task 234:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xaf/0x190 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xcb/0x260 mm/slab.c:3815
u32_destroy_key.constprop.0+0x108/0x1e0 net/sched/cls_u32.c:406
u32_delete_key_freepf_work+0x1c/0x22 net/sched/cls_u32.c:456
process_one_work+0x7c0/0x14c0 kernel/workqueue.c:2116
worker_thread+0x5d7/0x1080 kernel/workqueue.c:2250
kthread+0x30d/0x420 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

The buggy address belongs to the object at ffff8880953f8b80
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 24 bytes inside of
64-byte region [ffff8880953f8b80, ffff8880953f8bc0)
The buggy address belongs to the page:
page:ffffea000254fe00 count:1 mapcount:0 mapping:ffff8880953f8000 index:0xffff8880953f8c00
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffff8880953f8000 ffff8880953f8c00 0000000100000017
raw: ffffea000240a9a0 ffffea000241b620 ffff8880aa800340 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880953f8a80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff8880953f8b00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8880953f8b80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff8880953f8c00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff8880953f8c80: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc
==================================================================
minix_free_inode: bit 1 already cleared


---
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,
Jun 8, 2020, 10:05:15 PM6/8/20
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following crash on:

HEAD commit: c6db52a8 Linux 4.14.183
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=173e23ca100000
kernel config: https://syzkaller.appspot.com/x/.config?x=98bbe4d18401ff4
dashboard link: https://syzkaller.appspot.com/bug?extid=4effaa8c391c52e99ecd
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=106c7d6a100000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13822e46100000

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

audit: type=1400 audit(1591668159.693:8): avc: denied { execmem } for pid=6331 comm="syz-executor215" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=process permissive=1
IPVS: ftp: loaded support on port[0] = 21
==================================================================
BUG: KASAN: use-after-free in u32_destroy_key.constprop.0+0x1a7/0x1e0 net/sched/cls_u32.c:405
Read of size 4 at addr ffff88809a949d98 by task kworker/u4:2/121

CPU: 1 PID: 121 Comm: kworker/u4:2 Not tainted 4.14.183-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: tc_filter_workqueue u32_delete_key_freepf_work
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x283 lib/dump_stack.c:58
print_address_description.cold+0x54/0x1dc mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report mm/kasan/report.c:409 [inline]
kasan_report.cold+0xa9/0x2b9 mm/kasan/report.c:393
u32_destroy_key.constprop.0+0x1a7/0x1e0 net/sched/cls_u32.c:405
u32_delete_key_freepf_work+0x1c/0x22 net/sched/cls_u32.c:456
process_one_work+0x7c0/0x14c0 kernel/workqueue.c:2116
worker_thread+0x5d7/0x1080 kernel/workqueue.c:2250
kthread+0x30d/0x420 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

Allocated by task 6353:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc.part.0+0x4f/0xd0 mm/kasan/kasan.c:551
kmem_cache_alloc_trace+0x14d/0x3f0 mm/slab.c:3618
kmalloc include/linux/slab.h:488 [inline]
kzalloc include/linux/slab.h:661 [inline]
u32_init+0x3e9/0x890 net/sched/cls_u32.c:367
tcf_proto_create net/sched/cls_api.c:166 [inline]
tc_ctl_tfilter+0xa68/0x18e7 net/sched/cls_api.c:677
rtnetlink_rcv_msg+0x3be/0xb10 net/core/rtnetlink.c:4315
netlink_rcv_skb+0x127/0x370 net/netlink/af_netlink.c:2433
netlink_unicast_kernel net/netlink/af_netlink.c:1287 [inline]
netlink_unicast+0x437/0x610 net/netlink/af_netlink.c:1313
netlink_sendmsg+0x64a/0xbb0 net/netlink/af_netlink.c:1878
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xb5/0x100 net/socket.c:656
___sys_sendmsg+0x349/0x840 net/socket.c:2062
__sys_sendmmsg+0x129/0x330 net/socket.c:2152
SYSC_sendmmsg net/socket.c:2183 [inline]
SyS_sendmmsg+0x2f/0x50 net/socket.c:2178
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

Freed by task 121:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xaf/0x190 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xcb/0x260 mm/slab.c:3815
u32_destroy_key.constprop.0+0x108/0x1e0 net/sched/cls_u32.c:406
u32_delete_key_freepf_work+0x1c/0x22 net/sched/cls_u32.c:456
process_one_work+0x7c0/0x14c0 kernel/workqueue.c:2116
worker_thread+0x5d7/0x1080 kernel/workqueue.c:2250
kthread+0x30d/0x420 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

The buggy address belongs to the object at ffff88809a949d80
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 24 bytes inside of
64-byte region [ffff88809a949d80, ffff88809a949dc0)
The buggy address belongs to the page:
page:ffffea00026a5240 count:1 mapcount:0 mapping:ffff88809a949000 index:0x0
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffff88809a949000 0000000000000000 0000000100000020
raw: ffffea00026a0a20 ffffea00026818a0 ffff8880aa800340 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88809a949c80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88809a949d00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88809a949d80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff88809a949e00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88809a949e80: 00 00 00 00 00 00 00 06 fc fc fc fc fc fc fc fc
==================================================================

Reply all
Reply to author
Forward
0 new messages