🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: muc.lists.freebsd.hackers
Article #66

Fwd: [PATCH] NFSv4.2: request mode after CLONE

#66
From: Cedric Blancher
Date: Tue, 27 Oct 2026 14:05
75 lines
8270 bytes
Good afternoon!

Does the FreeBSD NFSv4.2 client request the mode after the update?

Ced

---------- Forwarded message ---------
From: Felix Hoffmann <f3lix.dev@gmx.de>
Date: Sun, 2 Aug 2026 at 21:58
Subject: [PATCH] NFSv4.2: request mode after CLONE
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>


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



-- 
Cedric Blancher <cedric.blancher@gmail.com>
[https://plus.google.com/u/0/+CedricBlancher/]
Institute Pasteur


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID: <CALXu0UehOWLoY8cnHXPDeHYxUB2XUNwzPzzxDeYJ6DZeScz9sQ@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail
References: <20260802195328.175328-1-f3lix.dev@gmx.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: Cedric Blancher <cedric.blancher@gmail.com>
Newsgroups: muc.lists.freebsd.hackers
Subject: Fwd: [PATCH] NFSv4.2: request mode after CLONE
Date: Tue, 27 Oct 2026 15:05:12 +0100
Organization: Newsgate at muc.de e.V.
Sender: owner-freebsd-hackers@FreeBSD.org
Approved: news-admin@muc.de
Distribution: world
Message-ID: <CALXu0UehOWLoY8cnHXPDeHYxUB2XUNwzPzzxDeYJ6DZeScz9sQ@mail.gmail.com>
References: <20260802195328.175328-1-f3lix.dev@gmx.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2";
	logging-data="3949"; mail-complaints-to="news-admin@muc.de"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
	t=1793109954; h=from:from:sender:sender:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:mime-version:mime-version:
	 content-type:content-type:in-reply-to:in-reply-to:
	 references:references:list-id:list-help:list-owner:list-unsubscribe:
	 list-subscribe:list-post; bh=KSzAraj3+8Zzh016CNxIArUMPtfOAvuDTaPQErNuTdw=;
	b=S/8qbbZTo2oc1JWKORsIoKlhsvWvvRGHVVTZsyTOdN9bu4fo0qSNIKruMmcESCBIVPG6r2
	nN1qGEIl6hijgGSl90oGhruLzNqKFlT5SegqG7R1z5UXvZ4R5OWPidiiMW4jKm4zrf8HMQ
	l7EIN/MRApUFt3hcdbWIDX7oQ24mAUVfjJFEHYmqZm0bp4EycCL7/CazOs5h7lnJ+X9Rlp
	ETuIruCZBMotizIYID0BgyFQlrHVRiwCv2SdR2ClNR5/W925R07nDlkWXqSzDgryY09ZPB
	6WnZY74jj21BfLs5DRmdaqHTxAxA0U/hcOQvCbNyLwGdZfgHGyjoCtNVbv1Q8w==
X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org
Authentication-Results: mx1.freebsd.org;
	dkim=pass header.d=gmail.com header.s=20260707 header.b=wNuSS166;
	arc=pass ("google.com:s=arc-20260327:i=1");
	spf=pass (mx1.freebsd.org: domain of cedric.blancher@gmail.com designates 2607:f8b0:4864:20::a31 as permitted sender) smtp.mailfrom=cedric.blancher@gmail.com;
	dmarc=pass (policy=none) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1793109949; x=1793714749; darn=freebsd.org;
        h=content-type:to:subject:message-id:date:from:in-reply-to:references
         :mime-version:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=KSzAraj3+8Zzh016CNxIArUMPtfOAvuDTaPQErNuTdw=;
        b=wNuSS166FJNA3UuLwuAE/UgAnbq7Vezq5bN6CgKdnb2YQH+3joQiQBfnk5GyvicAAK
         OOSCkKdOTSdrmAtRFb/FpG32mQRGUcl4aU9XE0wxw6Opti0eAN3RuF28O6g3aew8G2DX
         eCpUtCwfrQ8QrnFrVakgEK7QYFxdI6Z0t6xJ/NGPSHKEK3hA1zEuaU7ypHmn5xlFo/3q
         XpwRWLGJGIfzm9td3GLkCRmGeh0SIg6g9yLGAeWkZBkLtlXCG59cz+H2vaiRFF3yQyQc
         4kOdmaSFtjfvkRpT3D6XfFIXMcoxdQaaXvadrdzOoM50h07jW+iFzGSJARTZoEdvkmIv
         BW6Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1793109949; x=1793714749;
        h=content-type:to:subject:message-id:date:from:in-reply-to:references
         :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=KSzAraj3+8Zzh016CNxIArUMPtfOAvuDTaPQErNuTdw=;
        b=E0yo+iDdfBWUJrkhV9VLQ6DPIt/DOJ6xcWbdVzst1QGIpzTY4vcKSP32AqqjQCV2DJ
         qKuxMBvlljny+jm4Lkqpc4knxBxm6lwYdE3j2BuHX4nGasihNG0ZyFq8sRVpnvKwZzWA
         Xh/nm1ke9NYX9jRdXpEO9xuNQO/gO85Ety01iPylZ2h5DtffkXEB8URsD61pjU5q+gwo
         gHdT5n0KGh0/udGLZR2leTkpYgwqDqKJfP37ZR7TJaRuZcubM/G8Khl9sCyy3CVCLan1
         ws5dJ+cJKavzVafX7HDIet/NpiZIZVTlJYUg59vtNE5lov7X6ncSIDf56R2k/P/7g1em
         ZSMw==
X-Gm-Message-State: AFq9FYJ73+acHxYty6IjBho3GghuhZXQH3oCafjlb5JaiqB/pe3vKK/Z
	Ql9Hp+T33fwTO1LsvMocbJisy8nnO898KeNAbGQjjvhpHytgKtF437s7DJwUe4qfnE83j3+1CFA
	oLXLsZS/hi/T4BjLp20EAfxhnGGUW/2BTI16M
X-Gm-Gg: AYBFou2Yo7i8x4REeO/g+rYOGvDPN9PaDpzGrYISRVy3k55cPJoTMfsG+dEaT1k3MLP
	Yn3Meb615gHVzWGuFwKBp8JQiekpPvUShKeNF3O7l6teV8GhvyF3vy5sGvqqNpv0sXIMvD4YIbA
	gHeThkcDC/GyHffnSQqqF2Uo8IMsL1ACGhzp6wJKFpjKcWteOH/gPNfcnPOKphG4V4Fg4PG1fG+
	EewZlMV7ayzD5it5EIhdlXKrDA2yONqxVDfEpJhZ6UXzVH4EpCGwnp4fVeO+w/kuGpLEcZQo+ia
	C8zaA4EJfsXMisbeutOnBrlgUF2m1v1BWveskmMAh4G3132NElguMyQbq6GgIolwGLEraH0/0Xd
	qdelkO+MsuSF8DGKYCv3UcLpzawUkRfduxg90V40CcJDYGxiJ04z7tNo1uM8=
Precedence: list
In-Reply-To: <20260802195328.175328-1-f3lix.dev@gmx.de>
X-Gm-Features: AclHuK-1UXpC8JrpGQr4WtRLN8Fi4lZoI_p6DOZUniwCV7HwN2wfvzXbt2WOnVk
X-Spamd-Bar: --
X-Spamd-Result: default: False [-2.00 / 15.00];
	ARC_ALLOW(-1.00)[google.com:s=arc-20260327:i=1];
	DMARC_POLICY_ALLOW(-0.50)[gmail.com,none];
	R_DKIM_ALLOW(-0.20)[gmail.com:s=20260707];
	R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4864::/56];
	MIME_GOOD(-0.10)[text/plain];
	FREEMAIL_FROM(0.00)[gmail.com];
	ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US];
	FREEMAIL_ENVFROM(0.00)[gmail.com];
	DWL_DNSWL_NONE(0.00)[gmail.com:dkim];
	RCPT_COUNT_ONE(0.00)[1];
	RCVD_COUNT_ONE(0.00)[1];
	MISSING_XM_UA(0.00)[];
	MIME_TRACE(0.00)[0:+];
	MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org];
	RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::a31:from];
	TO_DN_NONE(0.00)[];
	FROM_EQ_ENVFROM(0.00)[];
	FROM_HAS_DN(0.00)[];
	MID_RHS_MATCH_FROMTLD(0.00)[];
	TO_MATCH_ENVRCPT_ALL(0.00)[];
	RCVD_TLS_LAST(0.00)[];
	PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org];
	ALIAS_RESOLVED(0.00)[];
	DKIM_TRACE(0.00)[gmail.com:+]
X-Rspamd-Queue-Id: 4jDXMg2rrRz4LZq
X-Newsgate-Id: f02c70b8849f+
X-No-Archive: Yes