Skip to contentSkip to conversation

fuse: fix leaked ENOSYS error on first statx call

PATCH Applied Danny Lin 2 participants 2 messages Apr 14, 2024 – Apr 15, 2024

Subsystems (3)
lore
Share & tools
lore

Danny Lin

author
#0 lore raw

PATCH 1/1 fuse: fix leaked ENOSYS error on first statx call

FUSE attempts to detect server support for statx by trying it once and setting no_statx=1 if it fails with ENOSYS, but consider the following scenario:

- Userspace (e.g. sh) calls stat() on a file
* succeeds
- Userspace (e.g. lsd) calls statx(BTIME) on the same file
- request_mask = STATX_BASIC_STATS | STATX_BTIME
- first pass: sync=true due to differing cache_mask
- statx fails and returns ENOSYS
- set no_statx and retry
- retry sets mask = STATX_BASIC_STATS
- now mask == cache_mask; sync=false (time_before: still valid)
- so we take the "else if (stat)" path
- "err" is still ENOSYS from the failed statx call

Fix this by zeroing "err" before retrying the failed call.

Fixes d3045530bdd2 ("fuse: implement statx")
---
 fs/fuse/dir.c | 1 +
 1 file changed, 1 insertion(+)
fs/fuse/dir.c +1 -0
index de452cdbf3cf..a63125ce70a4 100644
@@ -1362,6 +1362,7 @@ static int fuse_update_get_attr(struct inode *inode, struct file *file,
 			err = fuse_do_statx(inode, file, stat);
 			if (err == -ENOSYS) {
 				fc->no_statx = 1;
+				err = 0;
 				goto retry;
 			}
 		} else {
Signature · 1 line
2.44.0
maintainer Applied
#1 lore raw
Quoted 17 lines · Danny Lin

FUSE attempts to detect server support for statx by trying it once and setting no_statx=1 if it fails with ENOSYS, but consider the following scenario:

- Userspace (e.g. sh) calls stat() on a file
* succeeds
- Userspace (e.g. lsd) calls statx(BTIME) on the same file
- request_mask = STATX_BASIC_STATS | STATX_BTIME
- first pass: sync=true due to differing cache_mask
- statx fails and returns ENOSYS
- set no_statx and retry
- retry sets mask = STATX_BASIC_STATS
- now mask == cache_mask; sync=false (time_before: still valid)
- so we take the "else if (stat)" path
- "err" is still ENOSYS from the failed statx call

Quoted 1 line

Fix this by zeroing "err" before retrying the failed call.

Thanks, applied.

Miklos