Commit 9e01892c authored by Heiko Carstens's avatar Heiko Carstens Committed by Rusty Russell

module: convert to stop_machine_create/destroy.

The module code relies on a non-failing stop_machine call. So we create
the kstop threads in advance and with that make sure the call won't fail.
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 9ea09af3
...@@ -757,8 +757,16 @@ sys_delete_module(const char __user *name_user, unsigned int flags) ...@@ -757,8 +757,16 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
return -EFAULT; return -EFAULT;
name[MODULE_NAME_LEN-1] = '\0'; name[MODULE_NAME_LEN-1] = '\0';
if (mutex_lock_interruptible(&module_mutex) != 0) /* Create stop_machine threads since free_module relies on
return -EINTR; * a non-failing stop_machine call. */
ret = stop_machine_create();
if (ret)
return ret;
if (mutex_lock_interruptible(&module_mutex) != 0) {
ret = -EINTR;
goto out_stop;
}
mod = find_module(name); mod = find_module(name);
if (!mod) { if (!mod) {
...@@ -817,6 +825,8 @@ sys_delete_module(const char __user *name_user, unsigned int flags) ...@@ -817,6 +825,8 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
out: out:
mutex_unlock(&module_mutex); mutex_unlock(&module_mutex);
out_stop:
stop_machine_destroy();
return ret; return ret;
} }
...@@ -1875,6 +1885,13 @@ static noinline struct module *load_module(void __user *umod, ...@@ -1875,6 +1885,13 @@ static noinline struct module *load_module(void __user *umod,
/* vmalloc barfs on "unusual" numbers. Check here */ /* vmalloc barfs on "unusual" numbers. Check here */
if (len > 64 * 1024 * 1024 || (hdr = vmalloc(len)) == NULL) if (len > 64 * 1024 * 1024 || (hdr = vmalloc(len)) == NULL)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
/* Create stop_machine threads since the error path relies on
* a non-failing stop_machine call. */
err = stop_machine_create();
if (err)
goto free_hdr;
if (copy_from_user(hdr, umod, len) != 0) { if (copy_from_user(hdr, umod, len) != 0) {
err = -EFAULT; err = -EFAULT;
goto free_hdr; goto free_hdr;
...@@ -2258,6 +2275,7 @@ static noinline struct module *load_module(void __user *umod, ...@@ -2258,6 +2275,7 @@ static noinline struct module *load_module(void __user *umod,
/* Get rid of temporary copy */ /* Get rid of temporary copy */
vfree(hdr); vfree(hdr);
stop_machine_destroy();
/* Done! */ /* Done! */
return mod; return mod;
...@@ -2280,6 +2298,7 @@ static noinline struct module *load_module(void __user *umod, ...@@ -2280,6 +2298,7 @@ static noinline struct module *load_module(void __user *umod,
kfree(args); kfree(args);
free_hdr: free_hdr:
vfree(hdr); vfree(hdr);
stop_machine_destroy();
return ERR_PTR(err); return ERR_PTR(err);
truncated: truncated:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment