Skip to content

Commit 4d671d9

Browse files
Rich Felkerkees
authored andcommitted
seccomp: kill process instead of thread for unknown actions
Asynchronous termination of a thread outside of the userspace thread library's knowledge is an unsafe operation that leaves the process in an inconsistent, corrupt, and possibly unrecoverable state. In order to make new actions that may be added in the future safe on kernels not aware of them, change the default action from SECCOMP_RET_KILL_THREAD to SECCOMP_RET_KILL_PROCESS. Signed-off-by: Rich Felker <[email protected]> Link: https://lore.kernel.org/r/[email protected] [kees: Fixed up coredump selection logic to match] Signed-off-by: Kees Cook <[email protected]>
1 parent e839317 commit 4d671d9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kernel/seccomp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ static int __seccomp_filter(int this_syscall, const struct seccomp_data *sd,
10201020
default:
10211021
seccomp_log(this_syscall, SIGSYS, action, true);
10221022
/* Dump core only if this is the last remaining thread. */
1023-
if (action == SECCOMP_RET_KILL_PROCESS ||
1023+
if (action != SECCOMP_RET_KILL_THREAD ||
10241024
get_nr_threads(current) == 1) {
10251025
kernel_siginfo_t info;
10261026

@@ -1030,10 +1030,10 @@ static int __seccomp_filter(int this_syscall, const struct seccomp_data *sd,
10301030
seccomp_init_siginfo(&info, this_syscall, data);
10311031
do_coredump(&info);
10321032
}
1033-
if (action == SECCOMP_RET_KILL_PROCESS)
1034-
do_group_exit(SIGSYS);
1035-
else
1033+
if (action == SECCOMP_RET_KILL_THREAD)
10361034
do_exit(SIGSYS);
1035+
else
1036+
do_group_exit(SIGSYS);
10371037
}
10381038

10391039
unreachable();

0 commit comments

Comments
 (0)