From patchwork Wed Mar 21 19:52:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 10300267 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 1F0F960386 for ; Wed, 21 Mar 2018 19:52:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1983D283C5 for ; Wed, 21 Mar 2018 19:52:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E1AF28770; Wed, 21 Mar 2018 19:52:52 +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 7E070283C5 for ; Wed, 21 Mar 2018 19:52:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752873AbeCUTwu (ORCPT ); Wed, 21 Mar 2018 15:52:50 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:43585 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752637AbeCUTwu (ORCPT ); Wed, 21 Mar 2018 15:52:50 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.89) (envelope-from ) id 1eyjmv-0002bn-II; Wed, 21 Mar 2018 20:52:45 +0100 From: Lucas Stach To: "J . Bruce Fields" , Jeff Layton Cc: linux-nfs@vger.kernel.org, kernel@pengutronix.de, patchwork-lst@pengutronix.de Subject: [PATCH] nfsd: zero out umask if the client didn't provide one Date: Wed, 21 Mar 2018 20:52:42 +0100 Message-Id: <20180321195242.4250-1-l.stach@pengutronix.de> X-Mailer: git-send-email 2.16.1 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-nfs@vger.kernel.org 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 When the server is serving a mixed set of clients where some support the NFS 4.2 umask attribute and some don't, we need to make sure to reset the nfd thread umask to 0 when serving a client that isn't providing the umask, otherwise a stale umask from a previous request will be applied. This was only done in the nfsd4_decode_open() callsite, but not in nfsd4_decode_create() leading to newly created directories ending up with wrong permissions in some cases. To avoid any such inconsistency in the future, reset the umask in nfsd4_decode_fattr() where we know if the client did provide a umask. Fixes: 47057abde515 (nfsd: add support for the umask attribute) Signed-off-by: Lucas Stach --- fs/nfsd/nfs4xdr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index e502fd16246b..1eb33b34c51b 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -486,6 +486,8 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, dummy32 = be32_to_cpup(p++); *umask = dummy32 & S_IRWXUGO; iattr->ia_valid |= ATTR_MODE; + } else if (umask) { + *umask = 0; } if (len != expected_len) goto xdr_error; @@ -927,7 +929,6 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) case NFS4_OPEN_NOCREATE: break; case NFS4_OPEN_CREATE: - current->fs->umask = 0; READ_BUF(4); open->op_createmode = be32_to_cpup(p++); switch (open->op_createmode) {