staging: lustre: obd_mount: fix possible race with module unload.
authorNeilBrown <neilb@suse.com>
Mon, 18 Dec 2017 01:13:20 +0000 (12:13 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 8 Jan 2018 15:03:44 +0000 (16:03 +0100)
commitd487fe31f49e78f3cdd826923bf0c340a839ffd8
treeeeb88828bdaffd84f114f6174c89e205edc40adf
parent7dc2155195586ec75f53d6dcd381f935ccc35d02
staging: lustre: obd_mount: fix possible race with module unload.

lustre_fill_super() calls client_fill_super() without holding a
reference to the module containing client_fill_super.  If that
module is unloaded at a bad time, this can crash.

To be able to get a reference to the module using
try_get_module(), we need a pointer to the module.

So replace
  lustre_register_client_fill_super() and
  lustre_register_kill_super_cb()
with a single
  lustre_register_super_ops()
which also passed a module pointer.

Then use a spinlock to ensure the module pointer isn't removed
while try_module_get() is running, and use try_module_get() to
ensure we have a reference before calling client_fill_super().

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/include/lustre_disk.h
drivers/staging/lustre/lustre/llite/super25.c
drivers/staging/lustre/lustre/obdclass/obd_mount.c