Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6178334imu; Wed, 30 Jan 2019 10:06:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN6xXUF5LhMHnfkd3/lCV2HjX9yq/SD01wU4PoBwxTHWAS9LXUst+0zd2Fb2v7JHuaFPGQET X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr31786487plo.50.1548871563684; Wed, 30 Jan 2019 10:06:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548871563; cv=none; d=google.com; s=arc-20160816; b=Mj+fzAW/3HYARYg+Kb4mwDOEJXvN8Mf0bcUm8tEojBKX8VGmZcHn5sC9jUOj4+i3bv vW5vRurOM9oWhpn+lqBcTqKurpGHmwBmCom/3NLF8sNB/mifLPvnTbyQZj5sWCcx8qmJ 2eFIEjF5HwooNX8LPhKCbGX0WfYqDuJhA4G18/5+vs1Jhi6Z2cWrw27mydvlslvpCW8E fgBJe26XbRyT+2N+5BkQmzFIc6m/vVqP+BRdDFYHeiLM4/P/V1yq+6D1q/3E6o1GD0rN VaibzIHqvYV3kVc24LlBMt5NJYHoZiKLGYDcF6FDzlQRy7DJrtqaeCFFGwDd/YzT03Ar RlGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=uUsDbd1WHpkZTr21/ymIBW3iMqvtmfAknPUj3BifJAQ=; b=D5Q0TrRJ8qsxFf32BIrgTEl0qDplOsClXTvVg5sstef1Xxa+I0gVpXfp9TjzGii+Yb +kRUqCvK8nHpP1Rqai5BqvvIkP7kDsM+rLuI2a+gTmNXOxCqwZoKt0JOvgWZZJGS8dyx WHhWwxjP6mWLuEqaWkjMdd66hpn2EA4CCDf2XS2NQrtkpZZ33HjDPsSLCrzYrO4Qhi8T 0wig2uBut7YWmBkaQbzmn3lScenLjoRrdxNo261XDdYZONThvTwCMx3EoclMCLD/Xtni tWUGA0CI6Y7yMvCvZN6tBc9eSUa5rV3FbxNeS0iZirsxAwh8nXJ1CXAXXU009FUoOSwM kJUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=K2lPJ3cv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 43si2058627plb.176.2019.01.30.10.05.48; Wed, 30 Jan 2019 10:06:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=K2lPJ3cv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732340AbfA3SDu (ORCPT + 99 others); Wed, 30 Jan 2019 13:03:50 -0500 Received: from mail.efficios.com ([167.114.142.138]:55452 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725535AbfA3SDt (ORCPT ); Wed, 30 Jan 2019 13:03:49 -0500 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 03DFC9E4A4; Wed, 30 Jan 2019 13:03:48 -0500 (EST) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id QuW9I1GAiEOH; Wed, 30 Jan 2019 13:03:47 -0500 (EST) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 30D8A9E49E; Wed, 30 Jan 2019 13:03:47 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 30D8A9E49E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1548871427; bh=uUsDbd1WHpkZTr21/ymIBW3iMqvtmfAknPUj3BifJAQ=; h=Date:From:To:Message-ID:MIME-Version; b=K2lPJ3cveLqkqF04BGQuRHsc8BL2nTHLLALg0/SocG6ldirCl5P7XsiW/zlel2PGf JlBobwjS8cnLS3CMM5Jr4rE9S5fsFkAkXUGvKOXAnUitXuuVUBCPiVAvs1H0N2Kt5o hgwhMFj7hHy5twiNpOoiWJwTrnssersK63GNl5X0HwQMYzZmvktX0v8ADDgydYm/YI KZBfI3HkwfRhiI1XaCt1CHxv87zcl/WqY8gEuwEf3cSJOKIVmh2ztvvgY7XwC5voKJ DssyMyAei26gxetBAqjZCj5JREuGp/JHwWx98dXW3lJfgx5isKVG4kgWvsrFL3BEO3 bae3e7Rn1R5GQ== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id SyIbtafStXY1; Wed, 30 Jan 2019 13:03:47 -0500 (EST) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id 0F86B9E492; Wed, 30 Jan 2019 13:03:47 -0500 (EST) Date: Wed, 30 Jan 2019 13:03:46 -0500 (EST) From: Mathieu Desnoyers To: Joseph Myers Cc: carlos , Florian Weimer , Szabolcs Nagy , libc-alpha , Thomas Gleixner , Ben Maurer , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Will Deacon , Dave Watson , Paul Turner , Rich Felker , linux-kernel , linux-api Message-ID: <1832200535.4162.1548871426959.JavaMail.zimbra@efficios.com> In-Reply-To: References: <20190121213530.23803-1-mathieu.desnoyers@efficios.com> <632671842.3079.1548781059601.JavaMail.zimbra@efficios.com> <596949707.3888.1548812359874.JavaMail.zimbra@efficios.com> Subject: Re: [RFC PATCH glibc 1/4] glibc: Perform rseq(2) registration at C startup and thread creation (v6) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.138] X-Mailer: Zimbra 8.8.10_GA_3716 (ZimbraWebClient - FF65 (Linux)/8.8.10_GA_3745) Thread-Topic: glibc: Perform rseq(2) registration at C startup and thread creation (v6) Thread-Index: sulJ8M5QtxdcyhSLifF52HPUsS3biA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Jan 29, 2019, at 9:40 PM, Joseph Myers joseph@codesourcery.com wrote: > On Tue, 29 Jan 2019, Mathieu Desnoyers wrote: > >> My thinking was to put the #error in the generic header, so architectures that >> are not supported yet cannot build against rseq.h at all, so we don't end up >> in a broken upgrade scenario. I'm open to alternative ways to do it though, as >> long as we don't let not-yet-supported architectures build broken code. > > Any case with #error in installed glibc headers needs special-casing in > check-installed-headers.sh (and, thus, such errors are to be discouraged). One alternative to #error would be to have an empty generic bits/rseq.h that does _not_ define RSEQ_SIG. This way, it would be possible to include sys/rseq.h from an architecture that does not define RSEQ_SIG yet, but it would not cause any build failure. It's only if the code try to use RSEQ_SIG that it would fail to compile because undefined. > Cases where architectures commonly need their own bits/ headers, > especially where those are likely to need updating for new kernel > versions, are also discouraged. The per-arch bits/rseq.h headers, once they define a specific value for RSEQ_SIG, should never ever change that value. > Furthermore, a normal check for glibc > headers updates needed for a new kernel version would only involve > examining uapi headers (and the non-uapi linux/socket.h for new address > families, an unfortunate existing wart in this area). As far as I can > see, this value isn't defined in any uapi header, which makes it > especially likely to be missed in such a check. Furthermore, I'm hoping > to add more glibc tests for consistency of such constants between glibc > and the kernel, to ensure any such updates missing are caught > automatically through test failures - but that doesn't work if the > constants in question aren't in a uapi header. > > If this constant were in a uapi header, the glibc header could just > include that - is the issue that it's not actually an interface between > glibc and the kernel at all, but some kind of purely-userspace interface? The rseq uapi headers do not enforce the value of RSEQ_SIG. The role of the kernel wrt signature is to receive it as sys_rseq argument, and then validate that abort targets are prefixed with the signature before moving the instruction pointer there. Therefore, it's up to user-space to agree on the RSEQ_SIG value across all code using rseq within a process. Since glibc will be registering rseq and exposing public headers, it appears that glibc would be the appropriate project to define the RSEQ_SIG value for each architecture. > > We very definitely wish to keep to a minimum the cases where updates need > to be done separately in glibc by each architecture maintainer (that's > just a recipe for some updates getting missed accidentally) - meaning that > there needs to be a clear way in which someone can tell, globally for all > architectures, whether the set of such architecture-specific headers for > this constant in glibc is complete and current, and when it needs updating > (and this should be as similar to possible to such checks for any other > header constant). Currently, I use #ifdef __NR_rseq from uapi unistd.h to check whether the kernel headers implement the rseq system call for the target architecture. With the approach of having an empty bits/rseq.h for architecture not yet supporting rseq in glibc, one way to check that glibc implements RSEQ_SIG for all architectures that have the rseq system call wired up in uapi would be: #include #include #if defined (__NR_rseq) && !defined (RSEQ_SIG) # error "UAPI headers support rseq system call, but glibc does not define RSEQ_SIG." #endif Would that take care of your concerns ? Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com