Unverified Commit 1992330d authored by Qing Wang's avatar Qing Wang Committed by Christian Brauner
Browse files

ovl: Fix uninit-value in ovl_fill_real



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: default avatar <syzbot+d130f98b2c265fae5297@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=d130f98b2c265fae5297


Fixes: 4edb83bb ("ovl: constant d_ino for non-merge dirs")
Signed-off-by: default avatarQing Wang <wangqing7171@gmail.com>
Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Link: https://patch.msgid.link/20260128132406.23768-2-amir73il@gmail.com


Acked-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
Reviewed-by: default avatarEric Biggers <ebiggers@kernel.org>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 9396bfda
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -755,7 +755,7 @@ static bool ovl_fill_real(struct dir_context *ctx, const char *name,
	struct dir_context *orig_ctx = rdt->orig_ctx;
	bool res;

	if (rdt->parent_ino && strcmp(name, "..") == 0) {
	if (rdt->parent_ino && namelen == 2 && !strncmp(name, "..", 2)) {
		ino = rdt->parent_ino;
	} else if (rdt->cache) {
		struct ovl_cache_entry *p;