KASAN: use-after-free Read in gc_data_segment

9 views
Skip to first unread message

syzbot

unread,
Oct 20, 2022, 12:52:38 PM10/20/22
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 2498b03977b3 Merge 5.10.149 into android12-5.10-lts
git tree: android12-5.10-lts
console+strace: https://syzkaller.appspot.com/x/log.txt?x=1638c4c2880000
kernel config: https://syzkaller.appspot.com/x/.config?x=585a67b78cadff5
dashboard link: https://syzkaller.appspot.com/bug?extid=c8b84be29c6dc2a40ca9
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1781b8d6880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14bed1b4880000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/febf235a7456/disk-2498b039.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/890382714d4b/vmlinux-2498b039.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/0e06e1192c6e/mount_0.gz

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

==================================================================
BUG: KASAN: use-after-free in data_blkaddr fs/f2fs/f2fs.h:2782 [inline]
BUG: KASAN: use-after-free in is_alive fs/f2fs/gc.c:1029 [inline]
BUG: KASAN: use-after-free in gc_data_segment+0x29fd/0x3040 fs/f2fs/gc.c:1448
Read of size 4 at addr ffff88811b6ca150 by task kworker/u4:2/177

CPU: 1 PID: 177 Comm: kworker/u4:2 Not tainted 5.10.149-syzkaller-01403-g2498b03977b3 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022
Workqueue: writeback wb_workfn (flush-7:0)
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
print_address_description+0x81/0x3c0 mm/kasan/report.c:233
__kasan_report mm/kasan/report.c:419 [inline]
kasan_report+0x1a4/0x1f0 mm/kasan/report.c:436
__asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:308
data_blkaddr fs/f2fs/f2fs.h:2782 [inline]
is_alive fs/f2fs/gc.c:1029 [inline]
gc_data_segment+0x29fd/0x3040 fs/f2fs/gc.c:1448
do_garbage_collect+0xd3a/0x1de0 fs/f2fs/gc.c:1652
f2fs_gc+0x89e/0x19c0 fs/f2fs/gc.c:1745
f2fs_balance_fs+0x339/0x3e0 fs/f2fs/segment.c:528
f2fs_write_inode+0x66f/0x720 fs/f2fs/inode.c:720
write_inode+0xf8/0x2a0 fs/fs-writeback.c:1326
__writeback_single_inode+0x37a/0x6e0 fs/fs-writeback.c:1524
writeback_sb_inodes+0x999/0x1700 fs/fs-writeback.c:1730
wb_writeback+0x42f/0xc20 fs/fs-writeback.c:1905
wb_do_writeback+0x222/0xbd0 fs/fs-writeback.c:2050
wb_workfn+0xf8/0x3f0 fs/fs-writeback.c:2091
process_one_work+0x726/0xc10 kernel/workqueue.c:2296
worker_thread+0xb27/0x1550 kernel/workqueue.c:2442
kthread+0x349/0x3d0 kernel/kthread.c:313
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:299

Allocated by task 0:
(stack is not available)

Freed by task 312:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4c/0x80 mm/kasan/common.c:46
kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:357
____kasan_slab_free+0x121/0x160 mm/kasan/common.c:360
__kasan_slab_free+0x11/0x20 mm/kasan/common.c:368
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:1604 [inline]
slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1630
slab_free mm/slub.c:3212 [inline]
kfree+0xc3/0x290 mm/slub.c:4200
skb_free_head net/core/skbuff.c:605 [inline]
skb_release_data+0x52c/0x630 net/core/skbuff.c:625
skb_release_all net/core/skbuff.c:680 [inline]
__kfree_skb+0x59/0x1c0 net/core/skbuff.c:694
kfree_skb_partial+0x40/0x50 net/core/skbuff.c:5162
tcp_rcv_established+0x1196/0x1a10 net/ipv4/tcp_input.c:5907
tcp_v4_do_rcv+0x3cc/0x7c0 net/ipv4/tcp_ipv4.c:1684
tcp_v4_rcv+0x23c4/0x2960 net/ipv4/tcp_ipv4.c:2069
ip_protocol_deliver_rcu+0x2ed/0x650 net/ipv4/ip_input.c:204
ip_local_deliver_finish net/ipv4/ip_input.c:231 [inline]
NF_HOOK include/linux/netfilter.h:304 [inline]
ip_local_deliver+0x2f4/0x5b0 net/ipv4/ip_input.c:252
dst_input include/net/dst.h:449 [inline]
ip_sublist_rcv_finish net/ipv4/ip_input.c:550 [inline]
ip_list_rcv_finish net/ipv4/ip_input.c:600 [inline]
ip_sublist_rcv+0x7cb/0x970 net/ipv4/ip_input.c:608
ip_list_rcv+0x443/0x490 net/ipv4/ip_input.c:643
__netif_receive_skb_list_ptype net/core/dev.c:5409 [inline]
__netif_receive_skb_list_core+0x71e/0x930 net/core/dev.c:5457
__netif_receive_skb_list+0x4b1/0x580 net/core/dev.c:5509
netif_receive_skb_list_internal+0x4ce/0x790 net/core/dev.c:5619
gro_normal_list net/core/dev.c:5773 [inline]
napi_complete_done+0x33f/0x760 net/core/dev.c:6521
virtqueue_napi_complete drivers/net/virtio_net.c:357 [inline]
virtnet_poll+0xb53/0x1200 drivers/net/virtio_net.c:1530
napi_poll+0x1a3/0x650 net/core/dev.c:6837
net_rx_action+0x387/0x970 net/core/dev.c:6907
__do_softirq+0x27e/0x596 kernel/softirq.c:305

The buggy address belongs to the object at ffff88811b6ca000
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 336 bytes inside of
1024-byte region [ffff88811b6ca000, ffff88811b6ca400)
The buggy address belongs to the page:
page:ffffea00046db200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11b6c8
head:ffffea00046db200 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 dead000000000100 dead000000000122 ffff888100042f00
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd2a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 312, ts 15798497982, free_ts 0
set_page_owner include/linux/page_owner.h:35 [inline]
post_alloc_hook mm/page_alloc.c:2386 [inline]
prep_new_page mm/page_alloc.c:2392 [inline]
get_page_from_freelist+0x755/0x810 mm/page_alloc.c:4073
__alloc_pages_nodemask+0x3b6/0x890 mm/page_alloc.c:5160
alloc_slab_page mm/slub.c:1815 [inline]
allocate_slab+0x78/0x540 mm/slub.c:1817
new_slab mm/slub.c:1878 [inline]
new_slab_objects mm/slub.c:2636 [inline]
___slab_alloc+0x131/0x2e0 mm/slub.c:2800
__slab_alloc+0x63/0xa0 mm/slub.c:2840
slab_alloc_node mm/slub.c:2922 [inline]
slab_alloc mm/slub.c:2964 [inline]
__kmalloc_track_caller+0x23e/0x350 mm/slub.c:4545
__kmalloc_reserve net/core/skbuff.c:143 [inline]
__alloc_skb+0xbe/0x580 net/core/skbuff.c:211
alloc_skb include/linux/skbuff.h:1101 [inline]
__tcp_send_ack+0x93/0x6c0 net/ipv4/tcp_output.c:3957
tcp_send_ack+0x3a/0x50 net/ipv4/tcp_output.c:3989
tcp_cleanup_rbuf+0x27f/0x5d0 net/ipv4/tcp.c:1591
tcp_recvmsg+0x210e/0x35a0 net/ipv4/tcp.c:2334
inet_recvmsg+0x157/0x500 net/ipv4/af_inet.c:852
sock_recvmsg_nosec net/socket.c:886 [inline]
sock_recvmsg net/socket.c:904 [inline]
sock_read_iter+0x3a7/0x4d0 net/socket.c:977
call_read_iter include/linux/fs.h:1941 [inline]
new_sync_read fs/read_write.c:415 [inline]
vfs_read+0x9e2/0xbf0 fs/read_write.c:496
ksys_read+0x198/0x2c0 fs/read_write.c:634
__do_sys_read fs/read_write.c:644 [inline]
__se_sys_read fs/read_write.c:642 [inline]
__x64_sys_read+0x7b/0x90 fs/read_write.c:642
page_owner free stack trace missing

Memory state around the buggy address:
ffff88811b6ca000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88811b6ca080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88811b6ca100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88811b6ca180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88811b6ca200: 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 can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches
Reply all
Reply to author
Forward
0 new messages