2017-09-22 20:15:54

by Scott Mayhew

[permalink] [raw]
Subject: [PATCH] nfs: override uid and gid for exclusive creates in nfs3_proc_create

RFC 1813 section 3.3.8 states

Once the client has performed a successful exclusive
create, it must issue a SETATTR to set the correct file
attributes. Until it does so, it should not rely upon any
of the file attributes, since the server implementation
may need to overload file metadata to store the verifier.

HP-UX expects the client to send the uid and gid in the post-create
setattr for exclusive creates. Customers are sometimes seeing bogus
values because the Linux NFS client is only updating the atime and
mtime.

Signed-off-by: Scott Mayhew <[email protected]>
---
fs/nfs/nfs3proc.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index d1e87ec..4d77d2d 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -370,6 +370,13 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
if (data->arg.create.createmode == NFS3_CREATE_EXCLUSIVE) {
dprintk("NFS call setattr (post-create)\n");

+ sattr->ia_uid = current_fsuid();
+ sattr->ia_valid |= ATTR_UID;
+ if (dir->i_mode & S_ISGID)
+ sattr->ia_gid = dir->i_gid;
+ else
+ sattr->ia_gid = current_fsgid();
+ sattr->ia_valid |= ATTR_GID;
if (!(sattr->ia_valid & ATTR_ATIME_SET))
sattr->ia_valid |= ATTR_ATIME;
if (!(sattr->ia_valid & ATTR_MTIME_SET))
--
2.9.5



2017-09-22 21:18:57

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH] nfs: override uid and gid for exclusive creates in nfs3_proc_create

T24gRnJpLCAyMDE3LTA5LTIyIGF0IDE2OjE1IC0wNDAwLCBTY290dCBNYXloZXcgd3JvdGU6DQo+
IFJGQyAxODEzIHNlY3Rpb24gMy4zLjggc3RhdGVzDQo+IA0KPiAgICAgICBPbmNlIHRoZSBjbGll
bnQgaGFzIHBlcmZvcm1lZCBhIHN1Y2Nlc3NmdWwgZXhjbHVzaXZlDQo+ICAgICAgIGNyZ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