Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2631972pxj; Mon, 14 Jun 2021 03:33:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJoz4BZL5itNvigfx27bbHLmRHmxqXRNf3SyPMb7JM2dUsLO4WMi3O9EaHa3HI0Bg9xrsa X-Received: by 2002:aa7:d158:: with SMTP id r24mr15867336edo.171.1623666801855; Mon, 14 Jun 2021 03:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623666801; cv=none; d=google.com; s=arc-20160816; b=bahiDf3d4Eqs5f28AapiAsx5SsaO3Wly9q9Q0MkToqg+3noYdfjSckonGL10QX+Gwh ReOVkoTzN7U2MM4aLRpEf+GwuMN73WF4OLNZZG1f6XWnm5KTPztb9+WjI4Sr2HQegrek hTImaJmIvckNSmVGFJUezqdyqwRBPkqJWIAeBVr3r3GVmYFbM6C4bJcHZGu0s8QyWN+I VxFcB0R/W0sE+rFM15yiv+SrGAdg9zzrdvg7EKLyJ3jo2aoMOCGtWcK3SOIfN4Gpe+CU LqG9JmPgP3Y4560Tj6jzABAIWyM+0Whg6sQG4ghr0xIO+V+drduw4hAqx3uAl8zMSAnK D7+g== 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=sycFJS25/9lqMZgylGAK+hiqEve1LRqCAC01yAeheNE=; b=nvF7nJGRzj2R1usDI4O8DNf+enclhMppvCkn29Y1CjOccf2p4c1O1b4gcBOs+i0KPa z0KBfp9RjZS3b8/RMbN2GPprSbFSPfmm2FbbpqPy2feO5CD6iU+sum8Bk4gCsmC+0Rlx a7JTPMIsCxbPlPD4P0qsWxNS//zPXVhfsRGGb1INcBT5b+yUFaR1CVPOGpqe3DOh32N3 fRg3G5TmK2nxmw08pUv+YfXtYLZKG0nWR+q8bxm3waxUUAao1GMLkfu6jfBWzOn1wPZO NUUHcPlFpBctEvfVLS9rdfF2XMkbdi2Uhinh9dddIMA7EFCMAPDVdObBZGEc9Vw4YH0V ISnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XOnyOd+V; 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 cf10si10924371edb.247.2021.06.14.03.32.58; Mon, 14 Jun 2021 03:33:21 -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=XOnyOd+V; 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 S233134AbhFNKcu (ORCPT + 99 others); Mon, 14 Jun 2021 06:32:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:38204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232959AbhFNKbs (ORCPT ); Mon, 14 Jun 2021 06:31:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D6F5561004; Mon, 14 Jun 2021 10:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623666586; bh=DisSFzvAF6qGHSND4P9j6dJWTVSDaAQaOnbyeJ5apR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XOnyOd+V/dtEUEo26o0HTrIUzU+Dl9QtkXzUwZuimjzWVar45/xbmBiDBT2WKpBHd Iy2/AAReZPdOziwvmhGcrGy7zbgOBNRdmF5Z6zXRr7aociQ8/TfoJI+Xc8PsWPV5xr ekte8QeVstZrOHKCRsdXnRvbNVEGemXU8K+EFrkA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dai Ngo , Trond Myklebust Subject: [PATCH 4.4 32/34] NFSv4: nfs4_proc_set_acl needs to restore NFS_CAP_UIDGID_NOMAP on error. Date: Mon, 14 Jun 2021 12:27:23 +0200 Message-Id: <20210614102642.612229879@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102641.582612289@linuxfoundation.org> References: <20210614102641.582612289@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 @@ -4887,6 +4887,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);