Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1736584
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] seccomp: fix the usage of get/put_seccomp_filter() in seccomp_get_filter() |
| Date | 2017-09-21 13:40 +0200 |
| Message-ID | <us7ZM-o2-19@gated-at.bofh.it> (permalink) |
| References | <urMLD-38Q-11@gated-at.bofh.it> <urMLD-38Q-9@gated-at.bofh.it> <urMVl-3rX-37@gated-at.bofh.it> <urSel-6MZ-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 09/20, Kees Cook wrote:
>
> I like doing these sanity checks -- this isn't fast-path at all.
Yes, but see another "introduce get_nth_filter()" cleanup I sent, it is
similar but more suitable for Tycho's "retrieving seccomp flags" patch.
> > + for (filter = orig; count > 1; filter = filter->prev)
^^^^^^^^^
I just noticed that I forgot to replace this check with "count != 1".
Correctness wise this doesn't matter, but looks more clean.
> > count--;
> > - }
> > -
> > - if (WARN_ON(count != 1 || !filter)) {
> > - /* The filter tree shouldn't shrink while we're using it. */
> > - ret = -ENOENT;
> > - goto out;
> > - }
>
> Similarly, there's no reason to remove this check either.
Well, I disagree, but this is subjective so I won't insist.
Why do we want this WARN_ON() ? The sanity check can only fail if we have
a bug in 10 lines above. Lets look at the code after this cleanup,
count = 0;
for (filter = orig; filter; filter = filter->prev)
count++;
if (filter_off >= count)
goto out;
count -= filter_off;
for (filter = orig; count != 1; filter = filter->prev)
count--;
Do we want to check "count == 1" after the 2nd loop? I don't think so.
filter != NULL ? IMO makes no sense. Again, it can only be NULL if the
quoted code above is wrong, and in this case the next line
refcount_inc(&filter->usage);
will crash.
Oleg.
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