Skip to contentSkip to conversation

fuse: don't fill in.h.pid in case args->nocreds is set

PATCH New Miklos Szeredi 1 participant 1 message Aug 25 FUSE filesystem core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fuse: don't fill in.h.pid in case args->nocreds is set

Commit 794e811d1443 ("fuse: split out filesystem part of request sending") alters the pid sent on force && nocreds requests.

Previously these allocated a zeroed request and skipped fuse_force_creds(), so they went out with in.h.pid == 0.

In fuse_fill_creds(), args->pid is now set before the nocreds early return, and fuse_args_to_req() copies it unconditionally - so writeback, release, and DESTROY requests now report the triggering (often kernel-worker) pid instead of 0.

Move the nocreds check above setting args->pid. Also remove the WARN_ON(!args->nocreds) from the !args->force branch, since it's obviously not going to be triggered.

---
 fs/fuse/req.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
fs/fuse/req.c +3 -4
index a01ee743d31e..51cfd64ea1ba 100644
@@ -10,12 +10,12 @@ static int fuse_fill_creds(struct fuse_mount *fm, struct fuse_args *args, struct
 	kuid_t fsuid = mapped_fsuid(idmap, fc->user_ns);
 	kgid_t fsgid = mapped_fsgid(idmap, fc->user_ns);
 
+	if (args->nocreds)
+		return 0;
+
 	args->pid = pid_nr_ns(task_pid(current), fc->pid_ns);
 
 	if (args->force) {
-		if (args->nocreds)
-			return 0;
-
 		if (no_idmap) {
 			args->uid = from_kuid_munged(fc->user_ns, current_fsuid());
 			args->gid = from_kgid_munged(fc->user_ns, current_fsgid());
@@ -26,7 +26,6 @@ static int fuse_fill_creds(struct fuse_mount *fm, struct fuse_args *args, struct
 		return 0;
 	}
 
-	WARN_ON(args->nocreds);
 	/*
 	 * Keep the old behavior when idmappings support was not
 	 * declared by a FUSE server.
Signature · 1 line
2.54.0