2024-01-14 10:15:42

by syzbot

[permalink] [raw]
Subject: [syzbot] [btrfs?] KMSAN: uninit-value in bcmp (2)

Hello,

syzbot found the following issue on:

HEAD commit: 610a9b8f49fb Linux 6.7-rc8
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=110b4555e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=e51fe20c3e51ba7f
dashboard link: https://syzkaller.appspot.com/bug?extid=3ce5dea5b1539ff36769
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: i386

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/daced691c987/disk-610a9b8f.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5e37367a7d1e/vmlinux-610a9b8f.xz
kernel image: https://storage.googleapis.com/syzbot-assets/013b65c960ab/bzImage-610a9b8f.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

=====================================================
BUG: KMSAN: uninit-value in memcmp lib/string.c:681 [inline]
BUG: KMSAN: uninit-value in bcmp+0xc3/0x1c0 lib/string.c:713
memcmp lib/string.c:681 [inline]
bcmp+0xc3/0x1c0 lib/string.c:713
sample_repeated_patterns fs/btrfs/compression.c:1298 [inline]
btrfs_compress_heuristic+0x926/0x31f0 fs/btrfs/compression.c:1380
inode_need_compress fs/btrfs/inode.c:804 [inline]
btrfs_run_delalloc_range+0x156c/0x16c0 fs/btrfs/inode.c:2272
writepage_delalloc+0x244/0x6b0 fs/btrfs/extent_io.c:1189
__extent_writepage fs/btrfs/extent_io.c:1440 [inline]
extent_write_cache_pages fs/btrfs/extent_io.c:2108 [inline]
extent_writepages+0x1d22/0x3f20 fs/btrfs/extent_io.c:2230
btrfs_writepages+0x35/0x40 fs/btrfs/inode.c:7836
do_writepages+0x426/0x870 mm/page-writeback.c:2553
filemap_fdatawrite_wbc+0x1d8/0x270 mm/filemap.c:387
start_delalloc_inodes+0x91d/0x1560 fs/btrfs/inode.c:9284
btrfs_start_delalloc_roots+0x874/0xe80 fs/btrfs/inode.c:9361
shrink_delalloc fs/btrfs/space-info.c:649 [inline]
flush_space+0xbd4/0x16c0 fs/btrfs/space-info.c:759
btrfs_async_reclaim_metadata_space+0x76d/0x9c0 fs/btrfs/space-info.c:1089
process_one_work kernel/workqueue.c:2627 [inline]
process_scheduled_works+0x104e/0x1e70 kernel/workqueue.c:2700
worker_thread+0xf45/0x1490 kernel/workqueue.c:2781
kthread+0x3ed/0x540 kernel/kthread.c:388
ret_from_fork+0x66/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:242

Uninit was stored to memory at:
heuristic_collect_sample fs/btrfs/compression.c:1338 [inline]
btrfs_compress_heuristic+0x303/0x31f0 fs/btrfs/compression.c:1378
inode_need_compress fs/btrfs/inode.c:804 [inline]
btrfs_run_delalloc_range+0x156c/0x16c0 fs/btrfs/inode.c:2272
writepage_delalloc+0x244/0x6b0 fs/btrfs/extent_io.c:1189
__extent_writepage fs/btrfs/extent_io.c:1440 [inline]
extent_write_cache_pages fs/btrfs/extent_io.c:2108 [inline]
extent_writepages+0x1d22/0x3f20 fs/btrfs/extent_io.c:2230
btrfs_writepages+0x35/0x40 fs/btrfs/inode.c:7836
do_writepages+0x426/0x870 mm/page-writeback.c:2553
filemap_fdatawrite_wbc+0x1d8/0x270 mm/filemap.c:387
start_delalloc_inodes+0x91d/0x1560 fs/btrfs/inode.c:9284
btrfs_start_delalloc_roots+0x874/0xe80 fs/btrfs/inode.c:9361
shrink_delalloc fs/btrfs/space-info.c:649 [inline]
flush_space+0xbd4/0x16c0 fs/btrfs/space-info.c:759
btrfs_async_reclaim_metadata_space+0x76d/0x9c0 fs/btrfs/space-info.c:1089
process_one_work kernel/workqueue.c:2627 [inline]
process_scheduled_works+0x104e/0x1e70 kernel/workqueue.c:2700
worker_thread+0xf45/0x1490 kernel/workqueue.c:2781
kthread+0x3ed/0x540 kernel/kthread.c:388
ret_from_fork+0x66/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:242

Uninit was created at:
__alloc_pages+0x9a4/0xe00 mm/page_alloc.c:4591
alloc_pages_mpol+0x62b/0x9d0 mm/mempolicy.c:2133
alloc_pages mm/mempolicy.c:2204 [inline]
folio_alloc+0x1da/0x380 mm/mempolicy.c:2211
filemap_alloc_folio+0xa5/0x430 mm/filemap.c:974
__filemap_get_folio+0xa5a/0x1760 mm/filemap.c:1918
pagecache_get_page+0x4a/0x1a0 mm/folio-compat.c:99
prepare_pages+0x1f2/0x1050 fs/btrfs/file.c:922
btrfs_buffered_write+0xe48/0x2be0 fs/btrfs/file.c:1316
btrfs_do_write_iter+0x370/0x2300 fs/btrfs/file.c:1687
btrfs_file_write_iter+0x38/0x40 fs/btrfs/file.c:1704
__kernel_write_iter+0x329/0x930 fs/read_write.c:517
dump_emit_page fs/coredump.c:888 [inline]
dump_user_range+0x593/0xcd0 fs/coredump.c:915
elf_core_dump+0x59e8/0x5c60 fs/binfmt_elf.c:2077
do_coredump+0x32c9/0x4920 fs/coredump.c:764
get_signal+0x2185/0x2d10 kernel/signal.c:2890
arch_do_signal_or_restart+0x53/0xca0 arch/x86/kernel/signal.c:309
exit_to_user_mode_loop+0xe8/0x320 kernel/entry/common.c:168
exit_to_user_mode_prepare+0x163/0x220 kernel/entry/common.c:204
irqentry_exit_to_user_mode+0xd/0x30 kernel/entry/common.c:309
irqentry_exit+0x16/0x40 kernel/entry/common.c:412
exc_page_fault+0x246/0x6f0 arch/x86/mm/fault.c:1564
asm_exc_page_fault+0x2b/0x30 arch/x86/include/asm/idtentry.h:570

CPU: 1 PID: 56 Comm: kworker/u4:4 Not tainted 6.7.0-rc8-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
Workqueue: events_unbound btrfs_async_reclaim_metadata_space
=====================================================


---
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 [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup


2024-02-04 11:44:57

by syzbot

[permalink] [raw]
Subject: Re: [syzbot] [btrfs?] KMSAN: uninit-value in bcmp (2)

syzbot has found a reproducer for the following issue on:

HEAD commit: 9f8413c4a66f Merge tag 'cgroup-for-6.8' of git://git.kerne..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=10fcfdc0180000
kernel config: https://syzkaller.appspot.com/x/.config?x=656820e61b758b15
dashboard link: https://syzkaller.appspot.com/bug?extid=3ce5dea5b1539ff36769
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=139dd53fe80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12685aa8180000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/79d9f2f4b065/disk-9f8413c4.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/cbc68430d9c6/vmlinux-9f8413c4.xz
kernel image: https://storage.googleapis.com/syzbot-assets/9740ad9fc172/bzImage-9f8413c4.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/25f4008bd752/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

=====================================================
BUG: KMSAN: uninit-value in memcmp lib/string.c:692 [inline]
BUG: KMSAN: uninit-value in bcmp+0x186/0x1c0 lib/string.c:713
memcmp lib/string.c:692 [inline]
bcmp+0x186/0x1c0 lib/string.c:713
fanotify_fh_equal fs/notify/fanotify/fanotify.c:51 [inline]
fanotify_fid_event_equal fs/notify/fanotify/fanotify.c:72 [inline]
fanotify_should_merge fs/notify/fanotify/fanotify.c:168 [inline]
fanotify_merge+0x15f5/0x27e0 fs/notify/fanotify/fanotify.c:209
fsnotify_insert_event+0x1d0/0x600 fs/notify/notification.c:113
fanotify_handle_event+0x47f7/0x6140 fs/notify/fanotify/fanotify.c:966
send_to_group fs/notify/fsnotify.c:360 [inline]
fsnotify+0x2510/0x3530 fs/notify/fsnotify.c:570
fsnotify_parent include/linux/fsnotify.h:80 [inline]
fsnotify_file include/linux/fsnotify.h:100 [inline]
fsnotify_close include/linux/fsnotify.h:362 [inline]
__fput+0x578/0x10c0 fs/file_table.c:368
__fput_sync+0x74/0x90 fs/file_table.c:467
__do_sys_close fs/open.c:1554 [inline]
__se_sys_close+0x28a/0x4c0 fs/open.c:1539
__x64_sys_close+0x48/0x60 fs/open.c:1539
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x6d/0x140 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b

Uninit was created at:
slab_post_alloc_hook+0x129/0xa70 mm/slab.h:768
slab_alloc_node mm/slub.c:3478 [inline]
slab_alloc mm/slub.c:3486 [inline]
__kmem_cache_alloc_lru mm/slub.c:3493 [inline]
kmem_cache_alloc+0x579/0xa90 mm/slub.c:3502
fanotify_alloc_fid_event fs/notify/fanotify/fanotify.c:584 [inline]
fanotify_alloc_event fs/notify/fanotify/fanotify.c:817 [inline]
fanotify_handle_event+0x2ff6/0x6140 fs/notify/fanotify/fanotify.c:952
send_to_group fs/notify/fsnotify.c:360 [inline]
fsnotify+0x2510/0x3530 fs/notify/fsnotify.c:570
fsnotify_parent include/linux/fsnotify.h:80 [inline]
fsnotify_file include/linux/fsnotify.h:100 [inline]
fsnotify_close include/linux/fsnotify.h:362 [inline]
__fput+0x578/0x10c0 fs/file_table.c:368
__fput_sync+0x74/0x90 fs/file_table.c:467
__do_sys_close fs/open.c:1554 [inline]
__se_sys_close+0x28a/0x4c0 fs/open.c:1539
__x64_sys_close+0x48/0x60 fs/open.c:1539
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x6d/0x140 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b

CPU: 0 PID: 5010 Comm: syz-executor120 Not tainted 6.7.0-syzkaller-00562-g9f8413c4a66f #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
=====================================================


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

2024-02-05 12:18:13

by Jan Kara

[permalink] [raw]
Subject: Re: [syzbot] [btrfs?] KMSAN: uninit-value in bcmp (2)

On Sun 04-02-24 03:44:30, syzbot wrote:
> syzbot has found a reproducer for the following issue on:
>
> HEAD commit: 9f8413c4a66f Merge tag 'cgroup-for-6.8' of git://git.kerne..
> git tree: upstream
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=10fcfdc0180000
> kernel config: https://syzkaller.appspot.com/x/.config?x=656820e61b758b15
> dashboard link: https://syzkaller.appspot.com/bug?extid=3ce5dea5b1539ff36769
> compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=139dd53fe80000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12685aa8180000
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/79d9f2f4b065/disk-9f8413c4.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/cbc68430d9c6/vmlinux-9f8413c4.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/9740ad9fc172/bzImage-9f8413c4.xz
> mounted in repro: https://storage.googleapis.com/syzbot-assets/25f4008bd752/mount_0.gz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email protected]
>
> =====================================================
> BUG: KMSAN: uninit-value in memcmp lib/string.c:692 [inline]
> BUG: KMSAN: uninit-value in bcmp+0x186/0x1c0 lib/string.c:713
> memcmp lib/string.c:692 [inline]
> bcmp+0x186/0x1c0 lib/string.c:713
> fanotify_fh_equal fs/notify/fanotify/fanotify.c:51 [inline]

So I'm not sure how this is possible. In fanotify_encode_fh() we have:

dwords = fh_len >> 2;
type = exportfs_encode_fid(inode, buf, &dwords);
err = -EINVAL;
if (type <= 0 || type == FILEID_INVALID || fh_len != dwords << 2)
goto out_err;

fh->type = type;
fh->len = fh_len;

So if the encoded file handle was different length than what we expected we
will fail the creation of the event...

Aha, the FAT filesystem is mounted in nfs=nostale_ro which means that we're
using fat_export_ops_nostale and thus fat_encode_fh_nostale for encoding
fh. And FAT_FID_SIZE_WITHOUT_PARENT is 3 (i.e. 12 bytes) but the function
initializes just the first 10 bytes of struct fat_fid. I'll send a fix for
FAT.

Honza


> fanotify_fid_event_equal fs/notify/fanotify/fanotify.c:72 [inline]
> fanotify_should_merge fs/notify/fanotify/fanotify.c:168 [inline]
> fanotify_merge+0x15f5/0x27e0 fs/notify/fanotify/fanotify.c:209
> fsnotify_insert_event+0x1d0/0x600 fs/notify/notification.c:113
> fanotify_handle_event+0x47f7/0x6140 fs/notify/fanotify/fanotify.c:966
> send_to_group fs/notify/fsnotify.c:360 [inline]
> fsnotify+0x2510/0x3530 fs/notify/fsnotify.c:570
> fsnotify_parent include/linux/fsnotify.h:80 [inline]
> fsnotify_file include/linux/fsnotify.h:100 [inline]
> fsnotify_close include/linux/fsnotify.h:362 [inline]
> __fput+0x578/0x10c0 fs/file_table.c:368
> __fput_sync+0x74/0x90 fs/file_table.c:467
> __do_sys_close fs/open.c:1554 [inline]
> __se_sys_close+0x28a/0x4c0 fs/open.c:1539
> __x64_sys_close+0x48/0x60 fs/open.c:1539
> do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> do_syscall_64+0x6d/0x140 arch/x86/entry/common.c:83
> entry_SYSCALL_64_after_hwframe+0x63/0x6b
>
> Uninit was created at:
> slab_post_alloc_hook+0x129/0xa70 mm/slab.h:768
> slab_alloc_node mm/slub.c:3478 [inline]
> slab_alloc mm/slub.c:3486 [inline]
> __kmem_cache_alloc_lru mm/slub.c:3493 [inline]
> kmem_cache_alloc+0x579/0xa90 mm/slub.c:3502
> fanotify_alloc_fid_event fs/notify/fanotify/fanotify.c:584 [inline]
> fanotify_alloc_event fs/notify/fanotify/fanotify.c:817 [inline]
> fanotify_handle_event+0x2ff6/0x6140 fs/notify/fanotify/fanotify.c:952
> send_to_group fs/notify/fsnotify.c:360 [inline]
> fsnotify+0x2510/0x3530 fs/notify/fsnotify.c:570
> fsnotify_parent include/linux/fsnotify.h:80 [inline]
> fsnotify_file include/linux/fsnotify.h:100 [inline]
> fsnotify_close include/linux/fsnotify.h:362 [inline]
> __fput+0x578/0x10c0 fs/file_table.c:368
> __fput_sync+0x74/0x90 fs/file_table.c:467
> __do_sys_close fs/open.c:1554 [inline]
> __se_sys_close+0x28a/0x4c0 fs/open.c:1539
> __x64_sys_close+0x48/0x60 fs/open.c:1539
> do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> do_syscall_64+0x6d/0x140 arch/x86/entry/common.c:83
> entry_SYSCALL_64_after_hwframe+0x63/0x6b
>
> CPU: 0 PID: 5010 Comm: syz-executor120 Not tainted 6.7.0-syzkaller-00562-g9f8413c4a66f #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
> =====================================================
>
>
> ---
> If you want syzbot to run the reproducer, reply with:
> #syz test: git://repo/address.git branch-or-commit-hash
> If you attach or paste a git patch, syzbot will apply it before testing.
>
--
Jan Kara <[email protected]>
SUSE Labs, CR