Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1735766
| From | Tycho Andersen <tycho@docker.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] seccomp: fix the usage of get/put_seccomp_filter() in seccomp_get_filter() |
| Date | 2017-09-20 15:30 +0200 |
| Message-ID | <urNeF-3Dk-9@gated-at.bofh.it> (permalink) |
| References | <urMLD-38Q-11@gated-at.bofh.it> <urMLD-38Q-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, Sep 20, 2017 at 02:56:21PM +0200, Oleg Nesterov wrote:
> As Chris explains, get_seccomp_filter() and put_seccomp_filter() can
> use the different filters, once we drop ->siglock task->seccomp.filter
> can be replaced by SECCOMP_FILTER_FLAG_TSYNC.
>
> Fixes: f8e529ed941b ("seccomp, ptrace: add support for dumping seccomp filters")
> Reported-by: Chris Salls <chrissalls5@gmail.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Ugh! Whoops.
Acked-by: Tycho Andersen <tycho@docker.com>
> ---
> kernel/seccomp.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/seccomp.c b/kernel/seccomp.c
> index 98b59b5..897f153 100644
> --- a/kernel/seccomp.c
> +++ b/kernel/seccomp.c
> @@ -476,10 +476,8 @@ static inline void seccomp_filter_free(struct seccomp_filter *filter)
> }
> }
>
> -/* put_seccomp_filter - decrements the ref count of tsk->seccomp.filter */
> -void put_seccomp_filter(struct task_struct *tsk)
> +static void __put_seccomp_filter(struct seccomp_filter *orig)
> {
> - struct seccomp_filter *orig = tsk->seccomp.filter;
> /* Clean up single-reference branches iteratively. */
> while (orig && refcount_dec_and_test(&orig->usage)) {
> struct seccomp_filter *freeme = orig;
> @@ -488,6 +486,12 @@ void put_seccomp_filter(struct task_struct *tsk)
> }
> }
>
> +/* put_seccomp_filter - decrements the ref count of tsk->seccomp.filter */
> +void put_seccomp_filter(struct task_struct *tsk)
> +{
> + __put_seccomp_filter(tsk->seccomp.filter);
> +}
> +
> static void seccomp_init_siginfo(siginfo_t *info, int syscall, int reason)
> {
> memset(info, 0, sizeof(*info));
> @@ -908,13 +912,13 @@ long seccomp_get_filter(struct task_struct *task, unsigned long filter_off,
> if (!data)
> goto out;
>
> - get_seccomp_filter(task);
> + refcount_inc(&filter->usage);
> spin_unlock_irq(&task->sighand->siglock);
>
> if (copy_to_user(data, fprog->filter, bpf_classic_proglen(fprog)))
> ret = -EFAULT;
>
> - put_seccomp_filter(task);
> + __put_seccomp_filter(filter);
> return ret;
>
> out:
> --
> 2.5.0
>
>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] seccomp: fix the usage of get/put_seccomp_filter() in seccomp_get_filter() Oleg Nesterov <oleg@redhat.com> - 2017-09-20 15:00 +0200
Re: [PATCH] seccomp: fix the usage of get/put_seccomp_filter() in seccomp_get_filter() Oleg Nesterov <oleg@redhat.com> - 2017-09-20 15:10 +0200
Re: [PATCH] seccomp: fix the usage of get/put_seccomp_filter() in seccomp_get_filter() Tycho Andersen <tycho@docker.com> - 2017-09-20 15:40 +0200
introduce get_nth_filter() Oleg Nesterov <oleg@redhat.com> - 2017-09-20 18:00 +0200
Re: introduce get_nth_filter() Oleg Nesterov <oleg@redhat.com> - 2017-09-20 18:20 +0200
Re: [PATCH] seccomp: fix the usage of get/put_seccomp_filter() in seccomp_get_filter() Kees Cook <keescook@chromium.org> - 2017-09-20 20:50 +0200
Re: [PATCH] seccomp: fix the usage of get/put_seccomp_filter() in seccomp_get_filter() Oleg Nesterov <oleg@redhat.com> - 2017-09-21 13:40 +0200
Re: [PATCH] seccomp: fix the usage of get/put_seccomp_filter() in seccomp_get_filter() Tycho Andersen <tycho@docker.com> - 2017-09-20 15:30 +0200
Re: [PATCH] seccomp: fix the usage of get/put_seccomp_filter() in seccomp_get_filter() Kees Cook <keescook@chromium.org> - 2017-09-20 20:40 +0200
Re: [PATCH] seccomp: fix the usage of get/put_seccomp_filter() in seccomp_get_filter() Oleg Nesterov <oleg@redhat.com> - 2017-09-21 13:00 +0200
Re: [PATCH] seccomp: fix the usage of get/put_seccomp_filter() in seccomp_get_filter() Kees Cook <keescook@chromium.org> - 2017-09-21 22:00 +0200
Re: [PATCH] seccomp: fix the usage of get/put_seccomp_filter() in seccomp_get_filter() Oleg Nesterov <oleg@redhat.com> - 2017-09-22 17:30 +0200
Re: [PATCH] seccomp: fix the usage of get/put_seccomp_filter() in seccomp_get_filter() Tycho Andersen <tycho@docker.com> - 2017-09-22 17:30 +0200
csiph-web