public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ovl: Fix uninit-value in ovl_fill_real
@ 2026-01-27  7:54 Qing Wang
  2026-01-27 10:42 ` Miklos Szeredi
  0 siblings, 1 reply; 9+ messages in thread
From: Qing Wang @ 2026-01-27  7:54 UTC (permalink / raw)
  To: Miklos Szeredi, Amir Goldstein
  Cc: linux-unionfs, linux-kernel, Qing Wang,
	syzbot+d130f98b2c265fae5297

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 wthout 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: 4edb83bb1041 ("ovl: constant d_ino for non-merge dirs")
Signed-off-by: Qing Wang <wangqing7171@gmail.com>
---
 fs/overlayfs/readdir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 160960bb0ad0..2581cb33fb87 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -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 && strncmp(name, "..", 2) == 0) {
 		ino = rdt->parent_ino;
 	} else if (rdt->cache) {
 		struct ovl_cache_entry *p;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-01-28 10:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-27  7:54 [PATCH] ovl: Fix uninit-value in ovl_fill_real Qing Wang
2026-01-27 10:42 ` Miklos Szeredi
2026-01-27 10:52   ` [PATCH v2] " Qing Wang
2026-01-27 11:09     ` Amir Goldstein
2026-01-28  0:43       ` Eric Biggers
2026-01-27 11:19     ` Miklos Szeredi
2026-01-28  2:42       ` Qing Wang
2026-01-28 10:19         ` Amir Goldstein
2026-01-28 10:36           ` Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox