From nobody Tue Sep 19 13:35:31 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RqjNF28RXz4twjS; Tue, 19 Sep 2023 13:35:41 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4RqjND60xmz4SrS; Tue, 19 Sep 2023 13:35:40 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.17.1/8.17.1) with ESMTPS id 38JDZVH2045495 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 19 Sep 2023 16:35:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 38JDZVH2045495 Received: (from kostik@localhost) by tom.home (8.17.1/8.17.1/Submit) id 38JDZVDL045494; Tue, 19 Sep 2023 16:35:31 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 19 Sep 2023 16:35:31 +0300 From: Konstantin Belousov To: Dmitry Chagin Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 227d01c1bc7c - main - linux(4): On Linux SIGKILL can not be reset to default Message-ID: References: <202309181453.38IErP3M046039@gitrepo.freebsd.org> List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on tom.home X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Queue-Id: 4RqjND60xmz4SrS On Tue, Sep 19, 2023 at 03:39:21PM +0300, Dmitry Chagin wrote: > On Tue, Sep 19, 2023 at 01:42:26PM +0300, Konstantin Belousov wrote: > > On Tue, Sep 19, 2023 at 01:05:07PM +0300, Dmitry Chagin wrote: > > > On Tue, Sep 19, 2023 at 12:05:42AM +0300, Konstantin Belousov wrote: > > > > On Mon, Sep 18, 2023 at 02:53:25PM +0000, Dmitry Chagin wrote: > > > > > The branch main has been updated by dchagin: > > > > > > > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=227d01c1bc7caf2e838ee6eef1e6a3cc81d79d1b > > > > > > > > > > commit 227d01c1bc7caf2e838ee6eef1e6a3cc81d79d1b > > > > > Author: Dmitry Chagin > > > > > AuthorDate: 2023-09-18 14:53:01 +0000 > > > > > Commit: Dmitry Chagin > > > > > CommitDate: 2023-09-18 14:53:01 +0000 > > > > > > > > > > linux(4): On Linux SIGKILL can not be reset to default > > > > > > > > > > MFC after: 1 week > > > > > --- > > > > > sys/compat/linux/linux_signal.c | 5 ++++- > > > > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > > > > > > > diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c > > > > > index e3e3fc74a6a9..9a84700b3949 100644 > > > > > --- a/sys/compat/linux/linux_signal.c > > > > > +++ b/sys/compat/linux/linux_signal.c > > > > > @@ -170,6 +170,7 @@ linux_do_sigaction(struct thread *td, int linux_sig, l_sigaction_t *linux_nsa, > > > > > > > > > > if (!LINUX_SIG_VALID(linux_sig)) > > > > > return (EINVAL); > > > > > + sig = linux_to_bsd_signal(linux_sig); > > > > > > > > > > osa = (linux_osa != NULL) ? &oact : NULL; > > > > > if (linux_nsa != NULL) { > > > > > @@ -180,9 +181,11 @@ linux_do_sigaction(struct thread *td, int linux_sig, l_sigaction_t *linux_nsa, > > > > > linux_ktrsigset(&linux_nsa->lsa_mask, > > > > > sizeof(linux_nsa->lsa_mask)); > > > > > #endif > > > > > + if ((sig == SIGKILL || sig == SIGSTOP) && > > > > > + nsa->sa_handler == SIG_DFL) > > > > > + return (EINVAL); > > > > This is excessive: look at kern_sigaction() around line 822. > > > > > > > > > > Well, I checkd that before, Bruce added this check a long time ago, > > > however, Bruce's change allows the handler to be set to SIG_DFL. > > > And I haven't found an explicit statement of how it should be in POSIX, > > > so I think it's Linux specific > > > > > > > If kern_sigaction() allows to change SIGKILL or SIGSTOP disposition from > > default, we have a serious issue. The check above simply repeats the > > check from kern_sigaction(). > > Hmm, why? Native kern_sigaction check: > > if ((sig == SIGKILL || sig == SIGSTOP) && > act->sa_handler != SIG_DFL) { > > ^^^^^^^ this allows to set sa_handler to SIG_DFL, > but Linux forbids this > > mtx_unlock(&ps->ps_mtx); > PROC_UNLOCK(p); > return (EINVAL); > } > > And I found in the POSIX: > > It is unspecified whether an attempt to set the action for a signal that > cannot be caught or ignored to SIG_DFL is ignored or causes an error to > be returned with errno set to [EINVAL]. > > The sigaction() function may fail if: > [EINVAL] > An attempt was made to set the action to SIG_DFL for a > signal that cannot be caught or ignored (or both). > > Linux returns EINVAL in that case, FreeBSD does not, both are valid? Ah, I see. Thank you for the explanation. What was the commit where bde added the check?