[RFC PATCH v2 14/41] nfsd: don't hand out uid 0 for read layouts of UUID-owned files
Jan Koester
jan.koester at tuxist.de
Wed Oct 21 03:15:34 UTC 2026
Read-only flexfile layout segments use the owner's uid plus one, so the
client gets no write access on the data server. For a UUID or GUID
owner from_kuid() is -1 and the "plus one" makes it 0, root. Use the
overflow uid for them instead.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jan Koester <jan.koester at tuxist.de>
---
fs/nfsd/flexfilelayout.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/nfsd/flexfilelayout.c b/fs/nfsd/flexfilelayout.c
index 6d531285ab..f459d2c1c1 100644
--- a/fs/nfsd/flexfilelayout.c
+++ b/fs/nfsd/flexfilelayout.c
@@ -51,7 +51,11 @@ nfsd4_ff_proc_layoutget(struct svc_rqst *rqstp, struct inode *inode,
/* Do not allow a IOMODE_READ segment to have write pemissions */
if (seg->iomode == IOMODE_READ) {
- u = from_kuid(&init_user_ns, inode->i_uid) + 1;
+ /* any uid but the owner's; a UUID or GUID has no "+ 1" */
+ if (uid_is_legacy(inode->i_uid))
+ u = from_kuid(&init_user_ns, inode->i_uid) + 1;
+ else
+ u = overflowuid;
fl->uid = make_kuid(&init_user_ns, u);
} else
fl->uid = inode->i_uid;
--
2.56.0
More information about the Linux-security-module-archive
mailing list