seccomp: split filter prep from check and apply
authorKees Cook <keescook@chromium.org>
Fri, 27 Jun 2014 22:16:33 +0000 (15:16 -0700)
committerJP Abgrall <jpa@google.com>
Thu, 28 Aug 2014 01:53:09 +0000 (01:53 +0000)
commit3497a88f5510c809ca10deac3030493eabba65d7
tree5dcd38d2867d22bbe25c38bda7efc6d4765ae807
parent2c6d7de579c2cfebbc9378e5209c641a93839f0a
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>
Conflicts:
kernel/seccomp.c

Change-Id: I8d89f80a5b4f2826d90474dcea441c41f0af6594
kernel/seccomp.c