Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1252009
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters |
| Date | 2015-10-20 22:30 +0200 |
| Message-ID | <qlLHI-65j-19@gated-at.bofh.it> (permalink) |
| References | <qlLeG-5i7-21@gated-at.bofh.it> <qlLeG-5i7-19@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 10/20, Tycho Andersen wrote:
>
> +long seccomp_get_filter(struct task_struct *task, unsigned long filter_off,
> + void __user *data)
> +{
> + struct seccomp_filter *filter;
> + struct sock_fprog_kern *fprog;
> + long ret;
> + unsigned long count = 0;
> +
> + if (!capable(CAP_SYS_ADMIN) ||
> + current->seccomp.mode != SECCOMP_MODE_DISABLED) {
> + return -EACCES;
> + }
> +
> + spin_lock_irq(&task->sighand->siglock);
> + if (task->seccomp.mode != SECCOMP_MODE_FILTER) {
> + ret = -EINVAL;
> + goto out_task;
> + }
> +
> + filter = task->seccomp.filter;
> + while (filter) {
> + filter = filter->prev;
> + count++;
> + }
> +
> + if (filter_off >= count) {
> + ret = -ENOENT;
> + goto out_task;
> + }
> + count -= filter_off;
> +
> + filter = task->seccomp.filter;
> + while (filter && count > 1) {
> + filter = filter->prev;
> + count--;
> + }
> +
> + if (WARN_ON(count != 1)) {
> + /* The filter tree shouldn't shrink while we're using it. */
> + ret = -ENOENT;
> + goto out_task;
> + }
> +
> + fprog = filter->prog->orig_prog;
> + if (!fprog) {
> + /* This must be a new non-cBPF filter, since we save every
> + * every cBPF filter's orig_prog above when
> + * CONFIG_CHECKPOINT_RESTORE is enabled.
> + */
> + ret = -EMEDIUMTYPE;
> + goto out_task;
> + }
> +
> + ret = fprog->len;
> + if (!data)
> + goto out_task;
> +
> + if (copy_to_user(data, fprog->filter, bpf_classic_proglen(fprog))) {
> + ret = -EFAULT;
> + goto out_task;
> + }
Oh wait, I didn't notice this when I looked at v7.
No, you can't do copy_to_user() from atomic context. You need to pin this
filter, drop the lock/irq, then copy_to_user().
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
v8 of seccomp filter c/r Tycho Andersen <tycho.andersen@canonical.com> - 2015-10-20 22:00 +0200
[PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Tycho Andersen <tycho.andersen@canonical.com> - 2015-10-20 22:00 +0200
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Kees Cook <keescook@chromium.org> - 2015-10-20 22:30 +0200
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Tycho Andersen <tycho.andersen@canonical.com> - 2015-10-20 22:40 +0200
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Oleg Nesterov <oleg@redhat.com> - 2015-10-20 22:30 +0200
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Tycho Andersen <tycho.andersen@canonical.com> - 2015-10-21 00:10 +0200
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Oleg Nesterov <oleg@redhat.com> - 2015-10-21 21:00 +0200
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Tycho Andersen <tycho.andersen@canonical.com> - 2015-10-21 21:20 +0200
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Kees Cook <keescook@chromium.org> - 2015-10-21 22:20 +0200
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Daniel Borkmann <daniel@iogearbox.net> - 2015-10-21 22:20 +0200
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Tycho Andersen <tycho.andersen@canonical.com> - 2015-10-21 22:40 +0200
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Oleg Nesterov <oleg@redhat.com> - 2015-10-21 23:20 +0200
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Kees Cook <keescook@chromium.org> - 2015-10-21 23:30 +0200
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Tycho Andersen <tycho.andersen@canonical.com> - 2015-10-21 23:40 +0200
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Oleg Nesterov <oleg@redhat.com> - 2015-10-25 15:50 +0100
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Kees Cook <keescook@chromium.org> - 2015-10-26 07:50 +0100
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Kees Cook <keescook@chromium.org> - 2015-10-26 08:10 +0100
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Tycho Andersen <tycho.andersen@canonical.com> - 2015-10-27 01:10 +0100
Re: [PATCH v8] seccomp, ptrace: add support for dumping seccomp filters Daniel Borkmann <daniel@iogearbox.net> - 2015-10-27 01:20 +0100
csiph-web