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 X-Spam-Level: X-Spam-Status: No, score=-10.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3DABC4363D for ; Thu, 8 Oct 2020 02:23:18 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1C3E22085B for ; Thu, 8 Oct 2020 02:23:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KcOkrjOu"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="v+1peSPo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C3E22085B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VwcBuwG7N8xm4YXdYiXd+fvY/0LybVwoIch5BdzuUKk=; b=KcOkrjOu3pY6IjZ5QR0b/RS8D Bhbkn5A9z1GeEs04ikxMHSQuCGUqVRMVDClYGkYREF/iwlazWkbyQLT29HDL8kqfMQRq5wy9u4KqT w7o3XotjCmvgJsgB+7W5znTu1htTEEfeCmK7L5uzc8AgqzKg1gciRIhSmpEBPeYhmw4Ni1hP27Fhx vd32jWg9jC/NwYq3PvNcgRB/lE1d5i+uzW/XsOkXenI2nPY97WiJs40Lx8OGPytEFRIw8jr+yNUFw fccbhkegk0Kd5NyoBPRMI/6JhtmZZYSqNgwRC+jFjJnjIXrp3j3FOrTgecFzmZ51jKgHkkWBzYwG9 EUqyAqQ/w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQLYr-0008Dl-Te; Thu, 08 Oct 2020 02:21:41 +0000 Received: from mail-vs1-xe41.google.com ([2607:f8b0:4864:20::e41]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQLYp-0008DO-1f for linux-arm-kernel@lists.infradead.org; Thu, 08 Oct 2020 02:21:39 +0000 Received: by mail-vs1-xe41.google.com with SMTP id x185so2257187vsb.1 for ; Wed, 07 Oct 2020 19:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Axxhf8ZkvoK3/mfrSUKF8oGt4VS3vK3Lrcneu1e8L88=; b=v+1peSPo8jWRRDNt+oe7uWRGJT1Cx+rKqW0VmqyLko+/LFp7ZVm27l70gJmLzMkpKg 1LIFFF+v+WZNEF/apGUKuGTVGWqT/U70lmugwnSM+R7z5SDGp+rdkNd2+b2PU+R3xg/O aldSoTPSH98TA465gGvx93g2yzMLMr94MUugxgAFMDAjo5N3MNGaChBddyY//4X8xUb4 BJtQkBIVZ6C/12b2GzZwyzQXaffY+8pdQ3QvgByeEMf9RFFF7kpnK4N18U5tYbfoe8P7 lwZBxatmXdI48DEb9BovyFsmEOfroWIyhhHOyIwOzgHU/mrwrgrBrn/tAyKL3DmFm9Eh snKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Axxhf8ZkvoK3/mfrSUKF8oGt4VS3vK3Lrcneu1e8L88=; b=EvQhatTOpcWeJpUeshG6WvkGC0MEfJ7gIvqAJ7YvE1BhQFdJ2stdqyFxkB1peBPmDN zDqtDSKkihmxX0Bb7v93jaGb+3d2AAfuNQrlfUJcVYt4ima1cV9LmJQsvpFAWeFm10kb P1EdeDyA2/cNF2PRHYFnypBsBky2Cn58xSTjFOo8f/YISkju6n2UFYWZ6jUkdMCdyUkq ZrjiELIktFmf7R10WmgU89S4OuzFPuRaJxWzWFL84oJ+0ftcL62Jb0wXmUeCWkfr3Gxh VFdTKthwuT00uAHE4SvHGwXA/o/u20/AHtyqdhBbB4JruDZ2TAyYsqxX+VH60KdnsGRo h0jg== X-Gm-Message-State: AOAM531wh1fQTROCWy8f9GsnzM9xEDItQ+rlIl3oPYpOZQ3suSYhqDPW naajJCM3Ak8NjyQhcNDcwF07vw52HPS39lQtX1UYwg== X-Google-Smtp-Source: ABdhPJymxAJWqwBnUdup+hN8zHGr6Ar4GjhvxJInxM3dkRrFARGBivPvUPWt8CZqxM+Ty4+UTbt++dw3MDraOFOq33c= X-Received: by 2002:a67:d84:: with SMTP id 126mr3398875vsn.51.1602123696606; Wed, 07 Oct 2020 19:21:36 -0700 (PDT) MIME-Version: 1.0 References: <20200908151306.GU6642@arm.com> In-Reply-To: <20200908151306.GU6642@arm.com> From: Peter Collingbourne Date: Wed, 7 Oct 2020 19:21:25 -0700 Message-ID: Subject: Re: [PATCH v10 4/7] signal: define the SA_UNSUPPORTED bit in sa_flags To: Dave Martin X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201007_222139_132467_F64D7AD4 X-CRM114-Status: GOOD ( 34.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linux ARM , Parisc List , Catalin Marinas , Kevin Brodsky , Oleg Nesterov , "James E.J. Bottomley" , Kostya Serebryany , "Eric W. Biederman" , Andrey Konovalov , David Spickett , Vincenzo Frascino , Will Deacon , Evgenii Stepanov , Richard Henderson Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Sep 8, 2020 at 8:13 AM Dave Martin wrote: > > On Fri, Aug 21, 2020 at 10:10:14PM -0700, Peter Collingbourne wrote: > > Nit: no statement of the chage being made (other than in the subject > line). Will fix. > > This bit will never be supported in the uapi. The purpose of this flag > > bit is to allow userspace to distinguish an old kernel that does not > > clear unknown sa_flags bits from a kernel that supports every flag bit. > > > > In other words, if userspace finds that this bit remains set in > > oldact.sa_flags, it means that the kernel cannot be trusted to have > > cleared unknown flag bits from sa_flags, so no assumptions about flag > > bit support can be made. > > This isn't quite right? After a single sigaction() call, oact will > contain the sa_flags for the previously registered handler. So a > second sigaction() call would be needed to find out the newly effective > sa_flags. You're right, this is unclear to say the least. In v11 I will reword like so: In other words, if userspace does something like: act.sa_flags |= SA_UNSUPPORTED; sigaction(SIGSEGV, &act, 0); sigaction(SIGSEGV, 0, &oldact); and finds that SA_UNSUPPORTED remains set in oldact.sa_flags, it means that the kernel cannot be trusted to have cleared unknown flag bits from sa_flags, so no assumptions about flag bit support can be made. > > > > Signed-off-by: Peter Collingbourne > > --- > > View this change in Gerrit: https://linux-review.googlesource.com/q/Ic2501ad150a3a79c1cf27fb8c99be342e9dffbcb > > > > include/uapi/asm-generic/signal-defs.h | 7 +++++++ > > kernel/signal.c | 6 ++++++ > > 2 files changed, 13 insertions(+) > > > > diff --git a/include/uapi/asm-generic/signal-defs.h b/include/uapi/asm-generic/signal-defs.h > > index 319628058a53..e853cbe8722d 100644 > > --- a/include/uapi/asm-generic/signal-defs.h > > +++ b/include/uapi/asm-generic/signal-defs.h > > @@ -14,6 +14,12 @@ > > * SA_RESTART flag to get restarting signals (which were the default long ago) > > * SA_NODEFER prevents the current signal from being masked in the handler. > > * SA_RESETHAND clears the handler when the signal is delivered. > > + * SA_UNSUPPORTED is a flag bit that will never be supported. Kernels from > > + * before the introduction of SA_UNSUPPORTED did not clear unknown bits from > > + * sa_flags when read using the oldact argument to sigaction and rt_sigaction, > > + * so this bit allows flag bit support to be detected from userspace while > > + * allowing an old kernel to be distinguished from a kernel that supports every > > + * flag bit. > > * > > * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single > > * Unix names RESETHAND and NODEFER respectively. > > @@ -42,6 +48,7 @@ > > #ifndef SA_RESETHAND > > #define SA_RESETHAND 0x80000000 > > #endif > > +#define SA_UNSUPPORTED 0x00000400 > > I guess people may debate which bit is chosen, but your consolidation > of these definitions should help to reduce the possibility of future > collisions. This bit appears unused for now, so I guess I don't have a > strong opinion. > > > #define SA_NOMASK SA_NODEFER > > #define SA_ONESHOT SA_RESETHAND > > diff --git a/kernel/signal.c b/kernel/signal.c > > index f802c82c7bcc..c80e70bde11d 100644 > > --- a/kernel/signal.c > > +++ b/kernel/signal.c > > @@ -3984,6 +3984,12 @@ int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) > > if (oact) > > *oact = *k; > > > > + /* > > + * Make sure that we never accidentally claim to support SA_UNSUPPORTED, > > + * e.g. by having an architecture use the bit in their uapi. > > + */ > > + BUILD_BUG_ON(UAPI_SA_FLAGS & SA_UNSUPPORTED); > > + > > Seems reasonable. > > With the above rewording in the commit message to clarify that a second > sigaction() is needed: > > Reviewed-by: Dave Martin Thanks for the review. Peter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel