Linux-NFS Archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: NeilBrown <neil@brown.name>,
	1128861@bugs.debian.org, Chuck Lever <cel@kernel.org>
Cc: Jeff Layton <jlayton@kernel.org>,
	Thorsten Leemhuis <regressions@leemhuis.info>,
	Tj <tj.iam.tj@proton.me>,
	 linux-nfs@vger.kernel.org,
	Olga Kornievskaia <okorniev@redhat.com>,
	 stable@vger.kernel.org
Subject: Re: Bug#1128861: [PATCH] lockd: fix TEST handling when not all permissions are available.
Date: Wed, 25 Mar 2026 21:29:09 +0100	[thread overview]
Message-ID: <eab4db41a02c4342bd6e5397f663c4e651f22e31.camel@decadent.org.uk> (raw)
In-Reply-To: <177442248735.2237155.773724155681455344@noble.neil.brown.name>

[-- Attachment #1: Type: text/plain, Size: 2571 bytes --]

On Wed, 2026-03-25 at 18:08 +1100, NeilBrown wrote:
> On Wed, 25 Mar 2026, Chuck Lever wrote:
> > 
> > On Tue, Mar 24, 2026, at 6:13 AM, NeilBrown wrote:
> > > From: NeilBrown <neil@brown.name>
> > > 
> > > The F_GETLK fcntl can work with either read access or write access or
> > > both.  It can query F_RDLCK and F_WRLCK locks in either case.
> > > 
> > > However lockd currently treats F_GETLK similar to F_SETLK in that read
> > > access is required to query an F_RDLCK lock and write access is required
> > > to query a F_WRLCK lock.
> > > 
> > > This is wrong and can cause problem - e.g.  when qemu accesses a
> > > read-only (e.g. iso) filesystem image over NFS (though why it queries
> > > if it can get a write lock - I don't know.  But it does, and this works
> > > with local filesystems).
> > > 
> > > So we need TEST requests to be handled differently.  To do this:
> > > 
> > > - change nlm_do_fopen() to accept O_RDWR as a mode and in that case
> > >   succeed if either a O_RDONLY or O_WRONLY file can be opened.
> > > - change nlm_lookup_file() to accept a mode argument from caller,
> > >   instead of deducing base on lock time, and pass that on to nlm_do_fopen()
> > > - change nlm4svc_retrieve_args() and nlmsvc_retrieve_args() to detect
> > >   TEST requests and pass O_RDWR as a mode to nlm_lookup_file, passing
> > >   the same mode as before for other requests.  Also set
> > >    lock->fl.c.flc_file to whichever file is available for TEST requests.
> > > - change nlmsvc_testlock() to also not calculate the mode, but to use
> > >   whenever was stored in lock->fl.c.flc_file.
> > > 
> > > Reported-by: Tj <tj.iam.tj@proton.me>
> > > Link:  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1128861
> > > Fixes: 7f024fcd5c97 ("Keep read and write fds with each nlm_file")
> > > Signed-off-by: NeilBrown <neil@brown.name>
> > 
> > Hi Neil, which kernels should this fix apply to?
> > 
> 
> v6.13 and later. So linux-6.18.y and linux-6.19.y

6.12.y is also affected since commit 4cc9b9f2bf4d was backported there
(triggering this bug report).

Ben.

> 
> The Fixes: tag is actually wrong.  This bug has been present forever.
> However a different bug that 
>   Commit: 4cc9b9f2bf4d ("nfsd: refine and rename NFSD_MAY_LOCK")
> fixed was hiding the bug.
> 
> So it should probably be marked
>   Fixes: 4cc9b9f2bf4d ("nfsd: refine and rename NFSD_MAY_LOCK")
> with an explanation.
> 
> NeilBrown

-- 
Ben Hutchings
Theory and practice are closer in theory than in practice - John Levine

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      parent reply	other threads:[~2026-03-25 20:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24  2:09 Regression: Missing check in nfsd_permission() causes -ENOLCK No locks available Tj
2026-02-24 12:50 ` Tj
2026-02-27  9:54 ` Thorsten Leemhuis
2026-03-04 10:28   ` Bug#1128861: " Salvatore Bonaccorso
2026-03-04 15:05   ` Olga Kornievskaia
2026-03-12 12:30   ` Jeff Layton
2026-03-12 22:39     ` NeilBrown
2026-03-13 14:11       ` Jeff Layton
2026-03-04 15:44 ` Sasha Levin
2026-03-04 23:03 ` NeilBrown
2026-03-12  8:55   ` Thorsten Leemhuis
2026-03-12 12:10     ` Jeff Layton
2026-03-24 10:13       ` [PATCH] lockd: fix TEST handling when not all permissions are available NeilBrown
2026-03-24 11:25         ` Jeff Layton
2026-03-25  6:44           ` NeilBrown
2026-03-24 14:59         ` Chuck Lever
2026-03-25  7:08           ` NeilBrown
2026-03-25 13:28             ` Chuck Lever
2026-03-26 22:33               ` NeilBrown
2026-03-26 22:47               ` [PATCH v2] " NeilBrown
2026-03-27 13:56                 ` Chuck Lever
2026-04-01 12:54                   ` Bug#1128861: " Uwe Kleine-König
2026-04-01 13:34                     ` Chuck Lever
2026-03-25 20:29             ` Ben Hutchings [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=eab4db41a02c4342bd6e5397f663c4e651f22e31.camel@decadent.org.uk \
    --to=ben@decadent.org.uk \
    --cc=1128861@bugs.debian.org \
    --cc=cel@kernel.org \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=regressions@leemhuis.info \
    --cc=stable@vger.kernel.org \
    --cc=tj.iam.tj@proton.me \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).