From patchwork Sat Aug 22 05:10:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 11730919 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E41A416B1 for ; Sat, 22 Aug 2020 05:12:26 +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 BCF312072D for ; Sat, 22 Aug 2020 05:12:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="xyZDDtC0"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="UIW9wmXb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BCF312072D 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+patchwork-linux-arm=patchwork.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:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8EeeuOq+ymUFqewSa3nVk1oZVVEhWbKh+CFelio4vIM=; b=xyZDDtC0dvsRXekcY3KezpBVB sflyvFmOadMVhQeRi0o0asmYTYYRzmByloelLgn3cBeaQy9k3DJvUtH3PJyebSNrVdHhhrogneJxk sqxuPO/V8pcfbdnxeNj7byRXMDkHVLmFmv3BvnmuTr3h98V3fLMnl4WiD7gYtYPDsSb7MhFfez4pl QBVU5yNHc/nnmVZZ3lJLHp9Mfsj1ikVW1yWT9oYrlGKMmjk6MDvJlZRf/IND+t6amCxFwcK5AoNKA N951yj41CHmgDc6VFmG1s/gAQLXb3KoO1r/aMUEWCIFFvRyMTsY3UDm0TSQB9JYKL/In7iw24MKZQ BhbA8//3g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k9Lnl-0007Wc-GB; Sat, 22 Aug 2020 05:10:49 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k9Lna-0007TY-Kc for linux-arm-kernel@lists.infradead.org; Sat, 22 Aug 2020 05:10:40 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id w17so4328691ybl.9 for ; Fri, 21 Aug 2020 22:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=CzaiCCk/tmQkpna8t+AyN0umynxVPZ5p6jzvAHIDwfM=; b=UIW9wmXbGVYHKhqDEhlWmDGB2IbEOJy2m5Fo34kXuErLfcyHhXUXjI2Y0XI4jCK3Ww 4djx8hkdnRzXAGt8c16ie49T+PLMhahp8BSI77dlPWNYMd7UnoUq6gmigxbDpZHIPL3j FieAez4T06FYbEYgb7+trkkJLLduc7/IkS6W+bfIQza+HUXYnvKPv7SYH75lkN14yAqY zSIOuyovSjCmwnJAtxkwuSbaE6K3cX2V95X5mIP8OLJQGD6WS2ZcqZKINr2xbwD8Y0f8 DNWueg7Fj4gaTQOQXXodTfglaTu55cG2KsBTSVBS1T8MoKLdJzSrFeniS2IetyLxNMtZ PszQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=CzaiCCk/tmQkpna8t+AyN0umynxVPZ5p6jzvAHIDwfM=; b=XGn2LZlFJgH3X/W0yvXX6XTw3sZicFJuxvXJSpGa4crtM5nklARBWl1LpGHtJEGAvM JetHw5vlevRUuzNPdq4CQ9CzSAu0FB9s48g4sDhKMcuaESDPWHNQM+NPn80BEhOko8+Y X+SwFrg3el/9wsDMU//vX0QJs9UFDN0sycfYyMVW9U22qTAmPtd0WmDqCsRvmzfrsTQc PhlvsdJk6n6WORsDilh/HC6RIhyPHLyrEIpAC58Y534bGsVeno7uO8ezhbcHCb0RP2hS bpmdS09pk8ohUOxx+YaWJM5KDgPmSmRhoVxCZ8apC2w3ChIIkOQfRPoiM79CteZN4I0u M04w== X-Gm-Message-State: AOAM531Xp/SD/SsW3hR7tAKnCwzS5631uyaldc9v4OFCPmAMayk2sMJa ID88zYR82LzR7cyrTlYW+3gbpiA= X-Google-Smtp-Source: ABdhPJzaeCeqahBEnR0P2M1+fMOk/d5exsENSGbXZeWp0bdqm2nfSWcG4vji5MvvlfxeI1VJ8DoQadk= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:0:7220:84ff:fe09:385a]) (user=pcc job=sendgmr) by 2002:a25:d946:: with SMTP id q67mr7305852ybg.517.1598073034645; Fri, 21 Aug 2020 22:10:34 -0700 (PDT) Date: Fri, 21 Aug 2020 22:10:14 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog Subject: [PATCH v10 4/7] signal: define the SA_UNSUPPORTED bit in sa_flags From: Peter Collingbourne To: Catalin Marinas , Evgenii Stepanov , Kostya Serebryany , Vincenzo Frascino , Dave Martin , Will Deacon , Oleg Nesterov , "Eric W. Biederman" , "James E.J. Bottomley" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200822_011038_741743_8B80348F X-CRM114-Status: GOOD ( 16.55 ) X-Spam-Score: -7.7 (-------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-7.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:b4a listed in] [list.dnswl.org] -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_MED DKIMwl.org - Medium sender 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-parisc@vger.kernel.org, Andrey Konovalov , Kevin Brodsky , David Spickett , Peter Collingbourne , Linux ARM , Richard Henderson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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. Signed-off-by: Peter Collingbourne Reviewed-by: Dave Martin --- 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 #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); + /* * Clear unknown flag bits in order to allow userspace to detect missing * support for flag bits and to allow the kernel to use non-uapi bits