From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5028C48BE5 for ; Tue, 15 Jun 2021 15:50:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9161B6192C for ; Tue, 15 Jun 2021 15:50:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231791AbhFOPw4 (ORCPT ); Tue, 15 Jun 2021 11:52:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:44930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232097AbhFOPvY (ORCPT ); Tue, 15 Jun 2021 11:51:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2E8ED61627; Tue, 15 Jun 2021 15:49:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623772159; bh=DbtdoTkiNbIAU8s9VhuyUIYnBVeYW4JOsXeL68JbIVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZdeBndOTm+cTYBkYorezsKFDfAZcIUBeqG0JgRn632VY/GWcr0f1jI2YNBsL6YIyW yAuddAL4HH7ccN5YKHw8qW1l1BTwIKpJ+IHkVN7Ems1sA7mSeVp+rpYMBB6UHobwJc VSh3/MHI+KMJ29/05A9YX04TzZ0JdGLOqVuBcnSj9XmrxD1Q+NiOTNJTUyhM4HlP/c gl+jNrHwcbkowG58IsPDkBHjOt27wsZP0jx7t59dy1XItAf6kHfHSYw+Jwcn/PNGGx 5klcMeC832xHL+3nouVIf5vvxNJM3tFhdDGDrnYuDYQz7K/BWwBYli1x+ba0ducEDO NrbqZJEd7mSYA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dai Ngo , Trond Myklebust , Sasha Levin , linux-nfs@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 09/30] NFSv4: nfs4_proc_set_acl needs to restore NFS_CAP_UIDGID_NOMAP on error. Date: Tue, 15 Jun 2021 11:48:46 -0400 Message-Id: <20210615154908.62388-9-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210615154908.62388-1-sashal@kernel.org> References: <20210615154908.62388-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dai Ngo [ Upstream commit f8849e206ef52b584cd9227255f4724f0cc900bb ] Currently if __nfs4_proc_set_acl fails with NFS4ERR_BADOWNER it re-enables the idmapper by clearing NFS_CAP_UIDGID_NOMAP before retrying again. The NFS_CAP_UIDGID_NOMAP remains cleared even if the retry fails. This causes problem for subsequent setattr requests for v4 server that does not have idmapping configured. This patch modifies nfs4_proc_set_acl to detect NFS4ERR_BADOWNER and NFS4ERR_BADNAME and skips the retry, since the kernel isn't involved in encoding the ACEs, and return -EINVAL. Steps to reproduce the problem: # mount -o vers=4.1,sec=sys server:/export/test /tmp/mnt # touch /tmp/mnt/file1 # chown 99 /tmp/mnt/file1 # nfs4_setfacl -a A::unknown.user@xyz.com:wrtncy /tmp/mnt/file1 Failed setxattr operation: Invalid argument # chown 99 /tmp/mnt/file1 chown: changing ownership of ‘/tmp/mnt/file1’: Invalid argument # umount /tmp/mnt # mount -o vers=4.1,sec=sys server:/export/test /tmp/mnt # chown 99 /tmp/mnt/file1 # v2: detect NFS4ERR_BADOWNER and NFS4ERR_BADNAME and skip retry in nfs4_proc_set_acl. Signed-off-by: Dai Ngo Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/nfs4proc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index c92d6ff0fcea..0a0b7680ea85 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -5942,6 +5942,14 @@ static int nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t buflen do { err = __nfs4_proc_set_acl(inode, buf, buflen); trace_nfs4_set_acl(inode, err); + if (err == -NFS4ERR_BADOWNER || err == -NFS4ERR_BADNAME) { + /* + * no need to retry since the kernel + * isn't involved in encoding the ACEs. + */ + err = -EINVAL; + break; + } err = nfs4_handle_exception(NFS_SERVER(inode), err, &exception); } while (exception.retry); -- 2.30.2