syzbot


KASAN: slab-out-of-bounds Write in shmem_file_read_iter

Status: upstream: reported C repro on 2023/12/14 19:30
Subsystems: hfs mm
[Documentation on labels]
Reported-by: syzbot+3e719fc23ab95580e4c2@syzkaller.appspotmail.com
First crash: 130d, last: 27d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [mm?] [hfs?] KASAN: slab-out-of-bounds Write in shmem_file_read_iter 0 (1) 2023/12/14 19:30
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: slab-out-of-bounds Write in shmem_file_read_iter origin:upstream C 2 17d 78d 0/3 upstream: reported C repro on 2024/02/01 06:28
linux-5.15 KASAN: slab-out-of-bounds Write in shmem_file_read_iter origin:upstream C error 1 76d 76d 0/3 upstream: reported C repro on 2024/02/02 14:56
Last patch testing requests (2)
Created Duration User Patch Repo Result
2024/03/04 03:45 26m retest repro git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci OK log
2023/12/24 22:19 17m retest repro git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci report log

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in memcpy_to_iter lib/iov_iter.c:65 [inline]
BUG: KASAN: slab-out-of-bounds in iterate_bvec include/linux/iov_iter.h:122 [inline]
BUG: KASAN: slab-out-of-bounds in iterate_and_advance2 include/linux/iov_iter.h:249 [inline]
BUG: KASAN: slab-out-of-bounds in iterate_and_advance include/linux/iov_iter.h:271 [inline]
BUG: KASAN: slab-out-of-bounds in _copy_to_iter+0x7d4/0x1cf0 lib/iov_iter.c:185
Write of size 2048 at addr ffff888028fa6000 by task kworker/u8:2/28

CPU: 0 PID: 28 Comm: kworker/u8:2 Not tainted 6.8.0-syzkaller-08951-gfe46a7dd189e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/29/2024
Workqueue: loop0 loop_rootcg_workfn
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 kasan_check_range+0x282/0x290 mm/kasan/generic.c:189
 __asan_memcpy+0x40/0x70 mm/kasan/shadow.c:106
 memcpy_to_iter lib/iov_iter.c:65 [inline]
 iterate_bvec include/linux/iov_iter.h:122 [inline]
 iterate_and_advance2 include/linux/iov_iter.h:249 [inline]
 iterate_and_advance include/linux/iov_iter.h:271 [inline]
 _copy_to_iter+0x7d4/0x1cf0 lib/iov_iter.c:185
 copy_page_to_iter+0xb1/0x160 lib/iov_iter.c:362
 shmem_file_read_iter+0x4cb/0xa50 mm/shmem.c:2872
 do_iter_readv_writev+0x5a4/0x800
 vfs_iter_read+0x152/0x420 fs/read_write.c:830
 lo_read_simple drivers/block/loop.c:286 [inline]
 do_req_filebacked drivers/block/loop.c:496 [inline]
 loop_handle_cmd drivers/block/loop.c:1907 [inline]
 loop_process_work+0xcfb/0x1e60 drivers/block/loop.c:1942
 process_one_work kernel/workqueue.c:3254 [inline]
 process_scheduled_works+0xa00/0x1770 kernel/workqueue.c:3335
 worker_thread+0x86d/0xd70 kernel/workqueue.c:3416
 kthread+0x2f0/0x390 kernel/kthread.c:388
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:243
 </TASK>

Allocated by task 5086:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:370 [inline]
 __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:387
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slub.c:3966 [inline]
 __kmalloc+0x233/0x4a0 mm/slub.c:3979
 kmalloc include/linux/slab.h:632 [inline]
 hfsplus_read_wrapper+0x613/0x1340 fs/hfsplus/wrapper.c:182
 hfsplus_fill_super+0x38e/0x1ca0 fs/hfsplus/super.c:419
 mount_bdev+0x20a/0x2d0 fs/super.c:1658
 legacy_get_tree+0xee/0x190 fs/fs_context.c:662
 vfs_get_tree+0x90/0x2a0 fs/super.c:1779
 do_new_mount+0x2be/0xb40 fs/namespace.c:3352
 do_mount fs/namespace.c:3692 [inline]
 __do_sys_mount fs/namespace.c:3898 [inline]
 __se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3875
 do_syscall_64+0xfb/0x240
 entry_SYSCALL_64_after_hwframe+0x6d/0x75

The buggy address belongs to the object at ffff888028fa6000
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 0 bytes inside of
 allocated 512-byte region [ffff888028fa6000, ffff888028fa6200)

The buggy address belongs to the physical page:
page:ffffea0000a3e900 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x28fa4
head:ffffea0000a3e900 order:2 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888014c41c80 dead000000000100 dead000000000122
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, tgid 1 (swapper/0), ts 25780901845, free_ts 0
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x1ea/0x210 mm/page_alloc.c:1533
 prep_new_page mm/page_alloc.c:1540 [inline]
 get_page_from_freelist+0x33ea/0x3580 mm/page_alloc.c:3311
 __alloc_pages+0x256/0x680 mm/page_alloc.c:4569
 __alloc_pages_node include/linux/gfp.h:238 [inline]
 alloc_pages_node include/linux/gfp.h:261 [inline]
 alloc_slab_page+0x5f/0x160 mm/slub.c:2175
 allocate_slab mm/slub.c:2338 [inline]
 new_slab+0x84/0x2f0 mm/slub.c:2391
 ___slab_alloc+0xc73/0x1260 mm/slub.c:3525
 __slab_alloc mm/slub.c:3610 [inline]
 __slab_alloc_node mm/slub.c:3663 [inline]
 slab_alloc_node mm/slub.c:3835 [inline]
 __do_kmalloc_node mm/slub.c:3965 [inline]
 __kmalloc+0x2e5/0x4a0 mm/slub.c:3979
 kmalloc include/linux/slab.h:632 [inline]
 pkcs1pad_verify+0x10b/0x600 crypto/rsa-pkcs1pad.c:564
 crypto_akcipher_verify include/crypto/akcipher.h:455 [inline]
 crypto_sig_verify+0x211/0x2b0 crypto/sig.c:129
 public_key_verify_signature+0x573/0x790 crypto/asymmetric_keys/public_key.c:441
 x509_check_for_self_signed+0x324/0x420 crypto/asymmetric_keys/x509_public_key.c:138
 x509_cert_parse+0x5b9/0x7c0 crypto/asymmetric_keys/x509_cert_parser.c:133
 x509_key_preparse+0x65/0x680 crypto/asymmetric_keys/x509_public_key.c:171
 asymmetric_key_preparse+0xb5/0x160 crypto/asymmetric_keys/asymmetric_type.c:417
 __key_create_or_update+0x481/0xc70 security/keys/key.c:841
 key_create_or_update+0x42/0x60 security/keys/key.c:1005
page_owner free stack trace missing

Memory state around the buggy address:
 ffff888028fa6100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888028fa6180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888028fa6200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                   ^
 ffff888028fa6280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888028fa6300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/03/22 21:16 upstream fe46a7dd189e 7a239ce7 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-kasan-gce-smack-root KASAN: slab-out-of-bounds Write in shmem_file_read_iter
2024/03/17 00:02 upstream fe46a7dd189e d615901c .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-kasan-gce-root KASAN: slab-out-of-bounds Write in shmem_file_read_iter
2023/12/10 19:26 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci d46efae31672 28b24332 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci-upstream-gce-arm64 KASAN: slab-out-of-bounds Write in shmem_file_read_iter
* Struck through repros no longer work on HEAD.