All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dominik Maier <dmnk@google.com>
To: Chuck Lever <cel@kernel.org>, Jeff Layton <jlayton@kernel.org>
Cc: NeilBrown <neil@brown.name>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <Dai.Ngo@oracle.com>,  Tom Talpey <tom@talpey.com>,
	linux-nfs@vger.kernel.org, dmnk+artist@google.com
Subject: [PATCH v3 2/2] nfsd: require NFSD_MAY_EXEC when acquiring directory delegations
Date: Mon, 30 Nov 2026 17:04:19 +0100	[thread overview]
Message-ID: <20261130160419.2644777-3-dmnk@google.com> (raw)
In-Reply-To: <20261130160419.2644777-1-dmnk@google.com>

Clients can obtain a directory delegation without search permission and
receive child filehandles in change notifications even when LOOKUP is
denied.

Opening a directory for delegation currently checks only read access and
applies the file-owner permission override to directories as well,
allowing delegations on mode 0744 directories for non-owners and mode
0400 directories for the owner.

Require search permission when acquiring a directory for delegation and
restrict the owner permission override to regular files, matching normal
file opens.

Fixes: 544a0ee152f0 ("nfsd: allow filecache to hold S_IFDIR files")
Cc: stable@vger.kernel.org
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Dominik Maier <dmnk@google.com>
---
 fs/nfsd/filecache.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index 162d07eb5be4..a703d376a52f 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -1197,13 +1197,14 @@ nfsd_file_do_acquire(struct svc_rqst *rqstp, struct net *net,
 	__be32 status;
 	int ret;
 
+	if (type == S_IFREG)
+		may_flags |= NFSD_MAY_OWNER_OVERRIDE;
 retry:
 	if (rqstp)
-		status = fh_verify(rqstp, fhp, type,
-				   may_flags|NFSD_MAY_OWNER_OVERRIDE);
+		status = fh_verify(rqstp, fhp, type, may_flags);
 	else
 		status = fh_verify_local(net, cred, client, fhp, type,
-					 may_flags|NFSD_MAY_OWNER_OVERRIDE);
+					 may_flags);
 
 	if (status != nfs_ok)
 		return status;
@@ -1475,7 +1476,8 @@ nfsd_file_acquire_dir(struct svc_rqst *rqstp, struct svc_fh *fhp,
 		      struct nfsd_file **pnf)
 {
 	return nfsd_file_do_acquire(rqstp, SVC_NET(rqstp), NULL, NULL, fhp,
-				    NFSD_MAY_READ|NFSD_MAY_64BIT_COOKIE,
+				    NFSD_MAY_READ | NFSD_MAY_EXEC |
+				    NFSD_MAY_64BIT_COOKIE,
 				    NULL, S_IFDIR, false, pnf);
 }
 
-- 
2.56.1.911.g883d8bcb20-goog


  parent reply	other threads:[~2026-11-30 16:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 16:04 [PATCH v3 0/2] nfsd: enforce search permission on directory delegations Dominik Maier
2026-11-30 16:04 ` [PATCH v3 1/2] nfsd: return GDD4_UNAVAIL on nfserr_acces in nfsd4_get_dir_delegation() Dominik Maier
2026-11-30 18:48   ` Chuck Lever
2026-11-30 16:04 ` Dominik Maier [this message]
2026-11-30 18:48   ` [PATCH v3 2/2] nfsd: require NFSD_MAY_EXEC when acquiring directory delegations Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130160419.2644777-3-dmnk@google.com \
    --to=dmnk@google.com \
    --cc=Dai.Ngo@oracle.com \
    --cc=cel@kernel.org \
    --cc=dmnk+artist@google.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.