lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 13 Nov 2019 08:51:09 -0500
From:   Prarit Bhargava <prarit@...hat.com>
To:     Konstantin Khorenko <khorenko@...tuozzo.com>,
        Jessica Yu <jeyu@...nel.org>, Barret Rhoden <brho@...gle.com>
Cc:     Andrey Ryabinin <aryabinin@...tuozzo.com>,
        linux-kernel@...r.kernel.org, David Arcari <darcari@...hat.com>,
        Heiko Carstens <heiko.carstens@...ibm.com>
Subject: Re: [PATCH 1/1] kernel/module.c: wakeup processes in module_wq on
 module unload



On 11/13/19 4:29 AM, Konstantin Khorenko wrote:
> Fix the race between load and unload a kernel module.
> 
> sys_delete_module()
>  try_stop_module()
>   mod->state = _GOING
> 					add_unformed_module()
> 					 old = find_module_all()
> 					 (old->state == _GOING =>
> 					  wait_event_interruptible())
> 
> 					 During pre-condition
> 					 finished_loading() rets 0
> 					 schedule()
> 					 (never gets waken up later)
>  free_module()
>   mod->state = _UNFORMED
>    list_del_rcu(&mod->list)
>    (dels mod from "modules" list)
> 
> return
> 
> The race above leads to modprobe hanging forever on loading
> a module.
> 
> Error paths on loading module call wake_up_all(&module_wq) after
> freeing module, so let's do the same on straight module unload.
> 
> Fixes: 6e6de3dee51a ("kernel/module.c: Only return -EEXIST
> for modules that have finished loading")
> 
> Signed-off-by: Konstantin Khorenko <khorenko@...tuozzo.com>
> ---
>  kernel/module.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/module.c b/kernel/module.c
> index ff2d7359a418..cb09a5f37a5f 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -1033,6 +1033,8 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
>  	strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module));
>  
>  	free_module(mod);
> +	/* someone could wait for the module in add_unformed_module() */
> +	wake_up_all(&module_wq);

free_module() acts on that *this* module so it makes sense to include the
wake_up_all(&module_wq) call in delete_module.  IIRC I did try a module load &
unload stress test but it looks like my testing wasn't hard enough :(

In any case,

Reviewed-by: Prarit Bhargava <prarit@...hat.com>

P.

>  	return 0;
>  out:
>  	mutex_unlock(&module_mutex);
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ