[syzbot] [hfs?] KMSAN: uninit-value in __hfsplus_ext_cache_extent

10 views
Skip to first unread message

syzbot

unread,
Dec 28, 2023, 5:23:24 AM12/28/23
to linux-...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: fbafc3e621c3 Merge tag 'for_linus' of git://git.kernel.org..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=1770ee26e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=e0c7078a6b901aa3
dashboard link: https://syzkaller.appspot.com/bug?extid=55ad87f38795d6787521
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=17ea9be9e80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=149e8179e80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/1520f7b6daa4/disk-fbafc3e6.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/8b490af009d5/vmlinux-fbafc3e6.xz
kernel image: https://storage.googleapis.com/syzbot-assets/202ca200f4a4/bzImage-fbafc3e6.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/78ed00b58340/mount_0.gz

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

=====================================================
BUG: KMSAN: uninit-value in __hfsplus_ext_read_extent fs/hfsplus/extents.c:167 [inline]
BUG: KMSAN: uninit-value in __hfsplus_ext_cache_extent+0x82a/0x960 fs/hfsplus/extents.c:191
__hfsplus_ext_read_extent fs/hfsplus/extents.c:167 [inline]
__hfsplus_ext_cache_extent+0x82a/0x960 fs/hfsplus/extents.c:191
hfsplus_ext_read_extent fs/hfsplus/extents.c:218 [inline]
hfsplus_file_extend+0x775/0x1b90 fs/hfsplus/extents.c:461
hfsplus_get_block+0xe99/0x1690 fs/hfsplus/extents.c:245
__block_write_begin_int+0x946/0x2c70 fs/buffer.c:2119
__block_write_begin fs/buffer.c:2168 [inline]
block_write_begin+0x143/0x450 fs/buffer.c:2227
cont_write_begin+0xd5c/0x12f0 fs/buffer.c:2582
hfsplus_write_begin+0x9a/0x130 fs/hfsplus/inode.c:52
generic_perform_write+0x3f5/0xc40 mm/filemap.c:3918
__generic_file_write_iter+0x20a/0x460 mm/filemap.c:4013
generic_file_write_iter+0x103/0x5b0 mm/filemap.c:4039
call_write_iter include/linux/fs.h:2020 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x8ef/0x1490 fs/read_write.c:584
ksys_write+0x20f/0x4c0 fs/read_write.c:637
__do_sys_write fs/read_write.c:649 [inline]
__se_sys_write fs/read_write.c:646 [inline]
__x64_sys_write+0x93/0xd0 fs/read_write.c:646
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x44/0x110 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]
__kmem_cache_alloc_node+0x5c9/0x970 mm/slub.c:3517
__do_kmalloc_node mm/slab_common.c:1006 [inline]
__kmalloc+0x121/0x3c0 mm/slab_common.c:1020
kmalloc include/linux/slab.h:604 [inline]
hfsplus_find_init+0x91/0x250 fs/hfsplus/bfind.c:21
hfsplus_ext_read_extent fs/hfsplus/extents.c:216 [inline]
hfsplus_file_extend+0x6d8/0x1b90 fs/hfsplus/extents.c:461
hfsplus_get_block+0xe99/0x1690 fs/hfsplus/extents.c:245
__block_write_begin_int+0x946/0x2c70 fs/buffer.c:2119
__block_write_begin fs/buffer.c:2168 [inline]
block_write_begin+0x143/0x450 fs/buffer.c:2227
cont_write_begin+0xd5c/0x12f0 fs/buffer.c:2582
hfsplus_write_begin+0x9a/0x130 fs/hfsplus/inode.c:52
generic_perform_write+0x3f5/0xc40 mm/filemap.c:3918
__generic_file_write_iter+0x20a/0x460 mm/filemap.c:4013
generic_file_write_iter+0x103/0x5b0 mm/filemap.c:4039
call_write_iter include/linux/fs.h:2020 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x8ef/0x1490 fs/read_write.c:584
ksys_write+0x20f/0x4c0 fs/read_write.c:637
__do_sys_write fs/read_write.c:649 [inline]
__se_sys_write fs/read_write.c:646 [inline]
__x64_sys_write+0x93/0xd0 fs/read_write.c:646
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x44/0x110 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b

CPU: 0 PID: 5003 Comm: syz-executor371 Not tainted 6.7.0-rc7-syzkaller-00003-gfbafc3e621c3 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
=====================================================


---
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.

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

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.

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

Edward Adam Davis

unread,
Dec 28, 2023, 8:21:17 AM12/28/23
to syzbot+55ad87...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
please test uninit-value in __hfsplus_ext_cache_extent

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git fbafc3e621c3

diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
index ca2ba8c9f82e..9d4ffff6d42e 100644
--- a/fs/hfsplus/bfind.c
+++ b/fs/hfsplus/bfind.c
@@ -23,6 +23,7 @@ int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd)
return -ENOMEM;
fd->search_key = ptr;
fd->key = ptr + tree->max_key_len + 2;
+ fd->key->ext.fork_type = 0;
hfs_dbg(BNODE_REFS, "find_init: %d (%p)\n",
tree->cnid, __builtin_return_address(0));
switch (tree->cnid) {

syzbot

unread,
Dec 28, 2023, 8:40:06 AM12/28/23
to ead...@qq.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: uninit-value in __hfsplus_ext_cache_extent

loop0: detected capacity change from 0 to 1024
=====================================================
BUG: KMSAN: uninit-value in __hfsplus_ext_read_extent fs/hfsplus/extents.c:170 [inline]
BUG: KMSAN: uninit-value in __hfsplus_ext_cache_extent+0x851/0x960 fs/hfsplus/extents.c:191
__hfsplus_ext_read_extent fs/hfsplus/extents.c:170 [inline]
__hfsplus_ext_cache_extent+0x851/0x960 fs/hfsplus/extents.c:191
hfsplus_ext_read_extent fs/hfsplus/extents.c:218 [inline]
hfsplus_file_extend+0x775/0x1b90 fs/hfsplus/extents.c:461
hfsplus_get_block+0xe99/0x1690 fs/hfsplus/extents.c:245
__block_write_begin_int+0x946/0x2c70 fs/buffer.c:2119
__block_write_begin fs/buffer.c:2168 [inline]
block_write_begin+0x143/0x450 fs/buffer.c:2227
cont_write_begin+0xd5c/0x12f0 fs/buffer.c:2582
hfsplus_write_begin+0x9a/0x130 fs/hfsplus/inode.c:52
generic_perform_write+0x3f5/0xc40 mm/filemap.c:3918
__generic_file_write_iter+0x20a/0x460 mm/filemap.c:4013
generic_file_write_iter+0x103/0x5b0 mm/filemap.c:4039
call_write_iter include/linux/fs.h:2020 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x8ef/0x1490 fs/read_write.c:584
ksys_write+0x20f/0x4c0 fs/read_write.c:637
__do_sys_write fs/read_write.c:649 [inline]
__se_sys_write fs/read_write.c:646 [inline]
__x64_sys_write+0x93/0xd0 fs/read_write.c:646
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x44/0x110 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b

Local variable fd.i created at:
hfsplus_ext_read_extent fs/hfsplus/extents.c:209 [inline]
hfsplus_file_extend+0x54b/0x1b90 fs/hfsplus/extents.c:461
hfsplus_get_block+0xe99/0x1690 fs/hfsplus/extents.c:245

CPU: 0 PID: 5477 Comm: syz-executor.0 Not tainted 6.7.0-rc7-syzkaller-00003-gfbafc3e621c3-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
=====================================================


Tested on:

commit: fbafc3e6 Merge tag 'for_linus' of git://git.kernel.org..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=12e6aeb5e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=e0c7078a6b901aa3
dashboard link: https://syzkaller.appspot.com/bug?extid=55ad87f38795d6787521
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=167e326ee80000

Edward Adam Davis

unread,
Dec 28, 2023, 8:59:39 AM12/28/23
to syzbot+55ad87...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index 3c572e44f2ad..6681e3a24f29 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -206,7 +206,7 @@ static inline int __hfsplus_ext_cache_extent(struct hfs_find_data *fd,
static int hfsplus_ext_read_extent(struct inode *inode, u32 block)
{
struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
- struct hfs_find_data fd;
+ struct hfs_find_data fd = {};
int res;

if (block >= hip->cached_start &&

syzbot

unread,
Dec 28, 2023, 9:51:05 AM12/28/23
to ead...@qq.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: uninit-value in __hfsplus_ext_cache_extent

loop0: detected capacity change from 0 to 1024
=====================================================
BUG: KMSAN: uninit-value in __hfsplus_ext_read_extent fs/hfsplus/extents.c:170 [inline]
BUG: KMSAN: uninit-value in __hfsplus_ext_cache_extent+0x851/0x960 fs/hfsplus/extents.c:191
__hfsplus_ext_read_extent fs/hfsplus/extents.c:170 [inline]
__hfsplus_ext_cache_extent+0x851/0x960 fs/hfsplus/extents.c:191
hfsplus_file_truncate+0x730/0xf50 fs/hfsplus/extents.c:598
hfsplus_write_failed+0xab/0x100 fs/hfsplus/inode.c:42
hfsplus_write_begin+0x12e/0x130 fs/hfsplus/inode.c:56
generic_perform_write+0x3f5/0xc40 mm/filemap.c:3918
__generic_file_write_iter+0x20a/0x460 mm/filemap.c:4013
generic_file_write_iter+0x103/0x5b0 mm/filemap.c:4039
call_write_iter include/linux/fs.h:2020 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x8ef/0x1490 fs/read_write.c:584
ksys_write+0x20f/0x4c0 fs/read_write.c:637
__do_sys_write fs/read_write.c:649 [inline]
__se_sys_write fs/read_write.c:646 [inline]
__x64_sys_write+0x93/0xd0 fs/read_write.c:646
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x44/0x110 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b

Local variable fd created at:
hfsplus_file_truncate+0x5d/0xf50 fs/hfsplus/extents.c:547
hfsplus_write_failed+0xab/0x100 fs/hfsplus/inode.c:42

CPU: 0 PID: 5485 Comm: syz-executor.0 Not tainted 6.7.0-rc7-syzkaller-00003-gfbafc3e621c3-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
=====================================================


Tested on:

commit: fbafc3e6 Merge tag 'for_linus' of git://git.kernel.org..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=16e5645ee80000
kernel config: https://syzkaller.appspot.com/x/.config?x=e0c7078a6b901aa3
dashboard link: https://syzkaller.appspot.com/bug?extid=55ad87f38795d6787521
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=129e0a91e80000

Edward Adam Davis

unread,
Dec 28, 2023, 5:01:13 PM12/28/23
to syzbot+55ad87...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
+ struct hfs_find_data fd = { 0 };

syzbot

unread,
Dec 28, 2023, 7:08:05 PM12/28/23
to ead...@qq.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
CPU: 1 PID: 5490 Comm: syz-executor.0 Not tainted 6.7.0-rc7-syzkaller-00003-gfbafc3e621c3-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
=====================================================


Tested on:

commit: fbafc3e6 Merge tag 'for_linus' of git://git.kernel.org..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=14922dcee80000
kernel config: https://syzkaller.appspot.com/x/.config?x=e0c7078a6b901aa3
dashboard link: https://syzkaller.appspot.com/bug?extid=55ad87f38795d6787521
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=12e443d9e80000

Reply all
Reply to author
Forward
0 new messages