]>
Commit | Line | Data |
---|---|---|
5c17fab8 GKH |
1 | From eb4b691b9115fae4c844f5941418335575cf667f Mon Sep 17 00:00:00 2001 |
2 | From: Danny Lin <danny@orbstack.dev> | |
3 | Date: Sat, 13 Apr 2024 17:34:31 -0700 | |
4 | Subject: fuse: fix leaked ENOSYS error on first statx call | |
5 | ||
6 | From: Danny Lin <danny@orbstack.dev> | |
7 | ||
8 | commit eb4b691b9115fae4c844f5941418335575cf667f upstream. | |
9 | ||
10 | FUSE attempts to detect server support for statx by trying it once and | |
11 | setting no_statx=1 if it fails with ENOSYS, but consider the following | |
12 | scenario: | |
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 | ||
26 | Fix this by zeroing "err" before retrying the failed call. | |
27 | ||
28 | Fixes: d3045530bdd2 ("fuse: implement statx") | |
29 | Cc: stable@vger.kernel.org # v6.6 | |
30 | Signed-off-by: Danny Lin <danny@orbstack.dev> | |
31 | Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> | |
32 | Signed-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 { |