From nobody Thu Apr 2 19:56:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08685ECAAD8 for ; Wed, 21 Sep 2022 15:48:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231158AbiIUPsC (ORCPT ); Wed, 21 Sep 2022 11:48:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231622AbiIUPra (ORCPT ); Wed, 21 Sep 2022 11:47:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DB699A687; Wed, 21 Sep 2022 08:47:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C42E0B82714; Wed, 21 Sep 2022 15:47:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07D99C433C1; Wed, 21 Sep 2022 15:47:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663775230; bh=Z/e0vmhAC7XFBvq3h2gIDwjZB3brPLREn1+e+ct5G8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BlEO2isaoKMre5tBrh2E16fhHeTo/rV9wty89cfxCXVtdd9RcA8fegY4l/jK+fJRd RMzT1//mMCOEg33UyiKn37g+JjiyVqb2hY7oTPExrs+7cqKSRc8JiDOB8MivFrbTG3 jnsvIkZ8rjNuwuYxGWReM++ABzQq2/bkmy09Y10I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuck Lever III , Trond Myklebust , Sasha Levin Subject: [PATCH 5.19 07/38] NFSv4: Turn off open-by-filehandle and NFS re-export for NFSv4.0 Date: Wed, 21 Sep 2022 17:45:51 +0200 Message-Id: <20220921153646.531097048@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220921153646.298361220@linuxfoundation.org> References: <20220921153646.298361220@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Trond Myklebust [ Upstream commit 2a9d683b48c8a87e61a4215792d44c90bcbbb536 ] The NFSv4.0 protocol only supports open() by name. It cannot therefore be used with open_by_handle() and friends, nor can it be re-exported by knfsd. Reported-by: Chuck Lever III Fixes: 20fa19027286 ("nfs: add export operations") Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/super.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 6ab5eeb000dc..5e4bacb77bfc 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -1051,22 +1051,31 @@ static void nfs_fill_super(struct super_block *sb, = struct nfs_fs_context *ctx) if (ctx->bsize) sb->s_blocksize =3D nfs_block_size(ctx->bsize, &sb->s_blocksize_bits); =20 - if (server->nfs_client->rpc_ops->version !=3D 2) { - /* The VFS shouldn't apply the umask to mode bits. We will do - * so ourselves when necessary. + switch (server->nfs_client->rpc_ops->version) { + case 2: + sb->s_time_gran =3D 1000; + sb->s_time_min =3D 0; + sb->s_time_max =3D U32_MAX; + break; + case 3: + /* + * The VFS shouldn't apply the umask to mode bits. + * We will do so ourselves when necessary. */ sb->s_flags |=3D SB_POSIXACL; sb->s_time_gran =3D 1; - sb->s_export_op =3D &nfs_export_ops; - } else - sb->s_time_gran =3D 1000; - - if (server->nfs_client->rpc_ops->version !=3D 4) { sb->s_time_min =3D 0; sb->s_time_max =3D U32_MAX; - } else { + sb->s_export_op =3D &nfs_export_ops; + break; + case 4: + sb->s_flags |=3D SB_POSIXACL; + sb->s_time_gran =3D 1; sb->s_time_min =3D S64_MIN; sb->s_time_max =3D S64_MAX; + if (server->caps & NFS_CAP_ATOMIC_OPEN_V1) + sb->s_export_op =3D &nfs_export_ops; + break; } =20 sb->s_magic =3D NFS_SUPER_MAGIC; --=20 2.35.1