Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp457058lqp; Wed, 12 Jun 2024 06:52:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVXVD4ZL4GRzXJC2q6UQSC0MjtzMlaXe6UxxAGN1UMYCNpJDzKeslaVBjlAJhSS0RBte8YfP2DKsP18MnmZYSOcvWQxC8tTWRZqiPPvuQ== X-Google-Smtp-Source: AGHT+IG78vYS0sw9OvPwqxDpY+Fc0M4PhVeBMrbgfb223apwQC0wWpzm0KQmqcjxRMYlM/1BJsOj X-Received: by 2002:a05:6a20:daa5:b0:1b1:ec17:ad81 with SMTP id adf61e73a8af0-1b8a9be97f1mr2396470637.29.1718200351170; Wed, 12 Jun 2024 06:52:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718200351; cv=pass; d=google.com; s=arc-20160816; b=XOQUKvkFSepOxZoAxlKRvCDDqKmG1NzauYeLMMxQ7B0WuFo+YCPaVK4k0ZDUbXCUFN CIaIXAxra/zEwZI71SnN11yU+unUQ60cNf0woaRNf7KN5XfskKaF8MniW7LJu6uqMOmu rMmt9KhFalSX3hK4Rcn6/bIeuFSHW3F74AO7Jdk3SAJI2hK04Dcuep75iyZb2jEwMRHS uMO72ome1OBpcXqd0N0wwhQROpcrDMmlXccVRmRakfiRdXrcbjkE7DlX0vRXRQThWOOG YmxFSJnqh1FQCT3gIsehfWLn/W09+cX9Ug+MoqPn/8V3yQu4OFhgReX5a0SxgTrtP8P/ RdsA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=tHRzsLw+8V0TG69Kd4snUUubGcKXULSuGi80HK+GWIU=; fh=gNGh0dYniQsmJcGeTmVbb1ExHeqpm5XpmVQamNBrIig=; b=u8/ohSPSL//ukQ+5HGdHh6czytQxC3oUsopi0nJ5/C7w0FW1/J0QuDHJvullSv/tuG iE1Kfq0qKmaEm8AdXL0CxnU0W7cHO/E+oA5pCXO4cIZQ3QUVU5vzhxawXwT9RGO0qjC2 +T9RfEvyugHFtFtL/NlsKnwuPjVfUWEPJ0mFUpXkcMXrVsj5W+iQ8Q+lEIYR5iH4U+oX Cw/3YNSiafKE2ur9yd/37UOkipN0CS+kVvwk+NLO+0/ygd+UcKqgSoBHFe8ChgD+MGLg gEsxwvFfJ//IEi6Ga2OrDwD8kyaxSyzUvcSV6XKY0xPtzPhfbSD1niO/hdRlOJsLNVng qUmw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CzHfhVv0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3695-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3695-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d2e1a72fcca58-705c4f8d07dsi411497b3a.71.2024.06.12.06.52.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 06:52:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3695-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CzHfhVv0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3695-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3695-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id EFD48B20A36 for ; Wed, 12 Jun 2024 13:52:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6B4317C7D5; Wed, 12 Jun 2024 13:52:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CzHfhVv0" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2D0C176ACE for ; Wed, 12 Jun 2024 13:52:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718200323; cv=none; b=oKaGyoMePBgMSGmcz76CMBbJfIV/RlTRf1+S8yNFtvEhint3MzdT51v474G3tfOGuAKMYtbp0l/VacgNOWJJDWnvT2Tc67YhJknrYuXcrbJjED0ZKnpfS9HRD/lsP7jyyr30jlv6Gj+oUIVLNZe2w/GbpcDjQd9aHDLBVbfC0iM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718200323; c=relaxed/simple; bh=CTeoL6qeqRTNKUfhkSqehTngSkPOgwYStfeqdeQ8nZY=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=EqB5oVjEtUfXt6SARmeUmhklhelXdpxVAUEy0cVKoJq0yBsKVtckjZ+KrxEs/11qEd1U6hP4lEWT3+CS4zvnzfpHKuWDqNjDtOsvWYfW498y5oQ6k0XDoKA+NMrk5/yZyIihndrQg5W8t+Zhf9GAp5jpeekg0Ks7pAaox6HoNac= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CzHfhVv0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62871C116B1; Wed, 12 Jun 2024 13:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718200323; bh=CTeoL6qeqRTNKUfhkSqehTngSkPOgwYStfeqdeQ8nZY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=CzHfhVv0o63lUeOng4i/LTqmktuY6cpjtI7mNoYqHph6obJPFvawTw0Uzez8QoiZt Ka8fImfkQ39QT7SH51eCcNgbd9L+4G30WekI5Tn68aKvlgQNOI1QNOvLk0mR2SS2/j KvldHS/tgnNOYUQAuOUiwC8avxzBWntJ/oGYqlr/Qt84xBx0w/CNbUeL0VnrxaJSLY qg1VsTTvzcSLWkaCMc2uNecGonzCCoCwu7RwZFvirUwcB6cEmBWRYkUZgluBhY6BIK Y2LbfpdimiXKmC9GXGFDKBQ+goeALA/Yz9Wc2b9Nl3+fwYKgon15KKoKqqpx5dvjIg KuhwZCt4d5JJQ== Message-ID: <98ef88e17f3996c2584f49be34bbee0ec78d72b1.camel@kernel.org> Subject: Re: [PATCH v2] NFSD: Support write delegations in LAYOUTGET From: Jeff Layton To: cel@kernel.org, linux-nfs@vger.kernel.org Cc: Neil Brown , Dai Ngo , Olga Kornievskaia , Tom Talpey , Chuck Lever , Christoph Hellwig Date: Wed, 12 Jun 2024 09:52:01 -0400 In-Reply-To: <20240611193645.65792-2-cel@kernel.org> References: <20240611193645.65792-2-cel@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.4 (3.50.4-1.fc39) Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Tue, 2024-06-11 at 15:36 -0400, cel@kernel.org wrote: > From: Chuck Lever >=20 > I noticed LAYOUTGET(LAYOUTIOMODE4_RW) returning NFS4ERR_ACCESS > unexpectedly. The NFS client had created a file with mode 0444, and > the server had returned a write delegation on the OPEN(CREATE). The > client was requesting a RW layout using the write delegation stateid > so that it could flush file modifications. >=20 > Creating a read-only file does not seem to be problematic for > NFSv4.1 without pNFS, so I began looking at NFSD's implementation of > LAYOUTGET. >=20 > The failure was because fh_verify() was doing a permission check as > part of verifying the FH presented during the LAYOUTGET. It uses the > loga_iomode value to specify the @accmode argument to fh_verify(). > fh_verify(MAY_WRITE) on a file whose mode is 0444 fails with -EACCES. >=20 > To permit LAYOUT* operations in this case, add OWNER_OVERRIDE when > checking the access permission of the incoming file handle for > LAYOUTGET and LAYOUTCOMMIT. >=20 > Cc: Christoph Hellwig > X-Cc: stable@vger.kernel.org=C2=A0# v6.6+ > Message-Id: 4E9C0D74-A06D-4DC3-A48A-73034DC40395@oracle.com > Signed-off-by: Chuck Lever > --- > =C2=A0fs/nfsd/nfs4proc.c | 5 +++-- > =C2=A01 file changed, 3 insertions(+), 2 deletions(-) >=20 > diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c > index 46bd20fe5c0f..2e39cf2e502a 100644 > --- a/fs/nfsd/nfs4proc.c > +++ b/fs/nfsd/nfs4proc.c > @@ -2269,7 +2269,7 @@ nfsd4_layoutget(struct svc_rqst *rqstp, > =C2=A0 const struct nfsd4_layout_ops *ops; > =C2=A0 struct nfs4_layout_stateid *ls; > =C2=A0 __be32 nfserr; > - int accmode =3D NFSD_MAY_READ_IF_EXEC; > + int accmode =3D NFSD_MAY_READ_IF_EXEC | > NFSD_MAY_OWNER_OVERRIDE; > =C2=A0 > =C2=A0 switch (lgp->lg_seg.iomode) { > =C2=A0 case IOMODE_READ: > @@ -2359,7 +2359,8 @@ nfsd4_layoutcommit(struct svc_rqst *rqstp, > =C2=A0 struct nfs4_layout_stateid *ls; > =C2=A0 __be32 nfserr; > =C2=A0 > - nfserr =3D fh_verify(rqstp, current_fh, 0, NFSD_MAY_WRITE); > + nfserr =3D fh_verify(rqstp, current_fh, 0, > + =C2=A0=C2=A0 NFSD_MAY_WRITE | > NFSD_MAY_OWNER_OVERRIDE); > =C2=A0 if (nfserr) > =C2=A0 goto out; > =C2=A0 Reviewed-by: Jeff Layton