Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2634543pxj; Mon, 14 Jun 2021 03:37:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/IqSR1CfjHO3/1JiQLiwCh1ETlWk/5x+Pgb13AG/BvCeN1OajBKfL5qPcPiASN9LfyjDM X-Received: by 2002:a17:906:f285:: with SMTP id gu5mr14656784ejb.226.1623667042641; Mon, 14 Jun 2021 03:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623667042; cv=none; d=google.com; s=arc-20160816; b=u/YSWNE8sOV4FBpmGbCHR//BCc3penTuC3kzW6AmEi1aZmRUvWdBAjDDL6bsmc/cjB Vj7tjvJN+ThZVI2sP4xRsm0Yu0DvgE3PKQHKf2Ce4LlbaylAloKqnLokxdg429d+F+po N33DuBOxK4Le3km5Oz88/XqeGQW88v7RSlsVMoKxxFw/DacK9+ohTMaisWAQofUKsc7+ LKrtlE8tVGTVxMMazVS5I4eQDyjjeHfgebwpHUVwfFwirfHEuatPw6dSdJT3ueFSAX+0 yh6dgJ8QsEIIMuh2t63nol1PhVM73WjmFlRYC8Eu096oyr1Bf1qldkYZFSQeIRLgE2bV QzSw== 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=WiV53bTOPWuxvSt314efdGztEhOCNdAHWGVRrHGM0PI=; b=Wigy2CazZJNKlo4z3teBy2DQQUfl98R2mQ/zyuXj0B2nnNXx+IIR/GcYaRy8B0DDra c0vmVHeQEtwGQBYJ+ooy9f5Qm1wUwQ8CR+EgbVGwNKwa/y0wTzDS5RqfVmltskr9a6pS DBddl5hH11RpHASEO5bwXs+nuJ0dPvmn8nd5O6CYHbKO4tUK1MKqSdiQPwmDpL0WTtmz +BSvjPeQHD5UqsHsNrYbqRM/+2uHDu4ek32A4LSCqBPmsk9M4ItsBrYXfa59oYZMUzB3 7JUUFtuHkfYRHfjUhXzeRDPGcCcENbIFH4VYgUvNUGyozG3KJKh2bjNzwombBgPuaT7m Bgmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LVFoIaQi; 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 lc28si11526393ejc.270.2021.06.14.03.36.59; Mon, 14 Jun 2021 03:37:22 -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=LVFoIaQi; 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 S233398AbhFNKgx (ORCPT + 99 others); Mon, 14 Jun 2021 06:36:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:38348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232937AbhFNKeX (ORCPT ); Mon, 14 Jun 2021 06:34:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 51F51613D9; Mon, 14 Jun 2021 10:32:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623666720; bh=ee0kuuNohkMrmsZ52BlDHlUuQJPZqLZoxGPBNEPm7UE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LVFoIaQiY/5fYv4o0Z2d5tZOgUwUmrTCYWVoH9Iu/mKtpGdmh9uOycE73KqEzu5Zw ZqcVCzBaHRPep5YjSU4oMSTyxZJeKAtjG9T0M/X4z8V19boADcZ/t0aIB39r9e30p1 G3aYAW+UfILwbup/qAcB3hQBFndKc3iXN//ompcY= 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.9 38/42] NFSv4: nfs4_proc_set_acl needs to restore NFS_CAP_UIDGID_NOMAP on error. Date: Mon, 14 Jun 2021 12:27:29 +0200 Message-Id: <20210614102643.919139152@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102642.700712386@linuxfoundation.org> References: <20210614102642.700712386@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 @@ -5183,6 +5183,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);