From patchwork Sat Mar 22 00:13:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 14026111 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 120CE1372 for ; Sat, 22 Mar 2025 00:13:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742602402; cv=none; b=uCvlPj/xC4hFWbLM10m8cji2GLtWDtAlaH87sssco5DiGhVkPEUkugWrNbhWAz5SpzSVrfRMob6EmkeMwyzA6JvKrP+OT1ClMxz+vsMnjiVIp3BhBcvNDs8ztX3KZMYmhCfEusDiW+iO1/G/091kyVHhyPWS8pdi3h18G7PrdC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742602402; c=relaxed/simple; bh=1asiAw1ri2UWtE20KHscvm9P09T/V+kTqFH4FeHo/Dg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G4INrqWezqECoCoMNVoFcxHl7yfewDd6Sw4n1+8dr3F0XjYbimY0O8aSWoQ/hjpUKmVyMykQ/oGXv7qZpdJpEM7XaAhrN2toKIRHk+SoYgs8uFM0buCUstWhRhKDqP3ekFpCfAmlBdqA9UxXZ2ZKRFRheyxYzEgyMRcZrsaHDBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=HkLf3s7q; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HkLf3s7q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742602400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=45hLfyuBD/lS8WUvn+1KftJK5CXmdLmMv7j8pBaYo4c=; b=HkLf3s7qUvpHqn1aihJIB9ozRg/g5wTO5rZB7qZfH3NkkiwfXLrQY79iOdTgOLctAVCyxo KHWqoOkL24hsP6IS4C+jnRTdoSAj6R/WjKBdftpmxMJEriAtA+eKSc0BWAUCpoM4bkSwCf c5/x/gzMnznrCzbdsBDYcltbFhWIe1Y= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-150-1HwaIsOBN_aytdznGGa7mg-1; Fri, 21 Mar 2025 20:13:16 -0400 X-MC-Unique: 1HwaIsOBN_aytdznGGa7mg-1 X-Mimecast-MFC-AGG-ID: 1HwaIsOBN_aytdznGGa7mg_1742602394 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C444A18007E1; Sat, 22 Mar 2025 00:13:14 +0000 (UTC) Received: from okorniev-mac.redhat.com (unknown [10.22.64.19]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0EB6E19560AF; Sat, 22 Mar 2025 00:13:12 +0000 (UTC) From: Olga Kornievskaia To: chuck.lever@oracle.com, jlayton@kernel.org Cc: linux-nfs@vger.kernel.org, neilb@suse.de, Dai.Ngo@oracle.com, tom@talpey.com, Olga Kornievskaia Subject: [PATCH 1/3] nfsd: fix access checking for NLM under XPRTSEC policies Date: Fri, 21 Mar 2025 20:13:04 -0400 Message-Id: <20250322001306.41666-2-okorniev@redhat.com> In-Reply-To: <20250322001306.41666-1-okorniev@redhat.com> References: <20250322001306.41666-1-okorniev@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 When an export policy with xprtsec policy is set with "tls" and/or "mtls", but an NFS client is doing a v3 xprtsec=tls mount, then NLM locking calls fail with an error because there is currently no support for NLM with TLS. Until such support is added, allow NLM calls under TLS-secured policy. Fixes: 4cc9b9f2bf4d ("nfsd: refine and rename NFSD_MAY_LOCK") Signed-off-by: Olga Kornievskaia --- fs/nfsd/export.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 0363720280d4..88ae410b4113 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -1124,7 +1124,8 @@ __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp, test_bit(XPT_PEER_AUTH, &xprt->xpt_flags)) goto ok; } - goto denied; + if (!may_bypass_gss) + goto denied; ok: /* legacy gss-only clients are always OK: */ From patchwork Sat Mar 22 00:13:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 14026112 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 DD5C92E3371 for ; Sat, 22 Mar 2025 00:13:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742602404; cv=none; b=f2s+AHzWM3EiGlJ98a0o1h6kfGjmCVRMVDveF1ycBcBqT45+VADjlTSqIlJYACw/eIaLv4YLp1ZNy/IcNf+PI39T5Mejpmveb62dX/YKVc3LCPil8M8TwV11wE72dDqwbMZzzNu3AS/8YtKuQiktAtPbKUJbc+HZRtrhpaEtc/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742602404; c=relaxed/simple; bh=kmj1nyCRII/tS6gbX/G5Ycz12ZOx/v58rNByfUQ/gqw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=If7YyyiSeGSq7j7jcour6KWkGUBKojyRWm0uVC/i0mCiup2PdjABLCs4QBTnOpCB8UDRrSoztGPfm6rDXD++h7k48Fmsd7ggyHd1QdMOaw7KTXY51CMuSfh11nQ+P0WeQzI4ayrQlwWC8XT5ne5bR1pxahFHquMjGWRo19XzQb8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Ayn9rDcx; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ayn9rDcx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742602402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YDiO4WQUSD1u8H75do5m+dIMRG7CpKjmHiZjR5AkofE=; b=Ayn9rDcxA8oA3wQY5GGucbZ2D8hJMBaPAZgOduDFH6yunB8+iAp5xeGetXmM5NDxouP0GV B2S3wWO4ch9I2Er+0q+xqWMueY+hheuTEKUrnTFd2tfUaDu0OacPL0wxVMpodcrzjyuuuk Cy1sep6nMtDu+KGBHMwB/IAvTcizFo4= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-653-VodmJoAqPsSdQaZnuzA0_Q-1; Fri, 21 Mar 2025 20:13:18 -0400 X-MC-Unique: VodmJoAqPsSdQaZnuzA0_Q-1 X-Mimecast-MFC-AGG-ID: VodmJoAqPsSdQaZnuzA0_Q_1742602397 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 307F9180049D; Sat, 22 Mar 2025 00:13:17 +0000 (UTC) Received: from okorniev-mac.redhat.com (unknown [10.22.64.19]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CC1561955DCE; Sat, 22 Mar 2025 00:13:15 +0000 (UTC) From: Olga Kornievskaia To: chuck.lever@oracle.com, jlayton@kernel.org Cc: linux-nfs@vger.kernel.org, neilb@suse.de, Dai.Ngo@oracle.com, tom@talpey.com, Olga Kornievskaia Subject: [PATCH 2/3] nfsd: adjust nfsd4_spo_must_allow checking order Date: Fri, 21 Mar 2025 20:13:05 -0400 Message-Id: <20250322001306.41666-3-okorniev@redhat.com> In-Reply-To: <20250322001306.41666-1-okorniev@redhat.com> References: <20250322001306.41666-1-okorniev@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Prior to this patch, some non-4.x NFS operations such as NLM calls have to go thru export policy checking would end up calling nfsd4_spo_must_allow() function and lead to an out-of-bounds error because no compound state structures needed by nfsd4_spo_must_allow() are present in the svc_rqst request structure. Instead, do the nfsd4_spo_must_allow() checking after the may_bypass_gss check which is geared towards allowing various calls such as NLM while export policy is set with sec=krb5:... Fixes: 4cc9b9f2bf4d ("nfsd: refine and rename NFSD_MAY_LOCK") Signed-off-by: Olga Kornievskaia --- fs/nfsd/export.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 88ae410b4113..02f26cbd59d0 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -1143,15 +1143,6 @@ __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp, return nfs_ok; } - /* If the compound op contains a spo_must_allowed op, - * it will be sent with integrity/protection which - * will have to be expressly allowed on mounts that - * don't support it - */ - - if (nfsd4_spo_must_allow(rqstp)) - return nfs_ok; - /* Some calls may be processed without authentication * on GSS exports. For example NFS2/3 calls on root * directory, see section 2.3.2 of rfc 2623. @@ -1168,6 +1159,14 @@ __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp, return 0; } } + /* If the compound op contains a spo_must_allowed op, + * it will be sent with integrity/protection which + * will have to be expressly allowed on mounts that + * don't support it + */ + if (nfsd4_spo_must_allow(rqstp)) + return nfs_ok; + denied: return nfserr_wrongsec; From patchwork Sat Mar 22 00:13:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 14026113 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 5D0E3F9C1 for ; Sat, 22 Mar 2025 00:15:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742602542; cv=none; b=hIZDDt2eG4k58Dddmuz6f49kPVT4rIhwuBiSGyUz2CVJPbszJvJFukTmLc6/msUSQrVNfxTaItVQYSc2osDiKe3bsUAcqrJHlh9Qaf1jXEAJfUoXawDBqz9hu52W1Jw5F2LpVmyOdeKzEgBM3CHo0BH9mVXqcg3CLs5e1vm9KDg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742602542; c=relaxed/simple; bh=JJO4elqzLEeUMZiR7QiSlsu8Hmcj+RXFnnfBB3JpTig=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MfEZ1752dHON8bqQ7z7ygHs6WTpvZtg7t96VrBrdrnaAOTbQV9E3W0Rjx2I0S7X/mOARAh6cB1m5xAKVmSQ34rVjJHwSB3hGMwJAGxGhmjLAuJLdYHs3GRbo3ClDhwSpX8DpZseUDO+diWmbn4ZD9dnFBX8kS4NBFs3T+v1c10c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LQckMva5; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LQckMva5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742602540; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nAs8LP/AD062of6xSns8W2yOfNMarC/kAE2NWetGNt4=; b=LQckMva5zasxEEHhHb0mTMtYXBzzlPAzJknpR2vQVY4fMpo8dbrYJK2+umrvExq8f7vtbd mf2sp4f6TZ4XMsmYkB/m1Q+v9Q482or7bK7/1jGjgEFIeDtqcojtjKNG355SZb/x02HXmQ lPPIzvQM1zvifXME7QejGNMgmCndOKk= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-99-JhoxJA8INoaIuHCvpyJipg-1; Fri, 21 Mar 2025 20:15:36 -0400 X-MC-Unique: JhoxJA8INoaIuHCvpyJipg-1 X-Mimecast-MFC-AGG-ID: JhoxJA8INoaIuHCvpyJipg_1742602535 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 637D018004A9; Sat, 22 Mar 2025 00:15:35 +0000 (UTC) Received: from okorniev-mac.redhat.com (unknown [10.22.64.19]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0616519560AF; Sat, 22 Mar 2025 00:15:33 +0000 (UTC) From: Olga Kornievskaia To: chuck.lever@oracle.com, jlayton@kernel.org Cc: linux-nfs@vger.kernel.org, neilb@suse.de, Dai.Ngo@oracle.com, tom@talpey.com, Olga Kornievskaia Subject: [PATCH 3/3] nfsd: reset access mask for NLM calls in nfsd_permission Date: Fri, 21 Mar 2025 20:13:06 -0400 Message-Id: <20250322001306.41666-4-okorniev@redhat.com> In-Reply-To: <20250322001306.41666-1-okorniev@redhat.com> References: <20250322001306.41666-1-okorniev@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 NLM locking calls need to pass thru file permission checking and for that prior to calling inode_permission() we need to set appropriate access mask. Fixes: 4cc9b9f2bf4d ("nfsd: refine and rename NFSD_MAY_LOCK") Signed-off-by: Olga Kornievskaia --- fs/nfsd/vfs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 4021b047eb18..7928ae21509f 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -2582,6 +2582,13 @@ nfsd_permission(struct svc_cred *cred, struct svc_export *exp, if ((acc & NFSD_MAY_TRUNC) && IS_APPEND(inode)) return nfserr_perm; + /* + * For the purpose of permission checking of NLM requests, + * the locker must have READ access or own the file + */ + if (acc & NFSD_MAY_NLM) + acc = NFSD_MAY_READ | NFSD_MAY_OWNER_OVERRIDE; + /* * The file owner always gets access permission for accesses that * would normally be checked at open time. This is to make