[PATCH] staging: lustre: do not ignore try_module_get() fail in obd_class_open()

Greg Kroah-Hartman gregkh at linuxfoundation.org
Sat Jan 17 23:48:30 UTC 2015


On Sat, Dec 27, 2014 at 02:26:53AM +0300, Alexey Khoroshilov wrote:
> obd_class_open() ignores error code of try_module_get(),
> while it can lead to race with module unload.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov at ispras.ru>
> ---
>  drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
> index 66ceab20c743..bb4bc72ddac7 100644
> --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
> +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
> @@ -168,8 +168,7 @@ EXPORT_SYMBOL(obd_ioctl_popdata);
>  /*  opening /dev/obd */
>  static int obd_class_open(struct inode *inode, struct file *file)
>  {
> -	try_module_get(THIS_MODULE);
> -	return 0;
> +	return try_module_get(THIS_MODULE);
>  }

This code is totally wrong and racy and should just be fixed up
properly.  No module can lock it's own code, we know better than this.

thanks,

greg k-h


More information about the devel mailing list