Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2663757pxj; Mon, 14 Jun 2021 04:22:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjen2NqQMzqjMTJet0ASIwKWJ8oe8raULiMwD39pUeJgTrUd+cOxwH3OyNeqDBRHoRDNCm X-Received: by 2002:a17:907:9801:: with SMTP id ji1mr15064530ejc.523.1623669728939; Mon, 14 Jun 2021 04:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623669728; cv=none; d=google.com; s=arc-20160816; b=tGfltY2SfVAJn/hQCXyUgUWGC5sigJo0lrJBlJ0QpglcFs/38hToM1gZGma/SvjcX9 Q7yRCHpYwClrfvIYLhKtJ/46uhYZ7SQNAa9Sk6PPeMMEoR3ooYnabIn78I1Ng2prhMrc 5X3lGDPZIyT+FyJqoT8yqjxc0GlHRgo7+EbtQwoLCmHZeoObDqMkhQib4c/GAsed4wbz oP10TgV68pCx8FqD3P9sw4P78K62bJuqRH/ajr533yYKR8BwLAnhrSJih96XHz7PmJPd 2Le+E6kmcnkXGBocchNPJic4VHeCcWs/JXej8NxpshHD1t+oPJQhNESDDmig7602g5zT Dylg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=D9x5zX1hzy0MTqKeFNye6ucq6KlKsjX81BBj+Q5IZO8=; b=KvrlTA4bOxBdiw1WmjB9xUbJM7mrUDH2TWF4ApyJSvVYLXvQthS/5V98ozf0dqLvBc 1lDuLRQcTVj89F4CXiGgA2d1Wq30hl+030YFDUAwkgd55i5/RVqZfMxi9BCJyPYN0qpS UBIp2ZcSaxxqFK28zgVrl2hZH2Aihursuw/QhausEHsBSfW0qZgmHb36zS5HhDLz8h8a fvy+2NUPVTwOn6tvOM8ZNtbRWaYaDXfh7gZ/KSOWKjlCKNYu0VJNvq1gmXvxErFiwYov eavhvVCg20Ian9uLj8DG81CBQi/EKwzzayw6L41x8cQ5swq/EMeuIsOPBcSPuW/A7B1P W59Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cJTbSLiE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn22si10989554edb.132.2021.06.14.04.21.45; Mon, 14 Jun 2021 04:22:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cJTbSLiE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236173AbhFNLUj (ORCPT + 99 others); Mon, 14 Jun 2021 07:20:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:39838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235071AbhFNLIn (ORCPT ); Mon, 14 Jun 2021 07:08:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 56F6861442; Mon, 14 Jun 2021 10:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623667579; bh=2UEHXLPlBITCqD4+I+vPtEkDwyWs2Dq4hcyFJkBX8ZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cJTbSLiEVh4La0vM0cKZCfP16yL/bd1WSqEf5A3Gfpqs/aoD7yp+FOwbkxDFIaolZ 2uwQ4f+0DIJPRpUAGH0fpzD8kCern7EaDUAPmEZd9oSkmteqG3SBdax8MG8Td5Agda mX0nOPKBvdtxVhjKgkfCuRhpmIFzABUtmuv1D09o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dai Ngo , Trond Myklebust Subject: [PATCH 5.10 126/131] NFSv4: nfs4_proc_set_acl needs to restore NFS_CAP_UIDGID_NOMAP on error. Date: Mon, 14 Jun 2021 12:28:07 +0200 Message-Id: <20210614102657.293989065@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102652.964395392@linuxfoundation.org> References: <20210614102652.964395392@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dai Ngo commit f8849e206ef52b584cd9227255f4724f0cc900bb upstream. 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: Greg Kroah-Hartman --- fs/nfs/nfs4proc.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -5946,6 +5946,14 @@ static int nfs4_proc_set_acl(struct inod 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);