lineage_android_kernel_sams.../kernel
Kees Cook dec911d38e 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
2014-09-18 21:18:31 -05:00
..
debug Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
events Merge remote-tracking branch 'caf/kk_2.7-stable' into cm-11.0 2014-08-14 00:37:05 -05:00
gcov
irq Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
power Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
sched Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
time Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
trace Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
.gitignore
Kconfig.freezer
Kconfig.hz
Kconfig.locks locking/kconfig: Simplify INLINE_SPIN_UNLOCK usage 2012-03-23 13:18:57 +01:00
Kconfig.preempt locking/kconfig: Simplify INLINE_SPIN_UNLOCK usage 2012-03-23 13:18:57 +01:00
Makefile hotplug: Fix UP bug in smpboot hotplug code 2014-03-27 17:45:12 -07:00
acct.c Merge branch 'for-linus2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2012-01-08 12:19:57 -08:00
async.c Fix a dead loop in async_synchronize_full() 2012-10-02 10:30:35 -07:00
audit.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
audit.h audit: remove AUDIT_SETUP_CONTEXT as it isn't used 2012-01-17 16:16:57 -05:00
audit_tree.c kernel/audit_tree.c: tree will leak memory when failure occurs in audit_trim_trees() 2013-05-11 13:48:14 -07:00
audit_watch.c
auditfilter.c audit: allow interfield comparison in audit rules 2012-01-17 16:17:01 -05:00
auditsc.c seccomp: remove duplicated failure logging 2014-09-18 21:17:58 -05:00
backtracetest.c
bounds.c
capability.c Revert "capabitlies: ns_capable can use the cap helpers rather than lsm call" 2012-01-17 10:19:41 -08:00
cgroup.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
cgroup_freezer.c cgroup: cgroup_subsys->fork() should be called after the task is added to css_set 2014-03-11 16:10:03 -07:00
compat.c compat: Fix RT signal mask corruption via sigprocmask 2012-05-10 08:58:33 -07:00
configs.c
cpu.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
cpu_pm.c ARM: cpu_pm: Add cpu power management notifiers 2011-11-29 16:42:33 -05:00
cpuset.c cpuset,mempolicy: fix sleeping function called from invalid context 2014-07-17 15:39:49 -07:00
crash_dump.c Merge branch 'modsplit-Oct31_2011' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux 2011-11-06 19:44:47 -08:00
cred.c cred: copy_process() should clear child->replacement_session_keyring 2012-04-11 08:20:11 -07:00
delayacct.c
dma.c Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
elfcore.c
exec_domain.c
exit.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
extable.c
fork.c seccomp: add system call filtering using BPF 2014-09-18 21:17:57 -05:00
freezer.c freezer: skip waking up tasks with PF_FREEZER_SKIP set 2014-03-27 17:42:36 -07:00
futex.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
futex_compat.c futex: Revert "futex: Mark get_robust_list as deprecated" 2013-02-28 06:59:01 -08:00
groups.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
hrtimer.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
hung_task.c hung_task: fix the broken rcu_lock_break() logic 2012-03-05 15:49:42 -08:00
irq_work.c irq_work: fix compile failure on tile from missing include 2012-04-13 13:15:16 -04:00
itimer.c itimer: Use printk_once instead of WARN_ONCE 2012-04-10 11:00:30 +02:00
jump_label.c static keys: Inline the static_key_enabled() function 2012-02-28 20:01:08 +01:00
kallsyms.c vsprintf: Fix %ps on non symbols when using kallsyms 2012-04-23 14:29:54 -07:00
kexec.c Add and enable kexec hardboot support. 2014-03-27 17:42:18 -07:00
kfifo.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
kmod.c usermodehelper: check subprocess_info->path != NULL 2013-05-19 10:54:50 -07:00
kprobes.c Merge branch 'Linux 3.0.21' into msm-3.0 2012-03-30 00:09:34 -07:00
ksysfs.c kernel: ksysfs.c is implicitly using stat.h 2011-10-31 09:20:13 -04:00
kthread.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
latencytop.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
lockdep.c lockdep: remove task argument from debug_check_no_locks_held 2014-03-27 17:42:36 -07:00
lockdep_internals.h
lockdep_proc.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
lockdep_states.h
module.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
mutex-debug.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
mutex-debug.h
mutex.c mutex: back out architecture specific check for negative mutex count 2014-03-27 17:46:50 -07:00
mutex.h
notifier.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
nsproxy.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
padata.c padata: Fix cpu hotplug 2012-03-29 19:52:46 +08:00
panic.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
params.c params: <level>_initcall-like kernel parameters 2012-03-26 12:50:51 +10:30
pid.c vfs: fix panic in __d_lookup() with high dentry hashtable counts 2012-02-13 20:45:38 -05:00
pid_namespace.c pidns: add reboot_pid_ns() to handle the reboot syscall 2012-03-28 17:14:36 -07:00
posix-cpu-timers.c posix-cpu-timers: Fix nanosleep task_struct leak 2013-02-28 06:58:59 -08:00
posix-timers.c posix-timer: Don't call idr_find() with out-of-range ID 2013-03-04 06:06:38 +08:00
printk.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
profile.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
ptrace.c Import Samsung release ML4 on CAF kk_2.7_rb1.19 2014-03-27 17:42:15 -07:00
range.c range: fix bogus misuse of module.h to get printk() 2011-10-31 09:20:11 -04:00
rcu.h rcu: Allow nesting of rcu_idle_enter() and rcu_idle_exit() 2012-02-21 09:06:12 -08:00
rcupdate.c rcu: Make exit_rcu() more precise and consolidate 2014-08-02 12:52:27 -05:00
rcutiny.c rcu: Add RCU_NONIDLE() for idle-loop RCU read-side critical sections 2012-02-21 09:06:13 -08:00
rcutiny_plugin.h rcu: Make exit_rcu() more precise and consolidate 2014-08-02 12:52:27 -05:00
rcutorture.c PTR_ERR should be called before its argument is cleared. 2012-02-21 09:06:10 -08:00
rcutree.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
rcutree.h Revert "rcu: Move PREEMPT_RCU preemption to switch_to() invocation" 2014-08-02 12:52:38 -05:00
rcutree_plugin.h Revert "rcu: Move PREEMPT_RCU preemption to switch_to() invocation" 2014-08-02 12:52:38 -05:00
rcutree_trace.c rcu: Make rcu_barrier() less disruptive 2014-08-02 12:52:31 -05:00
relay.c splice: fix racy pipe->buffers uses 2012-07-16 09:04:42 -07:00
res_counter.c net: introduce res_counter_charge_nofail() for socket allocations 2012-01-22 15:08:46 -05:00
resource.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
rtmutex-debug.c lockdep, rtmutex, bug: Show taint flags on error 2011-12-06 08:16:49 +01:00
rtmutex-debug.h rtmutex: Handle deadlock detection smarter 2014-07-17 15:39:50 -07:00
rtmutex-tester.c rtmutex-tester: convert sysdev_class to a regular subsystem 2011-12-14 14:54:22 -08:00
rtmutex.c rtmutex: Plug slow unlock race 2014-07-17 15:39:50 -07:00
rtmutex.h rtmutex: Handle deadlock detection smarter 2014-07-17 15:39:50 -07:00
rtmutex_common.h
rwsem.c Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
seccomp.c seccomp: split filter prep from check and apply 2014-09-18 21:18:31 -05:00
semaphore.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
signal.c signal, x86: add SIGSYS info and make it synchronous. 2014-09-18 21:18:01 -05:00
smp.c smp, idle: Allocate idle thread for each possible cpu during boot 2014-03-27 17:45:12 -07:00
smpboot.c stop_machine: Mark per cpu stopper enabled early 2014-03-27 17:45:13 -07:00
smpboot.h smpboot: Provide infrastructure for percpu hotplug threads 2014-03-27 17:45:12 -07:00
softirq.c softirq: reduce latencies 2014-03-27 17:48:12 -07:00
spinlock.c locking/kconfig: Simplify INLINE_SPIN_UNLOCK usage 2012-03-23 13:18:57 +01:00
srcu.c rcu: Call out dangers of expedited RCU primitives 2012-02-21 09:06:08 -08:00
stacktrace.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
stop_machine.c stop_machine: Mark per cpu stopper enabled early 2014-03-27 17:45:13 -07:00
sys.c sched: move no_new_privs into new atomic flags 2014-09-18 21:18:29 -05:00
sys_ni.c seccomp: add "seccomp" syscall 2014-09-18 21:18:26 -05:00
sysctl.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
sysctl_binary.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
taskstats.c Make TASKSTATS require root access 2011-12-21 12:57:40 -08:00
test_kprobes.c
time.c time: Remove bogus comments 2012-03-15 18:17:55 -07:00
timeconst.pl timeconst.pl: Eliminate Perl warning 2013-02-28 06:58:58 -08:00
timer.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
tracepoint.c tracepoint: Do not waste memory on mods with no tracepoints 2014-05-18 05:25:56 -07:00
tsacct.c [S390] cputime: add sparse checking and cleanup 2011-12-15 14:56:19 +01:00
uid16.c
up.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
user-return-notifier.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
user.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
user_namespace.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
utsname.c kernel: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
utsname_sysctl.c Merge branch 'modsplit-Oct31_2011' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux 2011-11-06 19:44:47 -08:00
wait.c lockdep/waitqueues: Add better annotation 2011-12-21 10:07:39 +01:00
watchdog.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
workqueue.c Merge remote-tracking branch 'korg/linux-3.4.y' into cm-11.0 2014-08-13 23:51:05 -05:00
workqueue_sched.h