Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH] ovl: keep err zero after successful ovl_cache_get()
@ 2026-05-14 11:13 Nirmoy Das
  2026-05-14 12:36 ` Amir Goldstein
  2026-05-14 14:42 ` [PATCH v2] " Nirmoy Das
  0 siblings, 2 replies; 5+ messages in thread
From: Nirmoy Das @ 2026-05-14 11:13 UTC (permalink / raw)
  To: Miklos Szeredi, Amir Goldstein
  Cc: Christian Brauner, linux-unionfs, linux-kernel, Nirmoy Das,
	syzbot+a16fb0cce329a320661c, stable

ovl_iterate_merged() stores PTR_ERR(cache) in err before checking
IS_ERR(cache). On success err holds the truncated cache pointer and
can be returned as a bogus non-zero error.

The syzbot reproducer reaches this through overlay-on-overlay readdir:

  getdents64
    iterate_dir(outer overlay file)
      ovl_iterate_merged()
        ovl_cache_get()
          ovl_dir_read_merged()
            ovl_dir_read()
              iterate_dir(inner overlay file)
                ovl_iterate_merged()

Only compute PTR_ERR(cache) on the error path.

Fixes: d25e4b739f83 ("ovl: refactor ovl_iterate() and port to cred guard")
Reported-by: syzbot+a16fb0cce329a320661c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=a16fb0cce329a320661c
Cc: stable@vger.kernel.org
Signed-off-by: Nirmoy Das <nirmoyd@nvidia.com>
---
 fs/overlayfs/readdir.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 1dcc75b3a90f9..0d471064cfea1 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -844,9 +844,8 @@ static int ovl_iterate_merged(struct file *file, struct dir_context *ctx)
 		struct ovl_dir_cache *cache;
 
 		cache = ovl_cache_get(dentry);
-		err = PTR_ERR(cache);
 		if (IS_ERR(cache))
-			return err;
+			return PTR_ERR(cache);
 
 		od->cache = cache;
 		ovl_seek_cursor(od, ctx->pos);
-- 
2.43.0


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

end of thread, other threads:[~2026-05-14 15:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-14 11:13 [PATCH] ovl: keep err zero after successful ovl_cache_get() Nirmoy Das
2026-05-14 12:36 ` Amir Goldstein
2026-05-14 14:37   ` Nirmoy Das
2026-05-14 14:42 ` [PATCH v2] " Nirmoy Das
2026-05-14 15:26   ` Amir Goldstein

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