2021-06-24 19:02:00

by Eric W. Biederman

[permalink] [raw]
Subject: [PATCH 3/9] signal/seccomp: Dump core when there is only one live thread


Replace get_nr_threads with atomic_read(&current->signal->live) as
that is a more accurate number that is decremented sooner.

Signed-off-by: "Eric W. Biederman" <[email protected]>
---
kernel/seccomp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index 3e06d4628d98..5301eca670a0 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -1241,7 +1241,7 @@ static int __seccomp_filter(int this_syscall, const struct seccomp_data *sd,
seccomp_log(this_syscall, SIGSYS, action, true);
/* Dump core only if this is the last remaining thread. */
if (action != SECCOMP_RET_KILL_THREAD ||
- get_nr_threads(current) == 1) {
+ (atomic_read(&current->signal->live) == 1)) {
/* Show the original registers in the dump. */
syscall_rollback(current, current_pt_regs());
/* Trigger a coredump with SIGSYS */
--
2.20.1


2021-06-26 03:22:11

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 3/9] signal/seccomp: Dump core when there is only one live thread

On Thu, Jun 24, 2021 at 02:00:22PM -0500, Eric W. Biederman wrote:
> Replace get_nr_threads with atomic_read(&current->signal->live) as
> that is a more accurate number that is decremented sooner.

Okay, seems fine to me. :)

--
Kees Cook