From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47805C7EE26 for ; Tue, 23 May 2023 15:31:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237325AbjEWPbL (ORCPT ); Tue, 23 May 2023 11:31:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbjEWPbJ (ORCPT ); Tue, 23 May 2023 11:31:09 -0400 Received: from out03.mta.xmission.com (out03.mta.xmission.com [166.70.13.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B66A1FA for ; Tue, 23 May 2023 08:31:07 -0700 (PDT) Received: from in01.mta.xmission.com ([166.70.13.51]:34090) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1q1Tyb-00EE6n-4l; Tue, 23 May 2023 09:31:05 -0600 Received: from ip68-110-29-46.om.om.cox.net ([68.110.29.46]:45292 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 1q1TyZ-007oCX-Qg; Tue, 23 May 2023 09:31:04 -0600 From: "Eric W. Biederman" To: Mike Christie Cc: oleg@redhat.com, linux@leemhuis.info, nicolas.dichtel@6wind.com, axboe@kernel.dk, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, stefanha@redhat.com, brauner@kernel.org In-Reply-To: <20230522025124.5863-2-michael.christie@oracle.com> (Mike Christie's message of "Sun, 21 May 2023 21:51:22 -0500") References: <20230522025124.5863-1-michael.christie@oracle.com> <20230522025124.5863-2-michael.christie@oracle.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Date: Tue, 23 May 2023 10:30:35 -0500 Message-ID: <87fs7n9ias.fsf@email.froward.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1q1TyZ-007oCX-Qg;;;mid=<87fs7n9ias.fsf@email.froward.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=68.110.29.46;;;frm=ebiederm@xmission.com;;;spf=pass X-XM-AID: U2FsdGVkX1+s/DSlpo+vEYOge0Lgj9pKdKRgJGOmkLw= X-SA-Exim-Connect-IP: 68.110.29.46 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH 1/3] signal: Don't always put SIGKILL in shared_pending X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mike Christie writes: > When get_pending detects the task has been marked to be killed we try to ^^^^^^^^^^^ get_signal > clean up the SIGKLL by doing a sigdelset and recalc_sigpending, but we > still leave it in shared_pending. If the signal is being short circuit > delivered there is no need to put in shared_pending so this adds a check > in complete_signal. > > This patch was modified from Eric Biederman > original patch. > > Signed-off-by: Mike Christie > --- > kernel/signal.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/kernel/signal.c b/kernel/signal.c > index 8f6330f0e9ca..3dc99b9aec7f 100644 > --- a/kernel/signal.c > +++ b/kernel/signal.c > @@ -1052,6 +1052,14 @@ static void complete_signal(int sig, struct task_struct *p, enum pid_type type) > signal->flags = SIGNAL_GROUP_EXIT; > signal->group_exit_code = sig; > signal->group_stop_count = 0; > + > + /* > + * The signal is being short circuit delivered so > + * don't set pending. > + */ > + if (type != PIDTYPE_PID) > + sigdelset(&signal->shared_pending.signal, sig); > + > t = p; > do { > task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK); Oleg Nesterov writes: > > Eric, sorry. I fail to understand this patch. > > How can it help? And whom? You were looking at why recalc_sigpending was resulting in TIF_SIGPENDING set. The big bug was that get_signal was getting called by the thread after the thread had realized it was part of a group exit. The minor bug is that SIGKILL was stuck in shared_pending and causing recalc_sigpending to set TIF_SIGPENDING after get_signal removed the per thread flag that asks the thread to exit. The fact is that fatal signals (that pass all of the checks) are delivered right there in complete_signal so it does not make sense from a data structure consistency standpoint to leave the fatal signal (like SIGKILL) in shared_pending. Outside of this case it will only affect coredumps and other analyzers that run at process exit. One thing I am looking at is that the vhost code shares a common problem with the coredump code to pipes. There is code that tests signal_pending() and does something with it after signal processing has completed. Fixing the data structure to be consistent seems like one way to handle that situation. Eric