seccomp: Only dump core when single-threaded
PATCH 1/1 seccomp: Only dump core when single-threaded
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.
--- kernel/seccomp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/seccomp.c +8 -5
@@ -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 ); } }
Signature · 6 lines
2.7.4 -- Kees Cook Pixel Security
Quoted 8 lines · Kees Cook
The
SECCOMP_RET_KILLfilter 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 theRET_KILLsemantics, but still dump core when aRET_KILLdelivers SIGSYS to a single-threaded process.Fixes b25e67161c29 ("seccomp: dump core when using SECCOMP_RET_KILL")Signed-off-by Kees Cook <[email protected]>
All CRIU tests passed with this patch. Thanks!
Quoted 35 lines
--- kernel/seccomp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)kernel/seccomp.c +8
-5@@ -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 ); } }Signature · 6 lines
2.7.4 -- Kees Cook Pixel Security
Quoted 7 lines · Andrei Vagin
Quoted 6 lines · Kees Cook
The
SECCOMP_RET_KILLfilter 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 theRET_KILLsemantics, but still dump core when aRET_KILLdelivers SIGSYS to a single-threaded process.
Quoted 6 lines
Quoted 2 lines
Fixes b25e67161c29 ("seccomp: dump core when using SECCOMP_RET_KILL")Signed-off-by Kees Cook <[email protected]>All CRIU tests passed with this patch. Thanks!
Acked-by Andrei Vagin <[email protected]>
Thanks for testing!
James, can you make sure this makes it into your -next tree for v4.11?
Thanks!
-Kees
Quoted 36 lines
Quoted 36 lines
--- kernel/seccomp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)kernel/seccomp.c +8
-6@@ -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 ); } } --2.7.4
--
Kees Cook
Pixel Security
Signature · 2 lines
Kees Cook Pixel Security
Quoted 1 line · Kees Cook
James, can you make sure this makes it into your -next tree for v4.11?
Queued for next at:
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git#next-queue
Signature · 2 lines
James Morris <[email protected]>
Quoted 7 lines · James Morris
Quoted 1 line · Kees Cook
James, can you make sure this makes it into your -next tree for v4.11?
Queued for next at:
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git#next-queue
The b25e67161c29 ("seccomp: dump core when using SECCOMP_RET_KILL") is in the Linus' tree, but this patch isn't there yet. And I don't see it event in linux-next.
Do you have any plan to push it into the linus' tree?
https://travis-ci.org/avagin/criu/builds/204341051
Thanks,
Andrei
Quoted 5 lines
Signature · 3 lines
-- James Morris <[email protected]>
Quoted 9 lines · Andrei Vagin
Quoted 7 lines · James Morris
Quoted 1 line · Kees Cook
James, can you make sure this makes it into your -next tree for v4.11?
Queued for next at:
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git#next-queue
Quoted 7 lines
The
b25e67161c29("seccomp: dump core when usingSECCOMP_RET_KILL") is in the Linus' tree, but this patch isn't there yet. And I don't see it event in linux-next.Do you have any plan to push it into the linus' tree?
Yup, I already called James's attention to this. He just sent a pull request with the fix.
-Kees
Signature · 2 lines
Kees Cook Pixel Security