KASAN: use-after-free Read in perf_output_read (3)

8 views
Skip to first unread message

syzbot

unread,
Dec 21, 2021, 7:25:17 AM12/21/21
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 9dfbac0e6b86 Linux 4.14.258
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=178a867eb00000
kernel config: https://syzkaller.appspot.com/x/.config?x=9cac3dc48a267418
dashboard link: https://syzkaller.appspot.com/bug?extid=4d67dcfa33379fc29ebb
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)

Unfortunately, I don't have any reproducer for this issue yet.

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

==================================================================
BUG: KASAN: use-after-free in primary_event_id kernel/events/core.c:1316 [inline]
BUG: KASAN: use-after-free in perf_output_read_group kernel/events/core.c:5897 [inline]
BUG: KASAN: use-after-free in perf_output_read+0x1046/0x1090 kernel/events/core.c:5932
Read of size 8 at addr ffff8880af3487e0 by task syz-executor.4/10062

CPU: 0 PID: 10062 Comm: syz-executor.4 Not tainted 4.14.258-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x281 lib/dump_stack.c:58
print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:351
kasan_report mm/kasan/report.c:409 [inline]
__asan_report_load8_noabort+0x68/0x70 mm/kasan/report.c:430
primary_event_id kernel/events/core.c:1316 [inline]
perf_output_read_group kernel/events/core.c:5897 [inline]
perf_output_read+0x1046/0x1090 kernel/events/core.c:5932
perf_output_sample+0xa28/0x16f0 kernel/events/core.c:5974
__perf_event_output kernel/events/core.c:6287 [inline]
perf_event_output_forward+0xf8/0x1f0 kernel/events/core.c:6300
__perf_event_overflow+0x113/0x310 kernel/events/core.c:7549
perf_swevent_overflow kernel/events/core.c:7625 [inline]
perf_swevent_event+0x299/0x460 kernel/events/core.c:7653
do_perf_sw_event kernel/events/core.c:7766 [inline]
___perf_sw_event+0x2a1/0x480 kernel/events/core.c:7797
__perf_sw_event+0x4f/0x100 kernel/events/core.c:7809
perf_sw_event include/linux/perf_event.h:1046 [inline]
__do_page_fault+0x692/0xad0 arch/x86/mm/fault.c:1483
page_fault+0x25/0x50 arch/x86/entry/entry_64.S:1123
RIP: 0010:copy_user_enhanced_fast_string+0xe/0x20 arch/x86/lib/copy_user_64.S:181
RSP: 0018:ffff888054757a60 EFLAGS: 00050206
RAX: ffffed100a704000 RBX: 0000000000003a43 RCX: 0000000000001acb
RDX: 0000000000003a43 RSI: 0000000020ef4000 RDI: ffff88805381e535
RBP: 0000000020ef2088 R08: 0000000000000001 R09: ffffed100a703fff
R10: ffff88805381ffff R11: 0000000000000000 R12: ffff88805381c5bd
R13: 00007ffffffff000 R14: 0000000020ef5acb R15: ffff888092be4240
copy_user_generic arch/x86/include/asm/uaccess_64.h:37 [inline]
raw_copy_from_user arch/x86/include/asm/uaccess_64.h:55 [inline]
copyin+0x99/0xc0 lib/iov_iter.c:146
_copy_from_iter_full+0x19c/0x760 lib/iov_iter.c:608
copy_from_iter_full include/linux/uio.h:126 [inline]
skb_do_copy_data_nocache include/net/sock.h:1892 [inline]
skb_copy_to_page_nocache include/net/sock.h:1918 [inline]
tcp_sendmsg_locked+0x23fc/0x2ef0 net/ipv4/tcp.c:1360
tcp_sendmsg+0x2b/0x40 net/ipv4/tcp.c:1457
inet_sendmsg+0x11a/0x4e0 net/ipv4/af_inet.c:762
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xb5/0x100 net/socket.c:656
SYSC_sendto net/socket.c:1763 [inline]
SyS_sendto+0x1c7/0x2c0 net/socket.c:1731
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x7f661265fe99
RSP: 002b:00007f6610fd5168 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
RAX: ffffffffffffffda RBX: 00007f6612772f60 RCX: 00007f661265fe99
RDX: ffffffffffffffef RSI: 0000000020d7cfcb RDI: 0000000000000006
RBP: 00007f66126b9ff1 R08: 0000000000000000 R09: 0000000000000053
R10: 0000000000025c42 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd3c3870ff R14: 00007f6610fd5300 R15: 0000000000022000

Allocated by task 7988:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
__do_kmalloc_node mm/slab.c:3682 [inline]
__kmalloc_node_track_caller+0x4c/0x70 mm/slab.c:3696
__kmalloc_reserve net/core/skbuff.c:137 [inline]
__alloc_skb+0x96/0x510 net/core/skbuff.c:205
alloc_skb include/linux/skbuff.h:980 [inline]
kobject_uevent_env+0x882/0xf30 lib/kobject_uevent.c:480
rx_queue_add_kobject net/core/net-sysfs.c:931 [inline]
net_rx_queue_update_kobjects+0xce/0x3e0 net/core/net-sysfs.c:953
register_queue_kobjects net/core/net-sysfs.c:1420 [inline]
netdev_register_kobject+0x26f/0x410 net/core/net-sysfs.c:1631
register_netdevice+0x955/0xe40 net/core/dev.c:7668
macvlan_common_newlink+0xb5a/0x1480 drivers/net/macvlan.c:1436
macvtap_newlink drivers/net/macvtap.c:108 [inline]
macvtap_newlink+0x17b/0x230 drivers/net/macvtap.c:80
rtnl_newlink+0xfab/0x1860 net/core/rtnetlink.c:2728
rtnetlink_rcv_msg+0x3be/0xb10 net/core/rtnetlink.c:4320
netlink_rcv_skb+0x125/0x390 net/netlink/af_netlink.c:2441
netlink_unicast_kernel net/netlink/af_netlink.c:1294 [inline]
netlink_unicast+0x437/0x610 net/netlink/af_netlink.c:1320
netlink_sendmsg+0x638/0xb90 net/netlink/af_netlink.c:1886
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xb5/0x100 net/socket.c:656
SYSC_sendto net/socket.c:1763 [inline]
SyS_sendto+0x1c7/0x2c0 net/socket.c:1731
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

Freed by task 7988:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xc9/0x250 mm/slab.c:3815
skb_free_head net/core/skbuff.c:563 [inline]
skb_release_data+0x5f6/0x820 net/core/skbuff.c:583
skb_release_all net/core/skbuff.c:640 [inline]
__kfree_skb net/core/skbuff.c:654 [inline]
consume_skb+0xe0/0x380 net/core/skbuff.c:714
netlink_broadcast_filtered+0x2ae/0x9e0 net/netlink/af_netlink.c:1496
kobject_uevent_env+0x9c8/0xf30 lib/kobject_uevent.c:496
rx_queue_add_kobject net/core/net-sysfs.c:931 [inline]
net_rx_queue_update_kobjects+0xce/0x3e0 net/core/net-sysfs.c:953
register_queue_kobjects net/core/net-sysfs.c:1420 [inline]
netdev_register_kobject+0x26f/0x410 net/core/net-sysfs.c:1631
register_netdevice+0x955/0xe40 net/core/dev.c:7668
macvlan_common_newlink+0xb5a/0x1480 drivers/net/macvlan.c:1436
macvtap_newlink drivers/net/macvtap.c:108 [inline]
macvtap_newlink+0x17b/0x230 drivers/net/macvtap.c:80
rtnl_newlink+0xfab/0x1860 net/core/rtnetlink.c:2728
rtnetlink_rcv_msg+0x3be/0xb10 net/core/rtnetlink.c:4320
netlink_rcv_skb+0x125/0x390 net/netlink/af_netlink.c:2441
netlink_unicast_kernel net/netlink/af_netlink.c:1294 [inline]
netlink_unicast+0x437/0x610 net/netlink/af_netlink.c:1320
netlink_sendmsg+0x638/0xb90 net/netlink/af_netlink.c:1886
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xb5/0x100 net/socket.c:656
SYSC_sendto net/socket.c:1763 [inline]
SyS_sendto+0x1c7/0x2c0 net/socket.c:1731
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

The buggy address belongs to the object at ffff8880af348780
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 96 bytes inside of
512-byte region [ffff8880af348780, ffff8880af348980)
The buggy address belongs to the page:
page:ffffea0002bcd200 count:1 mapcount:0 mapping:ffff8880af348000 index:0xffff8880af348c80
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffff8880af348000 ffff8880af348c80 0000000100000002
raw: ffffea000252f6e0 ffffea0002bd30e0 ffff88813fe74940 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880af348680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880af348700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880af348780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880af348800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880af348880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This report 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 issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Dec 26, 2021, 4:04:21 PM12/26/21
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 8ee0807eedf3 Linux 4.14.259
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=13e6150db00000
kernel config: https://syzkaller.appspot.com/x/.config?x=cd64d8ac71350686
dashboard link: https://syzkaller.appspot.com/bug?extid=4d67dcfa33379fc29ebb
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1174a81bb00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=158c26edb00000

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

==================================================================
BUG: KASAN: use-after-free in primary_event_id kernel/events/core.c:1316 [inline]
BUG: KASAN: use-after-free in perf_output_read_group kernel/events/core.c:5897 [inline]
BUG: KASAN: use-after-free in perf_output_read+0x1046/0x1090 kernel/events/core.c:5932
Read of size 8 at addr ffff8880b2c8e620 by task syz-executor986/11066

CPU: 0 PID: 11066 Comm: syz-executor986 Not tainted 4.14.259-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x281 lib/dump_stack.c:58
print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:351
kasan_report mm/kasan/report.c:409 [inline]
__asan_report_load8_noabort+0x68/0x70 mm/kasan/report.c:430
primary_event_id kernel/events/core.c:1316 [inline]
perf_output_read_group kernel/events/core.c:5897 [inline]
perf_output_read+0x1046/0x1090 kernel/events/core.c:5932
perf_output_sample+0xa28/0x16f0 kernel/events/core.c:5974
__perf_event_output kernel/events/core.c:6287 [inline]
perf_event_output_forward+0xf8/0x1f0 kernel/events/core.c:6300
__perf_event_overflow+0x113/0x310 kernel/events/core.c:7549
perf_swevent_overflow kernel/events/core.c:7625 [inline]
perf_swevent_event+0x299/0x460 kernel/events/core.c:7653
do_perf_sw_event kernel/events/core.c:7766 [inline]
___perf_sw_event+0x2a1/0x480 kernel/events/core.c:7797
__perf_sw_event+0x4f/0x100 kernel/events/core.c:7809
perf_sw_event include/linux/perf_event.h:1046 [inline]
__do_page_fault+0x692/0xad0 arch/x86/mm/fault.c:1483
page_fault+0x25/0x50 arch/x86/entry/entry_64.S:1123
RIP: 0010:copy_user_enhanced_fast_string+0xe/0x20 arch/x86/lib/copy_user_64.S:181
RSP: 0018:ffff88809bbb7a60 EFLAGS: 00050206
RAX: ffffed1012f4b908 RBX: 0000000000004839 RCX: 0000000000002304
RDX: 0000000000004839 RSI: 0000000020e30000 RDI: ffff888097a5a535
RBP: 0000000020e2dacb R08: 0000000000000001 R09: ffffed1012f4b907
R10: ffff888097a5c838 R11: 0000000000000000 R12: ffff888097a58000
R13: 00007ffffffff000 R14: 0000000020e32304 R15: ffff88809fde41c0
copy_user_generic arch/x86/include/asm/uaccess_64.h:37 [inline]
raw_copy_from_user arch/x86/include/asm/uaccess_64.h:55 [inline]
copyin+0x99/0xc0 lib/iov_iter.c:146
_copy_from_iter_full+0x19c/0x760 lib/iov_iter.c:608
copy_from_iter_full include/linux/uio.h:126 [inline]
skb_do_copy_data_nocache include/net/sock.h:1892 [inline]
skb_copy_to_page_nocache include/net/sock.h:1918 [inline]
tcp_sendmsg_locked+0x23fc/0x2ef0 net/ipv4/tcp.c:1360
tcp_sendmsg+0x2b/0x40 net/ipv4/tcp.c:1457
inet_sendmsg+0x11a/0x4e0 net/ipv4/af_inet.c:762
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xb5/0x100 net/socket.c:656
SYSC_sendto net/socket.c:1763 [inline]
SyS_sendto+0x1c7/0x2c0 net/socket.c:1731
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x7f36db57a4a9
RSP: 002b:00007f36db528308 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
RAX: ffffffffffffffda RBX: 00007f36db6034e8 RCX: 00007f36db57a4a9
RDX: ffffffffffffffef RSI: 0000000020d7cfcb RDI: 0000000000000006
RBP: 00007f36db6034e0 R08: 0000000000000000 R09: 0000000000000053
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f36db5d04a4
R13: 00007ffc8f50974f R14: 00007f36db528400 R15: 0000000000022000

Allocated by task 7994:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
__do_kmalloc_node mm/slab.c:3682 [inline]
__kmalloc_node_track_caller+0x4c/0x70 mm/slab.c:3696
__kmalloc_reserve net/core/skbuff.c:137 [inline]
__alloc_skb+0x96/0x510 net/core/skbuff.c:205
alloc_skb include/linux/skbuff.h:980 [inline]
kobject_uevent_env+0x882/0xf30 lib/kobject_uevent.c:480
netdev_queue_add_kobject net/core/net-sysfs.c:1366 [inline]
netdev_queue_update_kobjects+0x296/0x350 net/core/net-sysfs.c:1383
register_queue_kobjects net/core/net-sysfs.c:1425 [inline]
netdev_register_kobject+0x34a/0x410 net/core/net-sysfs.c:1631
register_netdevice+0x955/0xe40 net/core/dev.c:7668
__ip_tunnel_create+0x338/0x4a0 net/ipv4/ip_tunnel.c:280
ip_tunnel_init_net+0x247/0x4f0 net/ipv4/ip_tunnel.c:1037
ops_init+0xaa/0x3e0 net/core/net_namespace.c:118
setup_net+0x22f/0x530 net/core/net_namespace.c:296
copy_net_ns+0x19b/0x440 net/core/net_namespace.c:420
create_new_namespaces+0x375/0x720 kernel/nsproxy.c:107
unshare_nsproxy_namespaces+0xa1/0x1d0 kernel/nsproxy.c:206
SYSC_unshare kernel/fork.c:2413 [inline]
SyS_unshare+0x308/0x7f0 kernel/fork.c:2363
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

Freed by task 7994:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xc9/0x250 mm/slab.c:3815
skb_free_head net/core/skbuff.c:563 [inline]
skb_release_data+0x5f6/0x820 net/core/skbuff.c:583
skb_release_all net/core/skbuff.c:640 [inline]
__kfree_skb net/core/skbuff.c:654 [inline]
consume_skb+0xe0/0x380 net/core/skbuff.c:714
netlink_broadcast_filtered+0x2ae/0x9e0 net/netlink/af_netlink.c:1496
kobject_uevent_env+0x9c8/0xf30 lib/kobject_uevent.c:496
netdev_queue_add_kobject net/core/net-sysfs.c:1366 [inline]
netdev_queue_update_kobjects+0x296/0x350 net/core/net-sysfs.c:1383
register_queue_kobjects net/core/net-sysfs.c:1425 [inline]
netdev_register_kobject+0x34a/0x410 net/core/net-sysfs.c:1631
register_netdevice+0x955/0xe40 net/core/dev.c:7668
__ip_tunnel_create+0x338/0x4a0 net/ipv4/ip_tunnel.c:280
ip_tunnel_init_net+0x247/0x4f0 net/ipv4/ip_tunnel.c:1037
ops_init+0xaa/0x3e0 net/core/net_namespace.c:118
setup_net+0x22f/0x530 net/core/net_namespace.c:296
copy_net_ns+0x19b/0x440 net/core/net_namespace.c:420
create_new_namespaces+0x375/0x720 kernel/nsproxy.c:107
unshare_nsproxy_namespaces+0xa1/0x1d0 kernel/nsproxy.c:206
SYSC_unshare kernel/fork.c:2413 [inline]
SyS_unshare+0x308/0x7f0 kernel/fork.c:2363
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

The buggy address belongs to the object at ffff8880b2c8e5c0
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 96 bytes inside of
512-byte region [ffff8880b2c8e5c0, ffff8880b2c8e7c0)
The buggy address belongs to the page:
page:ffffea0002cb2380 count:1 mapcount:0 mapping:ffff8880b2c8e0c0 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffff8880b2c8e0c0 0000000000000000 0000000100000006
raw: ffffea0002d4c7e0 ffffea0002cea420 ffff88813fe74940 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880b2c8e500: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff8880b2c8e580: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
>ffff8880b2c8e600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880b2c8e680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880b2c8e700: 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