From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751309AbdE3REj (ORCPT ); Tue, 30 May 2017 13:04:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56974 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750938AbdE3REh (ORCPT ); Tue, 30 May 2017 13:04:37 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AFB1C9782F Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=oleg@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AFB1C9782F Date: Tue, 30 May 2017 19:04:14 +0200 From: Oleg Nesterov To: Thomas Gleixner Cc: LKML , Linus Torvalds , Peter Zijlstra , Ingo Molnar , Michael Kerrisk , linux-man@vger.kernel.org, libc-alpha@sourceware.org Subject: Re: signals: Bug or manpage inconsistency? Message-ID: <20170530170414.GA22463@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 30 May 2017 17:04:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/30, Thomas Gleixner wrote: > > So I found at least some explanation by studying the spec some more. > > There are two variants of ignored signals: > > 1) handler is SIG_IGN > > 2) handler is SIG_DFL and default action is 'ignore' Yes, and note that sys_rt_sigaction() discard the pending signal in both cases. So even with this change the logic won't look 100% consistent. I can't comment, I never tried to understand the rationality behind the current behaviour. But at least the sending path should never drop a blocked SIG_DFL signal, there is no other way to ensure you won't miss a signal during exec. > --- a/kernel/signal.c > +++ b/kernel/signal.c > @@ -70,6 +70,13 @@ static int sig_handler_ignored(void __us > (handler == SIG_DFL && sig_kernel_ignore(sig)); > } > > +static int sig_handler_is_sigign(struct task_struct *t, int sig) > +{ > + void __user *handler = sig_handler(t, sig); > + > + return handler == SIG_IGN; > +} > + > static int sig_task_ignored(struct task_struct *t, int sig, bool force) > { > void __user *handler; > @@ -91,7 +98,7 @@ static int sig_ignored(struct task_struc > * unblocked. > */ > if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig)) > - return 0; > + return sig_handler_is_sigign(t, sig); we can probably make a simpler change, but this doesn't matter. Obviously this is a user-visible change and it can break something. Say, an application does sigwaitinfo(SIGCHLD) and SIGCHLD is ignored (SIG_IGN), this will no longer work. I won't argue, but perhaps it is too late change this historical behaviour. Although perhaps we can cleanup do_sigtimedwait() for the start. ->real_blocked doesn't look nice. I think we can replace it with task->sigwait_mask and then change sig_handler() to do sigismember(sigwait_mask, sig) ? SIG_ERR : t->sighand->action[sig - 1].sa.sa_handler; this needs other changes, say, sig_fatal() will need to use sig_handler() too. Then it would be more safe to drop the SIG_IGN signals unconditionally. Oleg.