Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5146914yba; Wed, 10 Apr 2019 12:23:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxz77GSjrgitVMZAoTRgJMW0ZcTJabLZbyI8EgBfnr3c2HlMOwtygZDmIO3KPSN7OlecXcN X-Received: by 2002:a65:44cd:: with SMTP id g13mr36293042pgs.258.1554924207750; Wed, 10 Apr 2019 12:23:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554924207; cv=none; d=google.com; s=arc-20160816; b=I+bt2CNK3i+ab6sjAtVdi2WnXnhakztt+MOGmdK820J1lbg61oYshglZsn8BRu8KbF HTApKMmBlvlcowPQTykiltC/K2/d0z5qpU/fh8QB41xtseOyJ+t+G3Jw0mIiynKoIw27 sGpa1NPzHnMp6J0w4ZJ1Aq2gWLNFUJA3stFzmIlO4x9kK8rbbRDl+Y4U3KXw+ZsBzwZf eJUujXvltJeQ84NMTIsnLTGlvuRBAQhZ07aWtQbcvlrvUZxmbQBkRhRkIPEaiCLgGv78 tYPJpJdXT+LSFX9C4RfanZoq2KlFvu7RT/A8QO/wNxOYETM0ylTiJ46s+IKyHdSqELK1 asZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=aOfrBofw/0QJ/2jPcHKrqREkEIvcRBqkblnnWA45Bjc=; b=iCowK+k+Xm+z1QS/BecZj7Xt6ii3xQ6KejkIyHloSV278g7VPGrV2PV9NIg9CN+3FK N+d3lgWFx8zr46V3kR9wvi99RU+aRE/wsFhyadOoklR28coueS+fQPoHa92iBZZKTMAI bt2VVXFD6D8BbEbmLrfJ8I1EZLXN5FGmY7JaX2S24c7IRmz2QV6a3D4S1iE63QU39Ujm c6npb2SLyTMvR1K2l+HGb3xMUT0irQ78jt69yzpqvAYL9fhB4b7rRKEPT9aOZ212w3CA bqXPw0vtbFw6Mu2sZkguIo1JzeVi721uk4MqdnmxHDJ96FDNcvFohmZ4sZfERK41LYC9 6MJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=CDthoel5; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 140si32120565pga.460.2019.04.10.12.23.08; Wed, 10 Apr 2019 12:23:27 -0700 (PDT) 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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=CDthoel5; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730935AbfDJR50 (ORCPT + 99 others); Wed, 10 Apr 2019 13:57:26 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:44484 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730819AbfDJR50 (ORCPT ); Wed, 10 Apr 2019 13:57:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=aOfrBofw/0QJ/2jPcHKrqREkEIvcRBqkblnnWA45Bjc=; b=CDthoel5H8xYFyZbgdeOb41Rt KYOJhdNpVJ+CjDx9Uv0Exg+8vtWzK4L02uEXpILNqPd7f9I9ERHoWnyQGloKXP/s/CsUFqD7QBffY pcyVMxFzLIqmdz62w4OlAUEmyGpk9UYBJ0TCNQNkSaFOtIEldg8KyrMw1arLxDq2DtfaiO+QIGYWn V/OGej49KPIV+Cq3WGoBUxUL31Y1I6HRS4xWWiP/hbS8n1CekedeI7H3yNYFsmVokh+nyxkcFA4cN U9T31GCiAOs/c09eQMaKfHowHgTkn3ZMM5f8V858BORrUopYG1F0QnKS9B/BnM7KfsUGIdB/+9gus Kxdn+oP0Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEHTD-0004oB-Se; Wed, 10 Apr 2019 17:57:12 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0657B2029FA03; Wed, 10 Apr 2019 19:57:10 +0200 (CEST) Date: Wed, 10 Apr 2019 19:57:09 +0200 From: Peter Zijlstra To: Mathieu Desnoyers Cc: Thomas Gleixner , Andy Lutomirski , "H. Peter Anvin" , Andi Kleen , Ingo Molnar , Borislav Petkov , libc-alpha , linux-kernel , carlos , x86 Subject: Re: rseq/x86: choosing rseq code signature Message-ID: <20190410175709.GW4038@hirez.programming.kicks-ass.net> References: <11513896.2624.1554838336494.JavaMail.zimbra@efficios.com> <913288111.2663.1554842622822.JavaMail.zimbra@efficios.com> <20190410065417.GU11158@hirez.programming.kicks-ass.net> <608558890.3157.1554911260089.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <608558890.3157.1554911260089.JavaMail.zimbra@efficios.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 10, 2019 at 11:47:40AM -0400, Mathieu Desnoyers wrote: > ----- On Apr 10, 2019, at 2:54 AM, Peter Zijlstra peterz@infradead.org wrote: > > > On Tue, Apr 09, 2019 at 04:43:42PM -0400, Mathieu Desnoyers wrote: > >> +/* > >> + * RSEQ_SIG is used with the following privileged instructions, which trap in > >> user-space: > >> + * x86-32: 0f 01 3d 53 30 05 53 invlpg 0x53053053 > >> + * x86-64: 0f 01 3d 53 30 05 53 invlpg 0x53053053(%rip) > >> + */ > > > > Right, and the alternative is: 0f b9 3d $SIG, which decodes to: > > > > UD1 $SIG(%rip),%edi > > > > which will trap unconditionally. The only problem is that gas will not > > actually assemble it, but since we're .byte coding it, it doesn't > > matter. > > > > UD1 is specified by both AMD and Intel to take a ModR/M, unlike UD0 > > where they disagree on the ModR/M. > > UD1 is even better from a code emulator perspective. It won't have to > try to emulate invlpg if it sees it. Some emulators terminate on UD2, not aware of any special UD1 behaviour. > Byte coding UD1 as your example above gives the following objdump output, > is it expected ? > > objdump --version > GNU objdump (GNU Binutils for Debian) 2.28 > > x86-32: > > 14: 0f b9 ud1 > 16: 3d 53 30 05 53 cmp $0x53053053,%eax > > x86-64: > > b: 0f b9 ud1 > d: 3d 53 30 05 53 cmp $0x53053053,%eax GNU objdump (GNU Binutils for Debian) 2.31.1 0f b9 3d 78 56 34 12 ud1 0x12345678(%rip),%edi So I suppose your objdump is too old :/