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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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 A8550C388F9 for ; Mon, 16 Nov 2020 23:50:31 +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 497872464E for ; Mon, 16 Nov 2020 23:50:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="RACkA6V+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 497872464E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=xmission.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:Subject:MIME-Version:Message-ID:In-Reply-To:Date: References:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=X7SdQtsGj68LAeJGBCHktHUTb9E3H7JnYrwnDUYCmdk=; b=RACkA6V+MOj1KLJ/VKiOfkZjO V7YINdcdg3DgvAtvdsFylX43KZEsQ6vHdE+uomTIVOC6CQ9fEGX3oxDRARnu5/YMSRu0ZBKVh9wtS ftkMEZevIYIBmlJQAklWx0XzIzyfUyUOjEJ/z8TMxFZWIexyoSPZQ2dNC5NHJ/C4XYLTlv9MsY45b tQjcHrUaPxS3AABJcj7iXF5BPXHEoqvh6N748NI65tKHyR59ibi76lPS2ddqaDmkXGGEzUYYTO9nG jWWkubjfAWBZDPMGYZXZnL7VMR0MSz1/rr8HeIobV3FJPHPei1zPELI8hhkFcAF2HgVL+TJNwt8/n Sz4LMOAEA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1keoF6-0006VQ-Go; Mon, 16 Nov 2020 23:49:04 +0000 Received: from out02.mta.xmission.com ([166.70.13.232]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1keoF3-0006Ur-TS for linux-arm-kernel@lists.infradead.org; Mon, 16 Nov 2020 23:49:03 +0000 Received: from in02.mta.xmission.com ([166.70.13.52]) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1keoEs-00C4dY-N0; Mon, 16 Nov 2020 16:48:50 -0700 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1keoEg-002h8J-B6; Mon, 16 Nov 2020 16:48:50 -0700 From: ebiederm@xmission.com (Eric W. Biederman) To: Peter Collingbourne References: <3581410892be6851d804bbbb84fccf06073f1262.1605235762.git.pcc@google.com> <878sb4nixz.fsf@x220.int.ebiederm.org> Date: Mon, 16 Nov 2020 17:48:21 -0600 In-Reply-To: (Peter Collingbourne's message of "Sat, 14 Nov 2020 14:12:41 -0800") Message-ID: <87wnykg8xm.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-XM-SPF: eid=1keoEg-002h8J-B6; ; ; mid=<87wnykg8xm.fsf@x220.int.ebiederm.org>; ; ; hst=in02.mta.xmission.com; ; ; ip=68.227.160.95; ; ; frm=ebiederm@xmission.com; ; ; spf=neutral X-XM-AID: U2FsdGVkX19xm/VQ0i8x06zvcrtDi6ZNWVyMQu46CXs= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH v16 5/6] signal: define the SA_UNSUPPORTED bit in sa_flags X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201116_184902_031898_EAB3C7F6 X-CRM114-Status: GOOD ( 33.00 ) 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: Catalin Marinas , Helge Deller , Kevin Brodsky , Oleg Nesterov , Linux API , "James E.J. Bottomley" , Kostya Serebryany , Linux ARM , Andrey Konovalov , David Spickett , Vincenzo Frascino , Will Deacon , Dave Martin , Evgenii Stepanov 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 Peter Collingbourne writes: > On Sat, Nov 14, 2020 at 5:53 AM Eric W. Biederman wrote: >> >> Peter Collingbourne writes: >> >> > Define a sa_flags bit, SA_UNSUPPORTED, which 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 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 >> > Reviewed-by: Dave Martin >> > Link: https://linux-review.googlesource.com/id/Ic2501ad150a3a79c1cf27fb8c99be342e9dffbcb >> > --- >> > v11: >> > - clarify the commit message >> > >> > 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 493953fe319b..0126ebda4d31 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 >> >> Why this value and why not in numerical order with the other flags? >> >> At the very least not being in order with the other bits makes it >> a little easier to overlook it and define something at that position. > > The value is because this is the first bit that isn't already taken by > an architecture-specific flag bit. It seems okay to move it into > numerical order. > > The taken flag bits are listed in the comment that I added in patch 3. > Do you think there would be a more prominent way to document them? > Maybe we can replace that comment with inline, in-order comments along > the lines of: > > #ifndef SA_NOCLDSTOP > #define SA_NOCLDSTOP 0x00000001 > #endif > #ifndef SA_NOCLDWAIT > #define SA_NOCLDWAIT 0x00000002 > #endif > #ifndef SA_SIGINFO > #define SA_SIGINFO 0x00000004 > #endif > /* 0x00000008 has arch-specific definition */ > /* 0x00000010 has arch-specific definition */ > > etc. > > And then this patch would add the new bit in the right place. Yes. That seems like it would be easier to think about. If you could also add the architectures that use those bits that would be helpful. Then if someone wants to look and see what is going on they need to look, and as a bunus in the if in event those architectures are deleted we would know that the bit no longer need to be reserved. Eric p.s. Apologies for some reason I did not see this reply earlier. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel