KMSAN: uninit-value in ni_seek_data_or_hole
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: cca95436be15 Merge tag 'phy-fixes-7.1' of git://git.kernel.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=10e36d6a580000 kernel config: https://syzkaller.appspot.com/x/.config?x=91978e795dcd971b dashboard link: https://syzkaller.appspot.com/bug?extid=c2cfe997245202e46f10 compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=147dad96580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=140c2cec580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/fb3ceeccf5bc/disk-cca95436.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/af588c0672f1/vmlinux-cca95436.xz
kernel image: https://storage.googleapis.com/syzbot-assets/beac806b38fd/bzImage-cca95436.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/7ca9c62c48ea/mount_0.gz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
ntfs3(loop0): Mark volume as dirty due to NTFS errors ntfs3(loop0): ino=1a, mi_enum_attr ntfs3(loop0): ino=1a, mi_enum_attr ntfs3(loop0): Failed to initialize $Extend/$Reparse.
=====================================================
BUG: KMSAN: uninit-value in ni_seek_data_or_hole+0x24f/0x5f0 fs/ntfs3/frecord.c:2862 ni_seek_data_or_hole+0x24f/0x5f0 fs/ntfs3/frecord.c:2862 ntfs_llseek+0x22a/0x4a0 fs/ntfs3/file.c:1530 vfs_llseek fs/read_write.c:391 [inline] ksys_lseek fs/read_write.c:404 [inline] __do_sys_lseek fs/read_write.c:414 [inline] __se_sys_lseek fs/read_write.c:412 [inline] __x64_sys_lseek+0x29d/0x460 fs/read_write.c:412 x64_sys_call+0x3004/0x3ea0 arch/x86/include/generated/asm/syscalls_64.h:9 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x134/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was stored to memory at:
ni_seek_data_or_hole+0x248/0x5f0 fs/ntfs3/frecord.c:2862 ntfs_llseek+0x22a/0x4a0 fs/ntfs3/file.c:1530 vfs_llseek fs/read_write.c:391 [inline] ksys_lseek fs/read_write.c:404 [inline] __do_sys_lseek fs/read_write.c:414 [inline] __se_sys_lseek fs/read_write.c:412 [inline] __x64_sys_lseek+0x29d/0x460 fs/read_write.c:412 x64_sys_call+0x3004/0x3ea0 arch/x86/include/generated/asm/syscalls_64.h:9 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x134/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Local variable lcn created at:
ni_seek_data_or_hole+0x72/0x5f0 fs/ntfs3/frecord.c:2851 ntfs_llseek+0x22a/0x4a0 fs/ntfs3/file.c:1530 CPU: 0 UID: 0 PID: 5901 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026 =====================================================
---
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 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
#syz test
fs/ntfs3/frecord.c +5 -4
@@ -2859,6 +2859,11 @@ loff_t ni_seek_data_or_hole(struct ntfs_inode *ni, loff_t offset, bool data)return err; } +if (!clen) { +/* Corrupted file. */ +return -EINVAL ; + } +if (lcn ==RESIDENT_LCN ) {/* clen - resident size in bytes. clen == ni->vfs_inode.i_size */ if (offset >= clen) {
@@ -2909,10 +2914,6 @@ loff_t ni_seek_data_or_hole(struct ntfs_inode *ni, loff_t offset, bool data) } } -if (!clen) { -/* Corrupted file. */ -return -EINVAL ; - } } }
syzbot
syzbotsyzbot has tested the proposed patch but the reproducer is still triggering an issue: lost connection to test machine
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
lost connection to test machine
Tested on:
commit: e8c2f9fd Merge tag 'for-7.1/hpfs-fixes' of git://git.k.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=103f5aa6580000 kernel config: https://syzkaller.appspot.com/x/.config?x=91978e795dcd971b dashboard link: https://syzkaller.appspot.com/bug?extid=c2cfe997245202e46f10 compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8 patch: https://syzkaller.appspot.com/x/patch.diff?x=10119aec580000
PATCH 1/1 fs/ntfs3: prevent potential lcn remains uninitialized
In reply to syzbotThe target VCN being sought was not found within runs[0], causing run_lookup() to return false. This causes run_lookup_entry() to return false, which in turn results in a len value of 0, and the new parameter passed to attr_data_get_block() is NULL. Collectively, these factors ultimately cause attr_data_get_block_locked() to exit prematurely without initializing lcn, thereby triggering [1].
To prevent [1], the clen check within ni_seek_data_or_hole() has been moved to occur before the lcn check.
[1]
BUG: KMSAN: uninit-value in ni_seek_data_or_hole+0x24f/0x5f0 fs/ntfs3/frecord.c:2862 ni_seek_data_or_hole+0x24f/0x5f0 fs/ntfs3/frecord.c:2862 ntfs_llseek+0x22a/0x4a0 fs/ntfs3/file.c:1530 vfs_llseek fs/read_write.c:391 [inline]
--- fs/ntfs3/frecord.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/ntfs3/frecord.c +5 -4
@@ -2859,6 +2859,11 @@ loff_t ni_seek_data_or_hole(struct ntfs_inode *ni, loff_t offset, bool data)return err; } +if (!clen) { +/* Corrupted file. */ +return -EINVAL ; + } +if (lcn ==RESIDENT_LCN ) {/* clen - resident size in bytes. clen == ni->vfs_inode.i_size */ if (offset >= clen) {
@@ -2909,10 +2914,6 @@ loff_t ni_seek_data_or_hole(struct ntfs_inode *ni, loff_t offset, bool data) } } -if (!clen) { -/* Corrupted file. */ -return -EINVAL ; - } } }
Signature · 1 line
2.43.0
Konstantin Komarov
maintainerRe: [PATCH] fs/ntfs3: prevent potential lcn remains uninitialized
Quoted 41 lines · Edward Adam Davis
The target VCN being sought was not found within runs[0], causing
run_lookup()to return false. This causesrun_lookup_entry()to return false, which in turn results in a len value of 0, and the new parameter passed toattr_data_get_block()is NULL. Collectively, these factors ultimately causeattr_data_get_block_locked()to exit prematurely without initializing lcn, thereby triggering [1].To prevent [1], the clen check within
ni_seek_data_or_hole()has been moved to occur before the lcn check.[1]
BUG: KMSAN: uninit-value in ni_seek_data_or_hole+0x24f/0x5f0 fs/ntfs3/frecord.c:2862 ni_seek_data_or_hole+0x24f/0x5f0 fs/ntfs3/frecord.c:2862 ntfs_llseek+0x22a/0x4a0 fs/ntfs3/file.c:1530 vfs_llseek fs/read_write.c:391 [inline]Fixes c61326967728 ("fs/ntfs3: implement llseek SEEK_DATA/SEEK_HOLE by scanning data runs")Reported-by [email protected]Signed-off-by Edward Adam Davis <[email protected]>--- fs/ntfs3/frecord.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)fs/ntfs3/frecord.c +5
-0@@ -2859,6 +2859,11 @@ loff_t ni_seek_data_or_hole(struct ntfs_inode *ni, loff_t offset, bool data)return err; } +if (!clen) { +/* Corrupted file. */ +return -EINVAL ; + } +if (lcn ==RESIDENT_LCN ) {/* clen - resident size in bytes. clen == ni->vfs_inode.i_size */ if (offset >= clen) {
fs/ntfs3/frecord.c loff_t ni_seek_data_or_hole(struct ntfs_inode *ni, loff_t offset, bool data) · line 2919
Quoted 10 lines
fs/ntfs3/frecord.c +0
-4@@ -2909,10 +2914,6 @@ loff_t ni_seek_data_or_hole(struct ntfs_inode *ni, loff_t offset, bool data) } } -if (!clen) { -/* Corrupted file. */ -return -EINVAL ; - } } }
Hello,
The patch was applied, thank you.
Regards,
Konstantin