]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC: r355194
authorRick Macklem <rmacklem@FreeBSD.org>
Sat, 28 Dec 2019 22:24:16 +0000 (22:24 +0000)
committerRick Macklem <rmacklem@FreeBSD.org>
Sat, 28 Dec 2019 22:24:16 +0000 (22:24 +0000)
commit39ea5e3b5bdea8cbdb3d4e96315610f4d21e9e25
tree7c0c7980dde12d1feeaf0c6a6b94fbd347c72993
parentba1755d072fc1edc8e5a2b4900f64eea509a5083
MFC: r355194
Fix two races while handling nfsuserd daemon start/stop.

A crash was reported where the nr_client field was NULL during an upcall
to the nfsuserd daemon. Since nr_client == NULL only occurs when the
nfsuserd daemon is being shut down, it appeared to be caused by a race
between doing an upcall and the daemon shutting down.
By inspection two races were identified:
1 - The nfsrv_nfsuserd variable is used to indicate whether or not the
    daemon is running. However it did not handle the intermediate phase
    where the daemon is starting or stopping.

    This was fixed by making nfsrv_nfsuserd tri-state and having the
    functions that are called during start/stop to obey the intermediate
    state.

2 - nfsrv_nfsuserd was checked to see that the daemon was running at
    the beginning of an upcall, but nothing prevented the daemon from
    being shut down while an upcall was still in progress.
    This race probably caused the crash.

    The patch fixes this by adding a count of upcalls in progress and
    having the shut down function delay until this count goes to zero
    before getting rid of nr_client and related data used by an upcall.
sys/fs/nfs/nfs.h
sys/fs/nfs/nfs_commonport.c
sys/fs/nfs/nfs_commonsubs.c
sys/fs/nfs/nfsport.h