From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out01.mta.xmission.com (out01.mta.xmission.com [166.70.13.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 061E0433E75 for ; Fri, 3 Jul 2026 21:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.70.13.231 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783114758; cv=none; b=FZdH5nOynxVbCjWqVUff/Pe6yY+00At7ic+wcEqofIR/ImdKMI7dLKuFiGsBUD9yE+WOwzaCVAZPRJm33bM1eCImzZ1a+9ZL0ofqXtGKHJGYmjNh4QRX3x1XnA4FGHkCorQtGVQe4WlZPd3vmsvpxE9N+k+jIbSE8Mmd9kjqc9M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783114758; c=relaxed/simple; bh=QCiBRx+yr87i+d3hdQ6cMGKl1/0tyvoZh+ZpxzykP1U=; h=From:To:Cc:In-Reply-To:References:Date:Message-ID:MIME-Version: Content-Type:Subject; b=mjMpL6iGodF+uULR3bcs3Sz1ZqVeU/h577hwMF1taQz1kq4Ws56XwbIZfsV5nUEBqsqbnYvbCkiWKl0Cip9OR5Ah3SY6U8nQFk4Z0U6RyC67BI0Y9yIezn9zYbeFisJF94AJvJmjAnBKQP6NiKy6JxQzPbtvCqiI5fqp8Y+7w7Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xmission.com; spf=pass smtp.mailfrom=xmission.com; dkim=pass (1024-bit key) header.d=xmission.com header.i=@xmission.com header.b=dg7s1fyT; arc=none smtp.client-ip=166.70.13.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xmission.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xmission.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xmission.com header.i=@xmission.com header.b="dg7s1fyT" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/simple; d=xmission.com; s=xmission; h=Subject:Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=QCiBRx+yr87i+d3hdQ6cMGKl1/0tyvoZh+ZpxzykP1U=; b=dg7s1fyTtv5tlk25dSSzSK7aPN ERlUzoVhmkW5l1IwuSemMBGB4Up3mGchVVaEFSQsKpCZVLspiLDJOxfrXxz6uvs2o+rUdKruqcaK6 6EoX4Bm/U0fU466P6jTCxYzsj29fuh9ZW4kSDoT+66OqkKoKI2IYo1JXxgcq1AfeDH8Q=; Received: from in01.mta.xmission.com ([166.70.13.51]:54944) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1wflbQ-00HEDK-Ac; Fri, 03 Jul 2026 15:39:16 -0600 Received: from ip72-198-198-28.om.om.cox.net ([72.198.198.28]:43786 helo=email.froward.int.ebiederm.org.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1wflbP-00DmD9-3J; Fri, 03 Jul 2026 15:39:16 -0600 From: "Eric W. Biederman" To: Oleg Nesterov Cc: Andrew Morton , Andy Lutomirski , Kees Cook , Kusaram Devineni , Peter Zijlstra , Thomas Gleixner , Will Drewry , linux-kernel@vger.kernel.org, Linus Torvalds , Christian Brauner In-Reply-To: <877bnb4uyw.fsf_-_@email.froward.int.ebiederm.org> (Eric W. Biederman's message of "Fri, 03 Jul 2026 16:35:51 -0500") References: <87o6gx9rc4.fsf@email.froward.int.ebiederm.org> <877bnh7tnf.fsf@email.froward.int.ebiederm.org> <877bnb4uyw.fsf_-_@email.froward.int.ebiederm.org> Date: Fri, 03 Jul 2026 16:39:09 -0500 Message-ID: <87echj3g8y.fsf_-_@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1wflbP-00DmD9-3J;;;mid=<87echj3g8y.fsf_-_@email.froward.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=72.198.198.28;;;frm=ebiederm@xmission.com;;;sPfnum=0;;;sPf=pass X-XM-AID: U2FsdGVkX1/3xT/PNkI55QT9Dy8iA37+psTE+p0MDpk= X-Spam-Level: X-Spam-Virus: No X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.1 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4998] * 1.5 XMNoVowels Alpha-numberic number with no vowels * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa03 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa03 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Oleg Nesterov X-Spam-Relay-Country: X-Spam-Timing: total 803 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 4.1 (0.5%), b_tie_ro: 2.8 (0.3%), parse: 1.21 (0.2%), extract_message_metadata: 11 (1.4%), get_uri_detail_list: 1.50 (0.2%), tests_pri_-2000: 10 (1.3%), tests_pri_-1000: 2.0 (0.3%), tests_pri_-950: 0.95 (0.1%), tests_pri_-900: 0.77 (0.1%), tests_pri_-90: 83 (10.3%), check_bayes: 81 (10.1%), b_tokenize: 6 (0.7%), b_tok_get_all: 6 (0.8%), b_comp_prob: 1.38 (0.2%), b_tok_touch_all: 65 (8.2%), b_finish: 0.75 (0.1%), tests_pri_0: 299 (37.3%), check_dkim_signature: 0.40 (0.0%), check_dkim_adsp: 3.6 (0.4%), poll_dns_idle: 379 (47.2%), tests_pri_10: 2.6 (0.3%), tests_pri_500: 385 (47.9%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 05/14] signal: Compute the exit_code in get_signal X-SA-Exim-Connect-IP: 166.70.13.51 X-SA-Exim-Rcpt-To: brauner@kernel.org, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, wad@chromium.org, tglx@kernel.org, peterz@infradead.org, kusaram@devineni.in, kees@kernel.org, luto@kernel.org, akpm@linux-foundation.org, oleg@redhat.com X-SA-Exim-Mail-From: ebiederm@xmission.com X-SA-Exim-Scanned: No (on out01.mta.xmission.com); SAEximRunCond expanded to false Update get_signal so it calls do_group_exit with the correct exit_code. Make the default exit_code 0, so that the special case for threads killed by de_thread falls out naturally. Update do_group_exit to trust the exit_code passed in except when SIGNAL_GROUP_EXIT is set. Moving the computation of exit_code into get_signal makes other cleanups possible. Signed-off-by: Eric W. Biederman --- kernel/exit.c | 4 ++-- kernel/signal.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/kernel/exit.c b/kernel/exit.c index 1056422bc101..c8460c215189 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -1126,7 +1126,7 @@ do_group_exit(int exit_code) if (sig->flags & SIGNAL_GROUP_EXIT) exit_code = sig->group_exit_code; else if (sig->group_exec_task) - exit_code = 0; + ; else { struct sighand_struct *const sighand = current->sighand; @@ -1135,7 +1135,7 @@ do_group_exit(int exit_code) /* Another thread got here before we took the lock. */ exit_code = sig->group_exit_code; else if (sig->group_exec_task) - exit_code = 0; + ; else { sig->group_exit_code = exit_code; sig->flags = SIGNAL_GROUP_EXIT; diff --git a/kernel/signal.c b/kernel/signal.c index b54669ac8e77..0e9103bda143 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2908,10 +2908,13 @@ bool get_signal(struct ksignal *ksig) for (;;) { struct k_sigaction *ka; enum pid_type type; + int exit_code = 0; /* Has this task already been marked for death? */ if ((signal->flags & SIGNAL_GROUP_EXIT) || signal->group_exec_task) { + if (signal->flags & SIGNAL_GROUP_EXIT) + exit_code = signal->group_exit_code; signr = SIGKILL; sigdelset(¤t->pending.signal, SIGKILL); trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO, @@ -3041,14 +3044,15 @@ bool get_signal(struct ksignal *ksig) continue; } + /* + * Anything else is fatal, maybe with a core dump. + */ + exit_code = signr; fatal: spin_unlock_irq(&sighand->siglock); if (unlikely(cgroup_task_frozen(current))) cgroup_leave_frozen(true); - /* - * Anything else is fatal, maybe with a core dump. - */ current->flags |= PF_SIGNALED; if (sig_kernel_coredump(signr)) { @@ -3078,7 +3082,7 @@ bool get_signal(struct ksignal *ksig) /* * Death signals, no core dump. */ - do_group_exit(signr); + do_group_exit(exit_code); /* NOTREACHED */ } spin_unlock_irq(&sighand->siglock); -- 2.41.0