Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp528595imm; Thu, 26 Jul 2018 07:44:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpegBB12QTAjv/9Dj5Eq2eL/meSwjdbb85jeIVi1EM1mMKaBWr2pz6GIKxtiLrKOnZr0u01i X-Received: by 2002:a62:b917:: with SMTP id z23-v6mr2446463pfe.131.1532616293755; Thu, 26 Jul 2018 07:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532616293; cv=none; d=google.com; s=arc-20160816; b=sYIs5hKphYdpakjjhBjYvJz3ZE7RBDMIUiziOaOQohAc/DbRSTpVLOEjGyzH2VZ6py W3GdmnXXLNH6cH1fzXNAtB1y17YCo5ktJBXybC62GBMKLf8uw0r8GVwIxzX+94UAqYf0 udYt8F3HnqrN1hwe5zrTQ7+rWczn3/eApUY46O/L5yln/AaCkWMTWRWa0SrLNdiUf9Ar EN8uxiGY3gpXGs/xohyBTP6isrsOrqCkKsseBiEE2WKzcmB20hFfT5+cgb+NtIIx3uJ/ wpYqeEp1A1kgYX3hmu2BFCymJNdsgu6vuTF/MeTQn5+8JwN0AHgl7p2QT93ethLdNDQq ISfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from :arc-authentication-results; bh=RluoSn95WS/L/7nrd1ErpEIyY/lnqEEbimPmxVJPmF8=; b=x1xY03qLlYVp2JJacMHi/llOacbfq7Dj7jsB0mGv+dN0xPdGVnobo7YzIddIniOLFx hY+WOeVFmhmHzv1KaWfSLOgBVyUmZM9uCFcUdHbTLslWGTta+uY5WWnafgkXPUWAV5kH 9Wrdc5BRy87jAhWC8DorrqWm8oZzJwvacW5KQy+Jw4ort6Xpj2dIUEKg2sDev4ARk+NZ rKgmuoZRV7rQ8yNXcsOKPrZR149Akci7Bkfp8wWlsqwKVeWnwAj64j8qyu2u2wABX2GI +IYrWHoFVN9SI7U+ARb6AkjXb8NH8M/3omtq+vZ6E72DObH6EcQ7P0kL1BS9F0AfcLE5 mgpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2-v6si1299024pla.509.2018.07.26.07.44.37; Thu, 26 Jul 2018 07:44:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731480AbeGZP7a (ORCPT + 99 others); Thu, 26 Jul 2018 11:59:30 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:38871 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730068AbeGZP7a (ORCPT ); Thu, 26 Jul 2018 11:59:30 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out03.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fihT8-0006od-Jz; Thu, 26 Jul 2018 08:42:18 -0600 Received: from [97.119.167.31] (helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fihT8-0007gP-17; Thu, 26 Jul 2018 08:42:18 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Oleg Nesterov Cc: Linus Torvalds , Andrew Morton , Linux Kernel Mailing List , Wen Yang , majiang References: <20180724032419.20231-20-ebiederm@xmission.com> <874lgo5xdg.fsf@xmission.com> <87fu084cxj.fsf@xmission.com> <87a7qg4bb3.fsf_-_@xmission.com> <87pnzc2upf.fsf@xmission.com> <87k1pk2cj9.fsf_-_@xmission.com> <20180726134143.GB32718@redhat.com> Date: Thu, 26 Jul 2018 09:42:13 -0500 In-Reply-To: <20180726134143.GB32718@redhat.com> (Oleg Nesterov's message of "Thu, 26 Jul 2018 15:41:43 +0200") Message-ID: <87pnza6ou2.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1fihT8-0007gP-17;;;mid=<87pnza6ou2.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=97.119.167.31;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18F+m/dDyNdcr6xh1zYNeU1d2TldBrSJNU= X-SA-Exim-Connect-IP: 97.119.167.31 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa06.xmission.com X-Spam-Level: X-Spam-Status: No, score=0.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TM2_M_HEADER_IN_MSG,T_TooManySym_01,T_TooManySym_02, XMSubLong autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.0 T_TooManySym_02 5+ unique symbols in subject X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Oleg Nesterov X-Spam-Relay-Country: X-Spam-Timing: total 220 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 2.8 (1.3%), b_tie_ro: 1.97 (0.9%), parse: 0.87 (0.4%), extract_message_metadata: 3.4 (1.5%), get_uri_detail_list: 1.39 (0.6%), tests_pri_-1000: 4.1 (1.8%), tests_pri_-950: 1.32 (0.6%), tests_pri_-900: 1.07 (0.5%), tests_pri_-400: 21 (9.6%), check_bayes: 20 (9.1%), b_tokenize: 6 (2.9%), b_tok_get_all: 7 (3.2%), b_comp_prob: 2.2 (1.0%), b_tok_touch_all: 2.4 (1.1%), b_finish: 0.58 (0.3%), tests_pri_0: 169 (76.8%), check_dkim_signature: 0.58 (0.3%), check_dkim_adsp: 7 (3.1%), tests_pri_500: 9 (3.9%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH v3 20/20] signal: Don't restart fork when signals come in. X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Oleg Nesterov writes: > On 07/24, Eric W. Biederman wrote: >> >> @@ -1979,6 +1983,8 @@ static __latent_entropy struct task_struct *copy_process( >> attach_pid(p, PIDTYPE_TGID); >> attach_pid(p, PIDTYPE_PGID); >> attach_pid(p, PIDTYPE_SID); >> + p->signal->shared_pending.signal = delayed.signal; > > Again, in this case we do not hold p->sighand->siglock (unless CLONE_SIGHAND), > so this should be done before list_add_tail/attach_pid above. Plus we need some > sort of barrier. > > Or we can do > > if (!CLONE_SIGHAND) > spin_lock_nested(child->siglock); > > at the start of "if (likely(p->pid))" block. Good point. We want to exclude races between new signals comming in and gathering the information from the old queued signals. I will take a look. >> --- a/kernel/signal.c >> +++ b/kernel/signal.c >> @@ -1123,6 +1123,15 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t, >> out_set: >> signalfd_notify(t, sig); >> sigaddset(&pending->signal, sig); >> + >> + /* Let multiprocess signals appear after on-going forks */ >> + if (type > PIDTYPE_TGID) { >> + struct multiprocess_signals *delayed; >> + hlist_for_each_entry(delayed, &t->signal->multiprocess, node) { >> + sigaddset(&delayed->signal, sig); > > This is not enough, I think... > > Suppose you send SIGSTOP and then SIGCONT to some process group. The 1st SIGSTOP > will be queued correctly, but the 2nd SIGCONT won't flush the pending SIGSTOP, you > need to modify prepare_signal() too. Good point. We can't have both SIGCONT and a stop signal (SIGSTOP or SIGTSTP) enqueued at the same time. And there is something in the prepare_signal code about parent notifications as well. I will look up the fine points of SIGCONT and SIGSTOP interaction and see what we should be doing here. Sigh. I thought this was going to be as simple as the sequence counter but this looks a tad more complicated. Are the earlier patches looking ok to you? Eric