]> git.baikalelectronics.ru Git - kernel.git/commit
seccomp: split filter prep from check and apply
authorKees Cook <keescook@chromium.org>
Fri, 27 Jun 2014 22:16:33 +0000 (15:16 -0700)
committerKees Cook <keescook@chromium.org>
Fri, 18 Jul 2014 19:13:39 +0000 (12:13 -0700)
commit42786264b940b4b9db72f5d757a397e0b78f1557
tree10e229d375150f64808709f5fe9c88b84236e327
parente1012e02fbc2ac0ae3ecf348a34181df3fac6719
seccomp: split filter prep from check and apply

In preparation for adding seccomp locking, move filter creation away
from where it is checked and applied. This will allow for locking where
no memory allocation is happening. The validation, filter attachment,
and seccomp mode setting can all happen under the future locks.

For extreme defensiveness, I've added a BUG_ON check for the calculated
size of the buffer allocation in case BPF_MAXINSN ever changes, which
shouldn't ever happen. The compiler should actually optimize out this
check since the test above it makes it impossible.

Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
kernel/seccomp.c