linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "NeilBrown" <neilb@suse.de>
To: "Chuck Lever III" <chuck.lever@oracle.com>
Cc: "linux-stable" <stable@vger.kernel.org>,
	"Chuck Lever" <cel@kernel.org>,
	"Linux NFS Mailing List" <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 0/3] Fix RELEASE_LOCKOWNER
Date: Sat, 03 Feb 2024 11:26:06 +1100	[thread overview]
Message-ID: <170691996664.13976.18138125578593325497@noble.neil.brown.name> (raw)
In-Reply-To: <FF7C90E0-251D-48D2-908B-E2145B0B9BAE@oracle.com>

On Sat, 03 Feb 2024, Chuck Lever III wrote:
> 
> 
> > On Feb 1, 2024, at 5:24 PM, NeilBrown <neilb@suse.de> wrote:
> > 
> > On Fri, 02 Feb 2024, Chuck Lever wrote:
> >> Passes pynfs, fstests, and the git regression suite. Please apply
> >> these to origin/linux-5.4.y.
> > 
> > I should have mentioned this a day or two ago but I hadn't quite made
> > all the connection yet...
> > 
> > The RELEASE_LOCKOWNER bug was masking a double-free bug that was fixed
> > by
> > Commit 47446d74f170 ("nfsd4: add refcount for nfsd4_blocked_lock")
> > which landed in v5.17 and wasn't marked as a bugfix, and so has not gone to
> > stable kernels.
> 
> Then, instructions to stable@vger.kernel.org:
> 
> Do not apply the patches I just sent for 5.15, 5.10, and 5.4. I will
> apply 47446d74f170, run the tests again, and resend.
> 
> 
> > Any kernel earlier than v5.17 that receives the RELEASE_LOCKOWNER fix
> > also needs the nfsd4_blocked_lock fix.  There is a minor follow-up fix
> > for that nfsd4_blocked_lock fix which Chuck queued yesterday.
> > 
> > The problem scenario is that an nfsd4_lock() call finds a conflicting
> > lock and so has a reference to a particular nfsd4_blocked_lock.  A concurrent
> > nfsd4_read_lockowner call frees all the nfsd4_blocked_locks including
> > the one held in nfsd4_lock().  nfsd4_lock then tries to free the
> > blocked_lock it has, and results in a double-free or a use-after-free.
> > 
> > Before either patch is applied, the extra reference on the lock-owner
> > than nfsd4_lock holds causes nfsd4_realease_lockowner() to incorrectly
> > return an error and NOT free the blocks_lock.
> > With only the RELEASE_LOCKOWNER fix applied, the double-free happens.
> 
> Our test suite currently does not exercise this use case, apparently.
> I didn't see a problem like this during testing.
> 

Our OpenQA testing found it (as did our customer :-).
Quoting from a bugzilla that unfortunately is not public (though might
not be accessible to anyone with an account)

https://bugzilla.suse.com/show_bug.cgi?id=1219349

     LTP test nfslock01.sh randomly fails on the latest SLE-15SP4 and
     SLE-15SP5 KOTD.  The failures appear only when testing NFS protocol
     v4.0, other versions do not seem to be affected.  The test either
     gets stuck or sometimes triggers kernel oops.  The contents of the
     kernel backtrace vary.  All archs appear to be affected. 

Does your test suite cover v4.0?  Does it include LTP ?

Thanks,
NeilBrown


> 
> > With both patches applied the refcount on the nfsd4_blocked_lock prevents
> > the double-free.
> > 
> > Kernels before 4.9 are (probably) not affected as they didn't have
> > find_or_allocate_block() which takes the second reference to a shared
> > object.  But that is ancient history - those kernels are well past EOL.
> > 
> > Thanks,
> > NeilBrown
> > 
> > 
> >> 
> >> ---
> >> 
> >> Chuck Lever (2):
> >>      NFSD: Modernize nfsd4_release_lockowner()
> >>      NFSD: Add documenting comment for nfsd4_release_lockowner()
> >> 
> >> NeilBrown (1):
> >>      nfsd: fix RELEASE_LOCKOWNER
> >> 
> >> 
> >> fs/nfsd/nfs4state.c | 65 +++++++++++++++++++++++++--------------------
> >> 1 file changed, 36 insertions(+), 29 deletions(-)
> >> 
> >> --
> >> Chuck Lever
> >> 
> >> 
> >> 
> > 
> 
> --
> Chuck Lever
> 
> 
> 


  reply	other threads:[~2024-02-03  0:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 19:06 [PATCH 0/3] Fix RELEASE_LOCKOWNER Chuck Lever
2024-02-01 19:06 ` [PATCH 1/3] NFSD: Modernize nfsd4_release_lockowner() Chuck Lever
2024-02-01 19:06 ` [PATCH 2/3] NFSD: Add documenting comment for nfsd4_release_lockowner() Chuck Lever
2024-02-01 19:06 ` [PATCH 3/3] nfsd: fix RELEASE_LOCKOWNER Chuck Lever
2024-02-01 22:24 ` [PATCH 0/3] Fix RELEASE_LOCKOWNER NeilBrown
2024-02-02 14:12   ` Chuck Lever III
2024-02-03  0:26     ` NeilBrown [this message]
2024-02-03  3:43       ` Chuck Lever III
2024-02-03  1:04     ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2024-02-01 14:23 Chuck Lever
2024-02-01 14:21 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=170691996664.13976.18138125578593325497@noble.neil.brown.name \
    --to=neilb@suse.de \
    --cc=cel@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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 NNTP newsgroup(s).