syzbot


KASAN: use-after-free Read in LZ4_decompress_safe_partial

Status: fixed on 2023/02/24 13:50
Subsystems: erofs
[Documentation on labels]
Reported-by: syzbot+63d688f1d899c588fb71@syzkaller.appspotmail.com
Fix commit: eafc0a02391b lz4: fix LZ4_decompress_safe_partial read out of bound
First crash: 914d, last: 755d
Cause bisection: introduced by (bisect log) :
commit f86cf25a609107960cf05263e491463feaae1f99
Author: Gao Xiang <gaoxiang25@huawei.com>
Date: Tue Aug 28 03:39:48 2018 +0000

  Revert "staging: erofs: disable compiling temporarile"

Crash: KASAN: use-after-free Write in __d_rehash (log)
Repro: C syz .config
  
Discussions (8)
Title Replies (including bot) Last reply
[PATCH 5.4 000/475] 5.4.189-rc1 review 485 (486) 2022/04/15 15:35
[PATCH 5.17 000/343] 5.17.3-rc1 review 355 (355) 2022/04/13 20:33
[PATCH 5.16 000/285] 5.16.20-rc1 review 294 (294) 2022/04/13 20:17
[PATCH 5.10 000/171] 5.10.111-rc1 review 175 (175) 2022/04/13 01:43
[PATCH 5.15 000/277] 5.15.34-rc1 review 288 (288) 2022/04/12 17:34
[patch 3/9] lz4: fix LZ4_decompress_safe_partial read out of bound 1 (1) 2022/04/08 20:08
[PATCH] lz4: fix LZ4_decompress_safe_partial read out of bound 8 (8) 2022/04/06 00:41
[syzbot] KASAN: use-after-free Read in LZ4_decompress_safe_partial 1 (2) 2021/10/29 15:32
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-6-1 general protection fault in LZ4_decompress_safe_partial origin:lts C done done 2 236d 250d 0/2 auto-obsoleted due to no activity on 2023/12/13 06:02

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in get_unaligned_le16 include/asm-generic/unaligned.h:27 [inline]
BUG: KASAN: use-after-free in LZ4_readLE16 lib/lz4/lz4defs.h:132 [inline]
BUG: KASAN: use-after-free in LZ4_decompress_generic lib/lz4/lz4_decompress.c:285 [inline]
BUG: KASAN: use-after-free in LZ4_decompress_safe_partial+0xff8/0x1580 lib/lz4/lz4_decompress.c:469
Read of size 2 at addr ffff88806dd1f000 by task kworker/u5:0/150

CPU: 1 PID: 150 Comm: kworker/u5:0 Not tainted 5.15.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: erofs_unzipd z_erofs_decompressqueue_work
Call Trace:
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1dc/0x2d8 lib/dump_stack.c:106
 print_address_description+0x66/0x3e0 mm/kasan/report.c:256
 __kasan_report mm/kasan/report.c:442 [inline]
 kasan_report+0x19a/0x1f0 mm/kasan/report.c:459
 get_unaligned_le16 include/asm-generic/unaligned.h:27 [inline]
 LZ4_readLE16 lib/lz4/lz4defs.h:132 [inline]
 LZ4_decompress_generic lib/lz4/lz4_decompress.c:285 [inline]
 LZ4_decompress_safe_partial+0xff8/0x1580 lib/lz4/lz4_decompress.c:469
 z_erofs_lz4_decompress+0x4c3/0x1100 fs/erofs/decompressor.c:226
 z_erofs_decompress_generic fs/erofs/decompressor.c:354 [inline]
 z_erofs_decompress+0xa8e/0xe30 fs/erofs/decompressor.c:407
 z_erofs_decompress_pcluster+0x15e4/0x2550 fs/erofs/zdata.c:977
 z_erofs_decompress_queue fs/erofs/zdata.c:1055 [inline]
 z_erofs_decompressqueue_work+0x123/0x1a0 fs/erofs/zdata.c:1066
 process_one_work+0x853/0x1140 kernel/workqueue.c:2297
 worker_thread+0xac1/0x1320 kernel/workqueue.c:2444
 kthread+0x453/0x480 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30

The buggy address belongs to the page:
page:ffffea0001b747c0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x6dd1f
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 ffffea0001b74408 ffffea0001b74ac8 0000000000000000
raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 0, migratetype Movable, gfp_mask 0x1100dca(GFP_HIGHUSER_MOVABLE|__GFP_ZERO), pid 6527, ts 51734930672, free_ts 51749499849
 prep_new_page mm/page_alloc.c:2424 [inline]
 get_page_from_freelist+0x779/0xa30 mm/page_alloc.c:4153
 __alloc_pages+0x255/0x580 mm/page_alloc.c:5375
 alloc_pages_vma+0x668/0x1030 mm/mempolicy.c:2152
 do_anonymous_page+0x31b/0x14b0 mm/memory.c:3768
 handle_pte_fault mm/memory.c:4557 [inline]
 __handle_mm_fault mm/memory.c:4694 [inline]
 handle_mm_fault+0x1860/0x2560 mm/memory.c:4792
 do_user_addr_fault+0x8ce/0x10c0 arch/x86/mm/fault.c:1397
 handle_page_fault arch/x86/mm/fault.c:1485 [inline]
 exc_page_fault+0xa1/0x1e0 arch/x86/mm/fault.c:1541
 asm_exc_page_fault+0x1e/0x30
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1338 [inline]
 free_pcp_prepare+0xc29/0xd20 mm/page_alloc.c:1389
 free_unref_page_prepare mm/page_alloc.c:3315 [inline]
 free_unref_page_list+0x11f/0xa50 mm/page_alloc.c:3431
 release_pages+0x18cb/0x1b00 mm/swap.c:963
 tlb_batch_pages_flush mm/mmu_gather.c:49 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:242 [inline]
 tlb_flush_mmu+0x780/0x910 mm/mmu_gather.c:249
 tlb_finish_mmu+0xcb/0x200 mm/mmu_gather.c:340
 exit_mmap+0x3dd/0x6f0 mm/mmap.c:3173
 __mmput+0x111/0x3a0 kernel/fork.c:1115
 exec_mmap+0x53e/0x640 fs/exec.c:1030
 begin_new_exec+0x6c9/0x1180 fs/exec.c:1288
 load_elf_binary+0x836/0x3bc0 fs/binfmt_elf.c:1001
 search_binary_handler fs/exec.c:1725 [inline]
 exec_binprm fs/exec.c:1766 [inline]
 bprm_execve+0x8eb/0x1470 fs/exec.c:1835
 do_execveat_common+0x44c/0x590 fs/exec.c:1924
 do_execve fs/exec.c:1992 [inline]
 __do_sys_execve fs/exec.c:2068 [inline]
 __se_sys_execve fs/exec.c:2063 [inline]
 __x64_sys_execve+0x8e/0xa0 fs/exec.c:2063
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae

Memory state around the buggy address:
 ffff88806dd1ef00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88806dd1ef80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88806dd1f000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                   ^
 ffff88806dd1f080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88806dd1f100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (13):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/10/25 14:59 upstream 87066fdd2e30 4f0000ee .config console log report syz C ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in LZ4_decompress_safe_partial
2022/04/02 23:53 upstream 88e6c0207623 79a2a8fc .config console log report syz C ci-upstream-kasan-gce-root KASAN: vmalloc-out-of-bounds Read in LZ4_decompress_safe_partial
2022/04/02 23:03 upstream 88e6c0207623 79a2a8fc .config console log report syz C ci-upstream-kasan-gce-root KASAN: vmalloc-out-of-bounds Read in LZ4_decompress_safe_partial
2021/12/03 02:02 upstream a51e3ac43ddb 61f86278 .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in LZ4_decompress_safe_partial
2021/11/30 08:39 upstream d58071a8a76d d0830353 .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in LZ4_decompress_safe_partial
2021/11/21 07:09 upstream 923dcc5eb0c1 4eb20a4e .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in LZ4_decompress_safe_partial
2021/11/16 05:44 upstream 8ab774587903 83f5c9b5 .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in LZ4_decompress_safe_partial
2021/11/12 03:26 upstream 5833291ab6de 75b04091 .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in LZ4_decompress_safe_partial
2021/11/06 21:31 upstream d4439a1189f9 4c1be0be .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in LZ4_decompress_safe_partial
2021/11/05 21:51 upstream d4439a1189f9 4c1be0be .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in LZ4_decompress_safe_partial
2021/11/05 05:16 upstream 7ddb58cb0eca 4c1be0be .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in LZ4_decompress_safe_partial
2021/10/25 14:44 upstream 87066fdd2e30 4f0000ee .config console log report info ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in LZ4_decompress_safe_partial
2021/10/25 14:45 linux-next 9ae1fbdeabd3 4f0000ee .config console log report info ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in LZ4_decompress_safe_partial
* Struck through repros no longer work on HEAD.