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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham 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 0A1A1C433E1 for ; Tue, 18 Aug 2020 03:34:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1BCD2053B for ; Tue, 18 Aug 2020 03:34:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pqd8wYji" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726583AbgHRDeX (ORCPT ); Mon, 17 Aug 2020 23:34:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726429AbgHRDeR (ORCPT ); Mon, 17 Aug 2020 23:34:17 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BE2FC061342 for ; Mon, 17 Aug 2020 20:34:16 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id x10so20442865ybj.19 for ; Mon, 17 Aug 2020 20:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=C50/vuMgqcrA+1VnnzXbJiGS1cNeYwcSIDfO7/hcWOU=; b=pqd8wYjiXwYWoRIaID0SosAHj16lSJz/ifWBqNsr2xgMKXXHOVE7Ap/UWvfXQniwA1 0dtZDa3DobHBdB3i0hDSbaypKY4LELbRfjsd3dgmC9qNy8rcEH101KqlKS0T+f9e3gT0 BE6FysjxV/pyjEhGnNjzxai6RJCVgjFAAGEMUcNJ3WU7zVFv2rmOfP6vKiZbNIafgICv 17evJflcuKHCWtXG/8q/X/I6fnTExz7+a+EI3lzMjx7jDBoHS+Rvi0rs+DeFSqx6aQ6R aS/eMV/PYT6fnYm+azIra+Ra68MixB4XQyppLElhff46hy0xvn+wWBuGzcg8+O6wXRIl a9OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=C50/vuMgqcrA+1VnnzXbJiGS1cNeYwcSIDfO7/hcWOU=; b=cHDv4+jDjM00PN6GzOAoD9hIIpDhCTpXrq3D0ONnmDyfYONNdz3Mn2Vef0RHD440H9 z6E2HDokBFsmYsuqwKSdZeg9iCBwYa4i7sAUVrIQofFvCQbaa3LaUAbtT9JG0lxn9bW6 J1NtZ/6+3dlFzQnuWUGAHceKBGNxVaGGuhbZv0PJSWJGNNnsjUJ+ssagNgrsRZh8O0p8 yQPdpRcw9rN4kqoEXCejA9ICSrwsD7n9h3RqsNR8S+Q5VkyndftPbsqa0Ds1cxYscT0w KAgOav+/hmv36f3JIWGG38j0tVEezPm2fL2FFuB0dRDanK69Wl5JNnU0yaE3ZR2heZKp ZnYw== X-Gm-Message-State: AOAM533k1OAHc/Y4YAe9wtkxRq2Z+NMNXCvwG4v3OwENeF804YBmRaC+ uaDhNR/CEzqtEnFp4rZrArwfsZI= X-Google-Smtp-Source: ABdhPJxwQRwAMWNrUOuKqNkI5joprptUVjSLR1d42JMj7BJy46pPo5IKuHr0ukBzS7a6VQiFGT5HBso= X-Received: by 2002:a25:400e:: with SMTP id n14mr26327126yba.420.1597721654941; Mon, 17 Aug 2020 20:34:14 -0700 (PDT) Date: Mon, 17 Aug 2020 20:33:49 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [PATCH v9 4/6] 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" Cc: Peter Collingbourne , Linux ARM , Kevin Brodsky , Andrey Konovalov , Richard Henderson , linux-parisc@vger.kernel.org, David Spickett Content-Type: text/plain; charset="UTF-8" Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.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 --- 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 91000b6b97e0..c30a9c1a77b2 100644 --- a/include/uapi/asm-generic/signal-defs.h +++ b/include/uapi/asm-generic/signal-defs.h @@ -13,6 +13,12 @@ * SA_RESETHAND clears the handler when the signal is delivered. * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. * SA_NODEFER prevents the current signal from being masked in the handler. + * 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 @@ * The following bits are used in architecture-specific SA_* definitions and * should be avoided for new generic flags: 3, 4, 5, 6, 7, 8, 9, 16, 24, 25, 26. */ +#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 348b7981f1ff..664a6c31137e 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(SA_UAPI_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 -- 2.28.0.220.ged08abb693-goog 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=-12.7 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,USER_AGENT_GIT 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 CAE53C433E4 for ; Tue, 18 Aug 2020 03:35:55 +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 9E29D2053B for ; Tue, 18 Aug 2020 03:35:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0vOPdsHN"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="pqd8wYji" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E29D2053B 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: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=125gKwDlsjZRu9cNp4HGTElBPTjdRIg1zdFRhL9EESo=; b=0vOPdsHNJHzYDsinBtVi2ap0S J22DyhVBIvGYRtmQLy1PHK+U2mwg/014E3/JcqLF4YDpk1PbsMVGr4X8vcubRt+WXU2WyVRpECj3C SQDDgiMORlhEz9US55CRqwpeAwYM1uC/OQRm6gcs8VcYvHjXZC5I7Aw69NEp5L/q3yL7EZesJwGTg 5TBS8BqHmc9P2Vc51bWzEsG0y4OmnwddV/mJzd7g7nD1gL3hjiRAgqMDYhIxbEs2E3lJ43y/qaBw9 cwcEo1ByN9PCaCLIigwV7sfDTgiW4G4gq3EUcxAy4bAZ0QM9LYRsCHEvsZqRbM2IcEo0L3qY1s6pQ E5UCzXrsw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k7sOJ-0002W6-Kg; Tue, 18 Aug 2020 03:34:27 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k7sO9-0002RS-Rw for linux-arm-kernel@lists.infradead.org; Tue, 18 Aug 2020 03:34:19 +0000 Received: by mail-yb1-xb49.google.com with SMTP id d26so20758876yba.20 for ; Mon, 17 Aug 2020 20:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=C50/vuMgqcrA+1VnnzXbJiGS1cNeYwcSIDfO7/hcWOU=; b=pqd8wYjiXwYWoRIaID0SosAHj16lSJz/ifWBqNsr2xgMKXXHOVE7Ap/UWvfXQniwA1 0dtZDa3DobHBdB3i0hDSbaypKY4LELbRfjsd3dgmC9qNy8rcEH101KqlKS0T+f9e3gT0 BE6FysjxV/pyjEhGnNjzxai6RJCVgjFAAGEMUcNJ3WU7zVFv2rmOfP6vKiZbNIafgICv 17evJflcuKHCWtXG/8q/X/I6fnTExz7+a+EI3lzMjx7jDBoHS+Rvi0rs+DeFSqx6aQ6R aS/eMV/PYT6fnYm+azIra+Ra68MixB4XQyppLElhff46hy0xvn+wWBuGzcg8+O6wXRIl a9OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=C50/vuMgqcrA+1VnnzXbJiGS1cNeYwcSIDfO7/hcWOU=; b=auUMMTmi2HkjSJOVEZOiyuhY4IHCC6E9Ykx9rCltaWVb7w3k/Vr8Iv+tCNZf1scnvr RgrozC27Fn2WNIxGzpNmDfzvxC0Mp2O9epVXgu6eCatTChR/F7fMtGZmJ8hHe82EZMhD LnmROft6nGFY+gJhhVIpGt1Mk1sQYNUelohkmfHr6g6BJ6iXBT1EtFfitZGDqvj1Kfno hXl2pqw6N+5cYZ7aWXh5KsTZCHDK3atGA3bi6JmS536EKv+qfVoyzbGoUZ79iqvnJ75T mryaYe+hfvxj/BSSal9pRZ1SEjtxfw85nuZ+srlGeo/XCtoA0CeMzzSTL+GSihs+/aRQ xKhA== X-Gm-Message-State: AOAM532szTR6NUpWKz8XM/9Ujtiw2I4eMOoMJNT9Z1YEQrXyTL5lDdSB 9JUoE5deBBMrEuF3ZTBSkibOxDM= X-Google-Smtp-Source: ABdhPJxwQRwAMWNrUOuKqNkI5joprptUVjSLR1d42JMj7BJy46pPo5IKuHr0ukBzS7a6VQiFGT5HBso= X-Received: by 2002:a25:400e:: with SMTP id n14mr26327126yba.420.1597721654941; Mon, 17 Aug 2020 20:34:14 -0700 (PDT) Date: Mon, 17 Aug 2020 20:33:49 -0700 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [PATCH v9 4/6] 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-20200817_233417_973327_21726C2E X-CRM114-Status: GOOD ( 17.30 ) 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 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 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 --- 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 91000b6b97e0..c30a9c1a77b2 100644 --- a/include/uapi/asm-generic/signal-defs.h +++ b/include/uapi/asm-generic/signal-defs.h @@ -13,6 +13,12 @@ * SA_RESETHAND clears the handler when the signal is delivered. * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. * SA_NODEFER prevents the current signal from being masked in the handler. + * 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 @@ * The following bits are used in architecture-specific SA_* definitions and * should be avoided for new generic flags: 3, 4, 5, 6, 7, 8, 9, 16, 24, 25, 26. */ +#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 348b7981f1ff..664a6c31137e 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(SA_UAPI_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 -- 2.28.0.220.ged08abb693-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel