diff options
author | Kees Cook <keescook@chromium.org> | 2012-10-15 17:02:07 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-12-13 21:35:24 -0500 |
commit | 2e72d51b4ac32989496870cd8171b3682fea1839 (patch) | |
tree | b8190d17aa5d59508f8c979ce0160f21bef89500 /kernel | |
parent | 2f3238aebedb243804f58d62d57244edec4149b2 (diff) |
security: introduce kernel_module_from_file hook
Now that kernel module origins can be reasoned about, provide a hook to
the LSMs to make policy decisions about the module file. This will let
Chrome OS enforce that loadable kernel modules can only come from its
read-only hash-verified root filesystem. Other LSMs can, for example,
read extended attributes for signatures, etc.
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Serge E. Hallyn <serge.hallyn@canonical.com>
Acked-by: Eric Paris <eparis@redhat.com>
Acked-by: Mimi Zohar <zohar@us.ibm.com>
Acked-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/module.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/module.c b/kernel/module.c index 1395ca382fb5..a1d2ed8bab93 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/vmalloc.h> | 29 | #include <linux/vmalloc.h> |
30 | #include <linux/elf.h> | 30 | #include <linux/elf.h> |
31 | #include <linux/proc_fs.h> | 31 | #include <linux/proc_fs.h> |
32 | #include <linux/security.h> | ||
32 | #include <linux/seq_file.h> | 33 | #include <linux/seq_file.h> |
33 | #include <linux/syscalls.h> | 34 | #include <linux/syscalls.h> |
34 | #include <linux/fcntl.h> | 35 | #include <linux/fcntl.h> |
@@ -2485,10 +2486,16 @@ static int elf_header_check(struct load_info *info) | |||
2485 | static int copy_module_from_user(const void __user *umod, unsigned long len, | 2486 | static int copy_module_from_user(const void __user *umod, unsigned long len, |
2486 | struct load_info *info) | 2487 | struct load_info *info) |
2487 | { | 2488 | { |
2489 | int err; | ||
2490 | |||
2488 | info->len = len; | 2491 | info->len = len; |
2489 | if (info->len < sizeof(*(info->hdr))) | 2492 | if (info->len < sizeof(*(info->hdr))) |
2490 | return -ENOEXEC; | 2493 | return -ENOEXEC; |
2491 | 2494 | ||
2495 | err = security_kernel_module_from_file(NULL); | ||
2496 | if (err) | ||
2497 | return err; | ||
2498 | |||
2492 | /* Suck in entire file: we'll want most of it. */ | 2499 | /* Suck in entire file: we'll want most of it. */ |
2493 | info->hdr = vmalloc(info->len); | 2500 | info->hdr = vmalloc(info->len); |
2494 | if (!info->hdr) | 2501 | if (!info->hdr) |
@@ -2515,6 +2522,10 @@ static int copy_module_from_fd(int fd, struct load_info *info) | |||
2515 | if (!file) | 2522 | if (!file) |
2516 | return -ENOEXEC; | 2523 | return -ENOEXEC; |
2517 | 2524 | ||
2525 | err = security_kernel_module_from_file(file); | ||
2526 | if (err) | ||
2527 | goto out; | ||
2528 | |||
2518 | err = vfs_getattr(file->f_vfsmnt, file->f_dentry, &stat); | 2529 | err = vfs_getattr(file->f_vfsmnt, file->f_dentry, &stat); |
2519 | if (err) | 2530 | if (err) |
2520 | goto out; | 2531 | goto out; |