Linux NFS development
 help / color / mirror / Atom feed
From: Chuck Lever <cel@kernel.org>
To: NeilBrown <neil@brown.name>, Jeff Layton <jlayton@kernel.org>
Cc: Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	linux-nfs@vger.kernel.org
Subject: Re: [PATCH v2 14/14] nfsd: use do_lookup_open() for non-creating open requests too.
Date: Mon,  6 Jul 2026 10:36:46 -0400	[thread overview]
Message-ID: <20260706143647.1243020-1-cel@kernel.org> (raw)
In-Reply-To: <20260705222032.1240057-15-neilb@ownmail.net>

Hi Neil,

Thanks for jumping on the Sashiko findings. Codex review identified
three correctness concerns which I've confirmed with Claude are not
false positives:

1. do_lookup_open() takes write access unconditionally.

	error = mnt_want_write(parent->mnt);
	if (error)
		return ERR_PTR(error);

   Fine for a create. But a read-only OPEN with no create now returns
   -EROFS on anything mounted read-only at the VFS layer: squashfs,
   iso9660, a read-only bind mount, a snapshot. The old path didn't ask
   for write until nfsd_open() actually opened the file, and for
   O_RDONLY it never asked at all, so these opens worked.

   Worth stressing that this isn't the "ro" export option. That keeps
   the underlying mount writable and is enforced in nfsd, so it's fine.
   Only genuinely read-only mounts break, which is probably why it
   slipped past testing. Can we make the mnt_want_write() conditional on
   O_CREAT? The read-only-open setattr path already re-takes write for
   itself, so it shouldn't need the blanket grab.

2. We open the target before checking it's a regular file.

   do_lookup_open() runs dentry_open() on any positive dentry, and
   nfsd_check_obj_isreg() doesn't run until nfsd4_open_file() returns.
   There's no O_NONBLOCK on that open, so an OPEN of an existing FIFO
   sits in fifo_open() waiting for a peer, and it waits with the parent
   directory's i_rwsem still held from start_creating(). One client can
   pin an nfsd thread and the parent directory that way; a handful of
   them and the pool is spent. A device node does the same thing through
   its ->open. We used to know the type before we opened anything, so
   could we check d_is_reg() ahead of the dentry_open()?

   In fairness this isn't new to 14/14. "always open file in
   nfsd4_create_file()" already opened existing files for the UNCHECKED
   case; this patch just extends it to plain reads.

3. Mount crossing and the target export check are gone.

   nfsd_lookup_dentry() went through nfsd_mountpoint() and
   nfsd_cross_mnt() and revalidated the export it crossed into.
   start_creating() is a plain one-component lookup, and we fh_compose()
   against the parent export. Bind-mount one regular file over another
   inside an export and the new path hands back the covered file instead
   of the mounted one, with no check_nfsd_access() on the real target.
   Narrow, since only file-over-file mounts reach it (a directory trips
   the isreg check), but the behavior did change.

Actually some of the suspect logic is added in earlier patches, only to
be exposed by this final switchover patch, so I'll wait for a re-roll.


--
Chuck Lever

      reply	other threads:[~2026-07-06 14:36 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-05 22:19 [PATCH v2 00/14] nfsd: refactor nfs4_create_file() NeilBrown
2026-07-05 22:19 ` [PATCH v2 01/14] nfsd: honour client-provided attributes for NFS4_CREATE_EXCLUSIVE4_1 NeilBrown
2026-07-06 16:14   ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 02/14] nfsd: replace fh_fill_both_attrs() with fh_fill_post_noop() NeilBrown
2026-07-06 16:15   ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 03/14] nfsd: move fh_want_write() after preamble in nfsd4_create_file() NeilBrown
2026-07-06 16:15   ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 04/14] nfsd: move more nfs-specific code into preamble of nfsd4_create_file() NeilBrown
2026-07-06 16:16   ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 05/14] nfsd: remove subtlety from nfsd4_create_file() NeilBrown
2026-07-06 16:16   ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 06/14] nfsd: in nfsd4_create_file() let VFS report if file was created NeilBrown
2026-07-06 15:52   ` Jeff Layton
2026-07-06 23:28     ` NeilBrown
2026-07-05 22:19 ` [PATCH v2 07/14] nfsd: nfsd4_create_file(): Move NFSD_MAY_CREATE check earlier NeilBrown
2026-07-06 16:19   ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 08/14] nfsd: always open file in nfsd4_create_file() NeilBrown
2026-07-05 22:19 ` [PATCH v2 09/14] nfsd: reduce range of directory lock " NeilBrown
2026-07-06 16:21   ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 10/14] nfsd: open-code nfsd4_vfs_create() into nfsd4_create_file() NeilBrown
2026-07-06 16:21   ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 11/14] nfsd: move some code out of the d_really_is_negative() branch in nfsd4_create_file() NeilBrown
2026-07-06 16:23   ` Jeff Layton
2026-07-05 22:19 ` [PATCH v2 12/14] nfsd: reduce want-write range " NeilBrown
2026-07-05 22:19 ` [PATCH v2 13/14] nfsd: separate out VFS-specific from from nfsd4_create_file() NeilBrown
2026-07-06 16:00   ` Jeff Layton
2026-07-06 23:29     ` NeilBrown
2026-07-05 22:19 ` [PATCH v2 14/14] nfsd: use do_lookup_open() for non-creating open requests too NeilBrown
2026-07-06 14:36   ` Chuck Lever [this message]

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=20260706143647.1243020-1-cel@kernel.org \
    --to=cel@kernel.org \
    --cc=Dai.Ngo@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox