From: Jeff Layton <jlayton@kernel.org>
To: NeilBrown <neil@brown.name>, Chuck Lever <chucklever@fastmail.com>
Cc: Chuck Lever <chuck.lever@oracle.com>,
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 1/2] lockd: fix vfs_test_lock() calls
Date: Sun, 23 Nov 2025 07:15:36 -0500 [thread overview]
Message-ID: <95a11afd51dc7975e75b81083ddab7d869b8bf3a.camel@kernel.org> (raw)
In-Reply-To: <176384450696.634289.131833962229924725@noble.neil.brown.name>
On Sun, 2025-11-23 at 07:48 +1100, NeilBrown wrote:
> On Sun, 23 Nov 2025, Chuck Lever wrote:
> > On Fri, Nov 21, 2025, at 8:00 PM, NeilBrown wrote:
> > > From: NeilBrown <neil@brown.name>
> > >
> > > Usage of vfs_test_lock() is somewhat confused. Documentation suggests
> > > it is given a "lock" but this is not the case. It is given a struct
> > > file_lock which contains some details of the sort of lock it should be
> > > looking for.
> > >
> > > In particular passing a "file_lock" containing fl_lmops or fl_ops is
> > > meaningless and possibly confusing.
> > >
> > > This is particularly problematic in lockd. nlmsvc_testlock() receives
> > > an initialised "file_lock" from xdr-decode, including manager ops and an
> > > owner. It then mistakenly passes this to vfs_test_lock() which might
> > > replace the owner and the ops. This can lead to confusion when freeing
> > > the lock.
> > >
> > > The primary role of the 'struct file_lock' passed to vfs_test_lock() is
> > > to report a conflicting lock that was found, so it makes more sense for
> > > nlmsvc_testlock() to pass "conflock", which it uses for returning the
> > > conflicting lock.
> > >
> > > With this change, freeing of the lock is not confused and code in
> > > __nlm4svc_proc_test() and __nlmsvc_proc_test() can be simplified.
> > >
> > > Documentation for vfs_test_lock() is improved to reflect its real
> > > purpose, and a WARN_ON_ONCE() is added to avoid a similar problem in the
> > > future.
> > >
> > > Reported-by: Olga Kornievskaia <okorniev@redhat.com>
> > > Closes: https://lore.kernel.org/all/20251021130506.45065-1-okorniev@redhat.com
> > > Signed-off-by: NeilBrown <neil@brown.name>
> >
> > At a guess:
> >
> > Fixes: 5ea0d75037b9 ("lockd: handle test_lock deferrals") ??
>
> I think the problem is, in practice, more recent.
> I think there is only a problem if the filesystem that lockd is
> accessing sets fl_lmops on locks.
>
...and specifically if the filesystem sets lm_get_owner/lm_put_owner.
That's only NFS/NLM, currently.
> So maybe
>
> Fixes: 20fa19027286 ("nfs: add export operations")
>
That's likely the place where it became a real problem, yes.
> >
> > I suspect this also needs a Cc: stable.
>
> I think that would be appropriate - yes.
>
> NeilBrown
Ditto.
--
Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2025-11-23 12:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-22 1:00 [PATCH v2 0/2] lockd/locks: address issues with vfs_test_lock() NeilBrown
2025-11-22 1:00 ` [PATCH v2 1/2] lockd: fix vfs_test_lock() calls NeilBrown
2025-11-22 16:10 ` Chuck Lever
2025-11-22 20:48 ` NeilBrown
2025-11-23 12:15 ` Jeff Layton [this message]
2025-11-22 1:00 ` [PATCH v2 2/2] locks: ensure vfs_test_lock() never returns FILE_LOCK_DEFERRED NeilBrown
2025-11-22 16:29 ` [PATCH v2 0/2] lockd/locks: address issues with vfs_test_lock() Chuck Lever
2025-11-23 12:16 ` Jeff Layton
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=95a11afd51dc7975e75b81083ddab7d869b8bf3a.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=chucklever@fastmail.com \
--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