linux/fs/overlayfs
Qing Wang 17cdaf3280 ovl: Fix uninit-value in ovl_fill_real
[ Upstream commit 1992330d90 ]

Syzbot reported a KMSAN uninit-value issue in ovl_fill_real.

This iusse's call chain is:
__do_sys_getdents64()
    -> iterate_dir()
        ...
            -> ext4_readdir()
                -> fscrypt_fname_alloc_buffer() // alloc
                -> fscrypt_fname_disk_to_usr // write without tail '\0'
                -> dir_emit()
                    -> ovl_fill_real() // read by strcmp()

The string is used to store the decrypted directory entry name for an
encrypted inode. As shown in the call chain, fscrypt_fname_disk_to_usr()
write it without null-terminate. However, ovl_fill_real() uses strcmp() to
compare the name against "..", which assumes a null-terminated string and
may trigger a KMSAN uninit-value warning when the buffer tail contains
uninit data.

Reported-by: syzbot+d130f98b2c265fae5297@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d130f98b2c265fae5297
Fixes: 4edb83bb10 ("ovl: constant d_ino for non-merge dirs")
Signed-off-by: Qing Wang <wangqing7171@gmail.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Link: https://patch.msgid.link/20260128132406.23768-2-amir73il@gmail.com
Acked-by: Miklos Szeredi <mszeredi@redhat.com>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-03-04 07:19:47 -05:00
..
copy_up.c ovl: fix UAF in ovl_dentry_update_reval by moving dput() in ovl_link_up 2025-03-13 12:50:55 +01:00
dir.c ovl: pass ofs to creation operations 2025-03-13 12:50:55 +01:00
export.c ovl: update of dentry revalidate flags after copy up 2023-07-23 13:47:10 +02:00
file.c ovl: fix incorrect fdput() on aio completion 2023-09-23 11:10:01 +02:00
inode.c ovl: use wrappers to all vfs_*xattr() calls 2025-03-13 12:50:55 +01:00
Kconfig docs: fix broken references to text files 2020-04-20 15:35:59 -06:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
namei.c ovl: use wrappers to all vfs_*xattr() calls 2025-03-13 12:50:55 +01:00
overlayfs.h ovl: pass ofs to creation operations 2025-03-13 12:50:55 +01:00
ovl_entry.h ovl: check type and offset of struct vfsmount in ovl_entry 2023-08-26 14:23:23 +02:00
readdir.c ovl: Fix uninit-value in ovl_fill_real 2026-03-04 07:19:47 -05:00
super.c ovl: pass ofs to creation operations 2025-03-13 12:50:55 +01:00
util.c ovl: Check for NULL d_inode() in ovl_dentry_upper() 2025-07-10 15:57:34 +02:00