From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out02.mta.xmission.com (out02.mta.xmission.com [166.70.13.232]) (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 F25713F9F4D for ; Fri, 26 Jun 2026 16:59:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.70.13.232 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782493155; cv=none; b=rb1ElgejZTCSqRu1+h/gubKJlo3shkdcKCVtkKmuGyJQ3HDlvAMpYGX9QY7xYTjXCo2gPHIcK6MBKHYBt5Sc/DesB9ZQ06KR6jky2v+khy8545KF7XihQ7wS8qSYycRg/bMxj8kt0SJPQTz0DXyIvdqvU8KDj3JqknHboGKwTSQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782493155; c=relaxed/simple; bh=VwXEMDZU3MddfmfhEG3dmZvH+NRyjmYwYSr6zF2Ka9U=; h=From:To:Cc:In-Reply-To:References:Date:Message-ID:MIME-Version: Content-Type:Subject; b=C7mvvWwYUzzkdKl1wBklDL3pdzWwov2/RlMWuhNSdtulboClL3svh7rmGbysneg0Hkl0wswj+Ywv6PJXzT/ydzLTfpinHbwmL2taFb8Tv0f8OiXpGfoU4GMAtDsaCSKJqaUvuoF0/qL2gOQHxq3WLhD07GOUAAl6i6CcSEthYzM= 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=LOaxXDAv; arc=none smtp.client-ip=166.70.13.232 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="LOaxXDAv" 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=VwXEMDZU3MddfmfhEG3dmZvH+NRyjmYwYSr6zF2Ka9U=; b=LOaxXDAvtTtC7srrtln26wkzc/ rlnceopv8WFw97mvNozZ1meEr5V5Wo9PGkPyXJyQ6qHLdr2rcz9VJ31S89nzEB1XJa7q40r5C5gZI rzOUmYU4NVoT00nfXeg7ja/dfrDTeZLQkWNM5xd2XkNiWz+5Wy2cFxe4YR6hI9EluWd0=; Received: from in02.mta.xmission.com ([166.70.13.52]:41756) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1wd9tZ-008j6X-17; Fri, 26 Jun 2026 10:59:13 -0600 Received: from ip72-198-198-28.om.om.cox.net ([72.198.198.28]:39386 helo=email.froward.int.ebiederm.org.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1wd9tY-0041ZB-1p; Fri, 26 Jun 2026 10:59:12 -0600 From: "Eric W. Biederman" To: Andrew Morton Cc: Andy Lutomirski , Kees Cook , Kusaram Devineni , Peter Zijlstra , Thomas Gleixner , Will Drewry , linux-kernel@vger.kernel.org, Oleg Nesterov In-Reply-To: <87o6gx9rc4.fsf@email.froward.int.ebiederm.org> (Eric W. Biederman's message of "Fri, 26 Jun 2026 11:52:43 -0500") References: <87o6gx9rc4.fsf@email.froward.int.ebiederm.org> Date: Fri, 26 Jun 2026 11:59:06 -0500 Message-ID: <878q818ch1.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=1wd9tY-0041ZB-1p;;;mid=<878q818ch1.fsf_-_@email.froward.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=72.198.198.28;;;frm=ebiederm@xmission.com;;;sPfnum=0;;;sPf=pass X-XM-AID: U2FsdGVkX19241MVxeUsiDEC6MI2oXYeuOq9K/eEcBc= X-Spam-Level: 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.5000] * 1.5 XMNoVowels Alpha-numberic number with no vowels * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Andrew Morton X-Spam-Relay-Country: X-Spam-Timing: total 523 ms - load_scoreonly_sql: 0.09 (0.0%), signal_user_changed: 10 (1.8%), b_tie_ro: 8 (1.5%), parse: 1.50 (0.3%), extract_message_metadata: 15 (2.8%), get_uri_detail_list: 2.3 (0.4%), tests_pri_-2000: 13 (2.6%), tests_pri_-1000: 2.8 (0.5%), tests_pri_-950: 1.25 (0.2%), tests_pri_-900: 1.08 (0.2%), tests_pri_-90: 73 (14.0%), check_bayes: 71 (13.7%), b_tokenize: 9 (1.7%), b_tok_get_all: 6 (1.2%), b_comp_prob: 2.7 (0.5%), b_tok_touch_all: 50 (9.6%), b_finish: 0.88 (0.2%), tests_pri_0: 382 (73.1%), check_dkim_signature: 0.66 (0.1%), check_dkim_adsp: 2.6 (0.5%), poll_dns_idle: 0.76 (0.1%), tests_pri_10: 3.2 (0.6%), tests_pri_500: 16 (3.1%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 09/11] signal: Dequeue fatal signals X-SA-Exim-Connect-IP: 166.70.13.52 X-SA-Exim-Rcpt-To: oleg@redhat.com, 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 X-SA-Exim-Mail-From: ebiederm@xmission.com X-SA-Exim-Scanned: No (on out02.mta.xmission.com); SAEximRunCond expanded to false Fatal signals are detected early and historically have not been dequeued. This barely matters as the process exits immediately. Not dequeuing the signal is visible to userspace inspecting the dying process through proc and will be to coredumps once we start using short circuit delivery for them. To keep things simple always populate siginfo in dequeue_exit_signal and always pass the dequeueed siginfo to trace_signal_deliver. In the slim chance that the fatal signal was a posix timer free the posix timer's sigqueue. In general this is not safe with tasklist_lock held because tasklist_lock needs to nest under it_lock. In this case I have read through posixtimer_sigqueue_putref and I can not find it taking the timer's it_lock. Signed-off-by: "Eric W. Biederman" --- include/linux/sched/signal.h | 1 + kernel/signal.c | 40 ++++++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index 1ea0a89cbef0..df7a3c4530e4 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -262,6 +262,7 @@ struct signal_struct { #define SIGNAL_STOP_STOPPED 0x00000001 /* job control stop in effect */ #define SIGNAL_STOP_CONTINUED 0x00000002 /* SIGCONT since WCONTINUED reap */ #define SIGNAL_GROUP_EXIT 0x00000004 /* group exit in progress */ +#define SIGNAL_EXIT_DEQUEUE 0x00000008 /* Dequeue the exit signal */ /* * Pending notifications to parent. */ diff --git a/kernel/signal.c b/kernel/signal.c index 89075c60b92b..ce3a99573aa9 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -665,6 +665,34 @@ int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type) } EXPORT_SYMBOL_GPL(dequeue_signal); +static int dequeue_exit_signal( + struct task_struct *tsk, int exit_code, kernel_siginfo_t *info) +{ + struct signal_struct *signal = tsk->signal; + + if (signal->flags & SIGNAL_EXIT_DEQUEUE) { + struct sigpending *pending = NULL; + struct sigqueue *timer_sigq; + int signr = exit_code; + + signal->flags &= ~SIGNAL_EXIT_DEQUEUE; + + pending = sigismember(&tsk->pending.signal, signr) ? + &tsk->pending : &signal->shared_pending; + + collect_signal(signr, pending, info, &timer_sigq); + if (unlikely(timer_sigq)) { + posixtimer_sigqueue_putref(timer_sigq); + } + return signr; + } + /* There is no short-circuit signal to dequeue -- fake something */ + clear_siginfo(info); + info->si_signo = SIGKILL; + info->si_code = SI_KERNEL; + return info->si_signo; +} + static int dequeue_synchronous_signal(kernel_siginfo_t *info) { struct task_struct *tsk = current; @@ -1012,7 +1040,7 @@ static void complete_signal(int sig, struct task_struct *p, enum pid_type type) * running and doing things after a slower * thread has the fatal signal pending. */ - signal->flags = SIGNAL_GROUP_EXIT; + signal->flags = SIGNAL_GROUP_EXIT | SIGNAL_EXIT_DEQUEUE; signal->group_exit_code = sig; signal->group_stop_count = 0; __for_each_thread(signal, t) { @@ -2874,15 +2902,11 @@ bool get_signal(struct ksignal *ksig) 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, - &sighand->action[SIGKILL-1]); + signr = dequeue_exit_signal(current, exit_code, &ksig->info); + trace_signal_deliver(signr, &ksig->info, + &sighand->action[signr-1]); recalc_sigpending(); - /* - * implies do_group_exit() or return to PF_USER_WORKER, - * no need to initialize ksig->info/etc. - */ goto fatal; } -- 2.41.0