Skip to content

Commit

Permalink
seccomp: Only dump core when single-threaded
Browse files Browse the repository at this point in the history
The SECCOMP_RET_KILL filter return code has always killed the current
thread, not the entire process. Changing this as a side-effect of dumping
core isn't a safe thing to do (a few test suites have already flagged this
behavioral change). Instead, restore the RET_KILL semantics, but still
dump core when a RET_KILL delivers SIGSYS to a single-threaded process.

Fixes: b25e671 ("seccomp: dump core when using SECCOMP_RET_KILL")
Signed-off-by: Kees Cook <[email protected]>
Acked-by: Andrei Vagin <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
kees authored and James Morris committed Feb 22, 2017
1 parent 37c8596 commit d7276e3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions kernel/seccomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,14 @@ static int __seccomp_filter(int this_syscall, const struct seccomp_data *sd,
default: {
siginfo_t info;
audit_seccomp(this_syscall, SIGSYS, action);
/* Show the original registers in the dump. */
syscall_rollback(current, task_pt_regs(current));
/* Trigger a manual coredump since do_exit skips it. */
seccomp_init_siginfo(&info, this_syscall, data);
do_coredump(&info);
/* Dump core only if this is the last remaining thread. */
if (get_nr_threads(current) == 1) {
/* Show the original registers in the dump. */
syscall_rollback(current, task_pt_regs(current));
/* Trigger a manual coredump since do_exit skips it. */
seccomp_init_siginfo(&info, this_syscall, data);
do_coredump(&info);
}
do_exit(SIGSYS);
}
}
Expand Down

0 comments on commit d7276e3

Please sign in to comment.