linux/fs/lockd
NeilBrown 761e3db3dd NFS: fix mount/umount race in nlmclnt.
commit 4a9be28c45 upstream.

If the last NFSv3 unmount from a given host races with a mount from the
same host, we can destroy an nlm_host that is still in use.

Specifically nlmclnt_lookup_host() can increment h_count on
an nlm_host that nlmclnt_release_host() has just successfully called
refcount_dec_and_test() on.
Once nlmclnt_lookup_host() drops the mutex, nlm_destroy_host_lock()
will be called to destroy the nlmclnt which is now in use again.

The cause of the problem is that the dec_and_test happens outside the
locked region.  This is easily fixed by using
refcount_dec_and_mutex_lock().

Fixes: 8ea6ecc8b0 ("lockd: Create client-side nlm_host cache")
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
[bwh: Backported to 3.16: use atomic instead of refcount API]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2019-08-13 12:38:45 +01:00
..
clnt4xdr.c nfsd: remove <linux/nfsd/nfsfh.h> 2014-05-06 17:54:53 -04:00
clntlock.c LOCKD: Don't call utsname()->nodename from nlmclnt_setlockargs 2013-08-05 15:03:46 -04:00
clntproc.c LOCKD: Don't call utsname()->nodename from nlmclnt_setlockargs 2013-08-05 15:03:46 -04:00
clntxdr.c nfsd: remove <linux/nfsd/nfsfh.h> 2014-05-06 17:54:53 -04:00
grace.c LockD: pass actual network namespace to grace period management functions 2012-07-27 16:49:22 -04:00
host.c NFS: fix mount/umount race in nlmclnt. 2019-08-13 12:38:45 +01:00
Makefile lockd: Introduce new-style XDR functions for NLMv4 2010-12-16 12:37:23 -05:00
mon.c lockd: create NSM handles per net namespace 2015-12-13 17:48:43 +00:00
netns.h lockd: create NSM handles per net namespace 2015-12-13 17:48:43 +00:00
svc.c lockd: create NSM handles per net namespace 2015-12-13 17:48:43 +00:00
svc4proc.c lockd: create NSM handles per net namespace 2015-12-13 17:48:43 +00:00
svclock.c lockd: send correct lock when granting a delayed lock. 2014-02-13 14:55:02 -05:00
svcproc.c lockd: create NSM handles per net namespace 2015-12-13 17:48:43 +00:00
svcshare.c lockd: fix sparse warning in svcshare.c 2008-04-23 16:13:39 -04:00
svcsubs.c nfsd: move <linux/nfsd/export.h> to fs/nfsd 2014-05-06 17:54:54 -04:00
xdr.c nfsd: remove <linux/nfsd/nfsfh.h> 2014-05-06 17:54:53 -04:00
xdr4.c lockd: Introduce new-style XDR functions for NLMv4 2010-12-16 12:37:23 -05:00