From patchwork Fri Sep 22 20:15:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 9967037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AEA8760381 for ; Fri, 22 Sep 2017 20:16:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A067129162 for ; Fri, 22 Sep 2017 20:16:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95579292C8; Fri, 22 Sep 2017 20:16:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 273FA29077 for ; Fri, 22 Sep 2017 20:16:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751911AbdIVUPz (ORCPT ); Fri, 22 Sep 2017 16:15:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52326 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751845AbdIVUPy (ORCPT ); Fri, 22 Sep 2017 16:15:54 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 99E23883A5; Fri, 22 Sep 2017 20:15:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 99E23883A5 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=smayhew@redhat.com Received: from coeurl.usersys.redhat.com (ovpn-122-50.rdu2.redhat.com [10.10.122.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D39560BE1; Fri, 22 Sep 2017 20:15:54 +0000 (UTC) Received: by coeurl.usersys.redhat.com (Postfix, from userid 1000) id 175E0207CF; Fri, 22 Sep 2017 16:15:51 -0400 (EDT) From: Scott Mayhew To: trond.myklebust@primarydata.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH] nfs: override uid and gid for exclusive creates in nfs3_proc_create Date: Fri, 22 Sep 2017 16:15:51 -0400 Message-Id: <20170922201551.15222-1-smayhew@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 22 Sep 2017 20:15:54 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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))