From: Rusty Russell <rusty@rustcorp.com.au>
To: Kees Cook <keescook@chromium.org>, linux-kernel@vger.kernel.org
Cc: Serge Hallyn <serge.hallyn@canonical.com>,
James Morris <james.l.morris@oracle.com>,
Al Viro <viro@zeniv.linux.org.uk>, Eric Paris <eparis@redhat.com>,
Kees Cook <keescook@chromium.org>, Jiri Kosina <jkosina@suse.cz>,
linux-security-module@vger.kernel.org
Subject: Re: [PATCH 1/2] module: add syscall to load module from fd
Date: Fri, 07 Sep 2012 09:45:08 +0930 [thread overview]
Message-ID: <87ipbqhenn.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1346955201-8926-1-git-send-email-keescook@chromium.org>
Kees Cook <keescook@chromium.org> writes:
> Instead of (or in addition to) kernel module signing, being able to reason
> about the origin of a kernel module would be valuable in situations
> where an OS already trusts a specific file system, file, etc, due to
> things like security labels or an existing root of trust to a partition
> through things like dm-verity.
>
> This introduces a new syscall (currently only on x86), similar to
> init_module, that has only two arguments. The first argument is used as
> a file descriptor to the module and the second argument is a pointer to
> the NULL terminated string of module arguments.
Thanks. Minor comments follow:
> +350 i386 init_module_from_fd sys_init_module_from_fd
The from_ seems redundant.
> diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
> index 19439c7..5386629 100644
> --- a/include/linux/syscalls.h
> +++ b/include/linux/syscalls.h
> @@ -860,4 +860,5 @@ asmlinkage long sys_process_vm_writev(pid_t pid,
>
> asmlinkage long sys_kcmp(pid_t pid1, pid_t pid2, int type,
> unsigned long idx1, unsigned long idx2);
> +asmlinkage long sys_init_module_from_fd(int len, const char __user *uargs);
> #endif
You mean, "int fd"?
> diff --git a/kernel/module.c b/kernel/module.c
> index 4edbd9c..b080cf8 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
...
> +/* Sets info->hdr and info->len. */
> +int copy_module_from_fd(int fd, struct load_info *info)
> +{
> + struct file *file;
> + int err;
> + struct kstat stat;
> + unsigned long size;
> + off_t pos;
> + ssize_t bytes = 0;
> +
> + file = fget(fd);
> + if (!file)
> + return -ENOEXEC;
> +
> + err = vfs_getattr(file->f_vfsmnt, file->f_dentry, &stat);
> + if (err)
> + goto out;
> +
> + if (stat.size > INT_MAX) {
> + err = -ENOMEM;
> + goto out;
> }
> + size = stat.size;
>
> - if (hdr->e_shoff >= len ||
> - hdr->e_shnum * sizeof(Elf_Shdr) > len - hdr->e_shoff) {
> - err = -ENOEXEC;
> - goto free_hdr;
> + info->hdr = vmalloc(size);
> + if (!info->hdr) {
> + err = -ENOMEM;
> + goto out;
The stat.size > INT_MAX is redundant: vmalloc is quite careful on its
checking of the size param.
(We removed a similar test from the module.c code a few years ago).
Cheers,
Rusty.
next prev parent reply other threads:[~2012-09-07 0:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-06 18:13 [PATCH 1/2] module: add syscall to load module from fd Kees Cook
2012-09-06 18:13 ` [PATCH 2/2] security: introduce kernel_module_from_file hook Kees Cook
2012-09-07 0:15 ` Rusty Russell [this message]
2012-09-07 16:19 ` [PATCH 1/2] module: add syscall to load module from fd Kees Cook
2012-09-07 17:12 ` Mimi Zohar
2012-09-07 17:19 ` Kees Cook
2012-09-07 19:04 ` Mimi Zohar
2012-09-10 1:46 ` Rusty Russell
2012-09-10 15:07 ` Kees Cook
2012-09-12 2:57 ` James Morris
2012-09-12 4:15 ` H. Peter Anvin
2012-09-12 7:34 ` Rusty Russell
2012-09-12 14:38 ` Kees Cook
2012-09-13 19:22 ` Mimi Zohar
2012-09-19 3:38 ` Rusty Russell
2012-09-19 14:41 ` Mimi Zohar
2012-09-19 16:15 ` Kees Cook
-- strict thread matches above, loose matches on Subject: below --
2012-09-07 18:38 Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ipbqhenn.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=eparis@redhat.com \
--cc=james.l.morris@oracle.com \
--cc=jkosina@suse.cz \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=serge.hallyn@canonical.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox