Skip to content

Commit 38f9017

Browse files
keesgregkh
authored andcommitted
module: Call security_kernel_post_load_data()
Now that there is an API for checking loaded contents for modules loaded without a file, call into the LSM hooks. Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: KP Singh <kpsingh@google.com> Acked-by: Jessica Yu <jeyu@kernel.org> Link: https://lore.kernel.org/r/20201002173828.2099543-11-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4f2d99b commit 38f9017

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

kernel/module.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -3014,7 +3014,7 @@ static int copy_module_from_user(const void __user *umod, unsigned long len,
30143014
if (info->len < sizeof(*(info->hdr)))
30153015
return -ENOEXEC;
30163016

3017-
err = security_kernel_load_data(LOADING_MODULE, false);
3017+
err = security_kernel_load_data(LOADING_MODULE, true);
30183018
if (err)
30193019
return err;
30203020

@@ -3024,11 +3024,17 @@ static int copy_module_from_user(const void __user *umod, unsigned long len,
30243024
return -ENOMEM;
30253025

30263026
if (copy_chunked_from_user(info->hdr, umod, info->len) != 0) {
3027-
vfree(info->hdr);
3028-
return -EFAULT;
3027+
err = -EFAULT;
3028+
goto out;
30293029
}
30303030

3031-
return 0;
3031+
err = security_kernel_post_load_data((char *)info->hdr, info->len,
3032+
LOADING_MODULE, "init_module");
3033+
out:
3034+
if (err)
3035+
vfree(info->hdr);
3036+
3037+
return err;
30323038
}
30333039

30343040
static void free_copy(struct load_info *info)

0 commit comments

Comments
 (0)