From: Felix Hoffmann <f3lix.dev@gmx.de>
To: Trond Myklebust <trondmy@kernel.org>, Anna Schumaker <anna@kernel.org>
Cc: Peng Tao <tao.peng@primarydata.com>,
linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] NFSv4.2: request mode after CLONE
Date: Sun, 2 Aug 2026 21:53:28 +0200 [thread overview]
Message-ID: <20260802195328.175328-1-f3lix.dev@gmx.de> (raw)
The NFS server can clear setuid and setgid bits when CLONE modifies the
destination. The client currently omits mode from the post-operation
attributes, so the cached mode can retain setid bits after the server has
removed them. A local process can then execute the file using those stale
privilege bits.
Request mode in the CLONE compound's GETATTR. This lets the ordered
post-operation update install the server's mode before CLONE returns.
Fixes: e5341f3a5762 ("nfs42: add CLONE proc functions")
Cc: stable@vger.kernel.org
Assisted-by: Codex:gpt-5
Signed-off-by: Felix Hoffmann <f3lix.dev@gmx.de>
---
Tested on x86-64 using an NFSv4.2 loopback mount with Linux NFSD and a
Btrfs export:
- before this change, the client retained mode 04775 while the server
stored mode 0775, and the privilege transition reproduced in 10/10
non-debug runs
- with this change, both client and server reported mode 0775 and no
privilege transition occurred in 10/10 non-debug runs or 3/3 KASAN
runs
The reproducer requires write authorization to the destination; NFSD
rejected the same operation against a non-writable 04755 file with EACCES.
A working reproducer is available privately on request.
fs/nfs/nfs42proc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index ab86246fc364..35a4909d51b7 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -1302,7 +1302,8 @@ static int _nfs42_proc_clone(struct rpc_message *msg, struct file *src_f,
return -ENOMEM;
nfs4_bitmask_set(dst_bitmask, server->cache_consistency_bitmask,
- dst_inode, NFS_INO_INVALID_BLOCKS);
+ dst_inode,
+ NFS_INO_INVALID_BLOCKS | NFS_INO_INVALID_MODE);
status = nfs4_call_sync(server->client, server, msg,
&args.seq_args, &res.seq_res, 0);
--
2.43.0
next reply other threads:[~2026-08-02 19:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-02 19:53 Felix Hoffmann [this message]
2026-08-12 6:25 ` Cedric Blancher
2026-08-12 14:07 ` Chuck Lever
2026-10-27 14:04 ` Cedric Blancher
2026-10-27 14:35 ` Felix Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260802195328.175328-1-f3lix.dev@gmx.de \
--to=f3lix.dev@gmx.de \
--cc=anna@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=tao.peng@primarydata.com \
--cc=trondmy@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®