]> www.infradead.org Git - users/dwmw2/linux.git/commit
nfsd: don't call locks_release_private() twice concurrently
authorNeilBrown <neilb@suse.de>
Wed, 31 Jan 2024 00:17:40 +0000 (11:17 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:19:29 +0000 (16:19 +0200)
commite90402fb0697a5b7dd1c4eb9f4838daa91bf8a27
tree715ee7671fe6667cb279264b098c2de75f9a2e59
parent8b4fa191deedd74edb01854c9a025fb6eab8ed49
nfsd: don't call locks_release_private() twice concurrently

[ Upstream commit 05eda6e75773592760285e10ac86c56d683be17f ]

It is possible for free_blocked_lock() to be called twice concurrently,
once from nfsd4_lock() and once from nfsd4_release_lockowner() calling
remove_blocked_locks().  This is why a kref was added.

It is perfectly safe for locks_delete_block() and kref_put() to be
called in parallel as they use locking or atomicity respectively as
protection.  However locks_release_private() has no locking.  It is
safe for it to be called twice sequentially, but not concurrently.

This patch moves that call from free_blocked_lock() where it could race
with itself, to free_nbl() where it cannot.  This will slightly delay
the freeing of private info or release of the owner - but not by much.
It is arguably more natural for this freeing to happen in free_nbl()
where the structure itself is freed.

This bug was found by code inspection - it has not been seen in practice.

Fixes: 47446d74f170 ("nfsd4: add refcount for nfsd4_blocked_lock")
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4state.c