]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-6.8/fuse-fix-leaked-enosys-error-on-first-statx-call.patch
6.8-stable patches
[thirdparty/kernel/stable-queue.git] / queue-6.8 / fuse-fix-leaked-enosys-error-on-first-statx-call.patch
CommitLineData
5c17fab8
GKH
1From eb4b691b9115fae4c844f5941418335575cf667f Mon Sep 17 00:00:00 2001
2From: Danny Lin <danny@orbstack.dev>
3Date: Sat, 13 Apr 2024 17:34:31 -0700
4Subject: fuse: fix leaked ENOSYS error on first statx call
5
6From: Danny Lin <danny@orbstack.dev>
7
8commit eb4b691b9115fae4c844f5941418335575cf667f upstream.
9
10FUSE attempts to detect server support for statx by trying it once and
11setting no_statx=1 if it fails with ENOSYS, but consider the following
12scenario:
13
14- Userspace (e.g. sh) calls stat() on a file
15 * succeeds
16- Userspace (e.g. lsd) calls statx(BTIME) on the same file
17 - request_mask = STATX_BASIC_STATS | STATX_BTIME
18 - first pass: sync=true due to differing cache_mask
19 - statx fails and returns ENOSYS
20 - set no_statx and retry
21 - retry sets mask = STATX_BASIC_STATS
22 - now mask == cache_mask; sync=false (time_before: still valid)
23 - so we take the "else if (stat)" path
24 - "err" is still ENOSYS from the failed statx call
25
26Fix this by zeroing "err" before retrying the failed call.
27
28Fixes: d3045530bdd2 ("fuse: implement statx")
29Cc: stable@vger.kernel.org # v6.6
30Signed-off-by: Danny Lin <danny@orbstack.dev>
31Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
32Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
33---
34 fs/fuse/dir.c | 1 +
35 1 file changed, 1 insertion(+)
36
37--- a/fs/fuse/dir.c
38+++ b/fs/fuse/dir.c
39@@ -1317,6 +1317,7 @@ retry:
40 err = fuse_do_statx(inode, file, stat);
41 if (err == -ENOSYS) {
42 fc->no_statx = 1;
43+ err = 0;
44 goto retry;
45 }
46 } else {