Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp297093pxb; Wed, 3 Feb 2021 06:00:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJy10OJ66GuL7Cmf2nw2zPyhAdqVusEyPFifxx0F3IuB3ie+ug3bOm4PEOXlbIWfzmrkhhP/ X-Received: by 2002:a19:c56:: with SMTP id 83mr1936144lfm.325.1612360854644; Wed, 03 Feb 2021 06:00:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612360854; cv=none; d=google.com; s=arc-20160816; b=cjyKr37/VhIyG1pYT9SmZb9XXMr9FdGG6OrTBAeNBtn4zcUqb/BOtBvNMw5fz0lU4h 01yEjVYIyUCMN/q9dB/sPGmXTk4yc/vfjDqqthDFAl/UKWihjM/Sl1q3QKQ7lQoIVihv U5WcbMRJezu+pJaxleO0zkPLqeLl4LBTdAAquL15ieJeNJsa39xIaROU9W47QCefIm3C n5VwqNI8vn4ZBdHhouJTICjinTn+pcUxZDsJWDe4Qymjvvf5oBySpR2ffahT9dBF2JG8 TSZOp7oRnFRybxO24asAXe+ajIwV5p/tkfy4089Ru0ZgFmfMWjkL7AbAfs66aJnPMTdo xUHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=7jcKuKJSg8pciK4+g71J2hYJ9Bmr1dnzsU3M2uRFs70=; b=jZqxSJFanKwlXCBkjHOdyFUvAz9nVK+MHLcQxDn/4fiMHLc/7BS527HxuZQvENXGOW oY69SWLDb6QFCMM534JoiMN1xDYppw3t7CWlp+SCQ5/t1/0W4obhZJsJxwRLOv1O9kJT fyF+MKzfLPCy/Tr/8lNLeGrp8k37rn513NOUmxI9GfkcAexcD68Cd5NepmckO3SqthoX xQQzqh+WweKzBZ32q8FXDqMDLOXBSmLzR+08uQwFsl3M3VM3vTZHjzfdvBnMEvOn/saw 5R324ruvLqWO9s/kCd1Yd66znfGo0TwdIrr1sB5qfGrsXojwUZ6jgngUCNp0O5n7R1Sk zzQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si1410382edd.237.2021.02.03.06.00.26; Wed, 03 Feb 2021 06:00:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232207AbhBCN7V (ORCPT + 99 others); Wed, 3 Feb 2021 08:59:21 -0500 Received: from foss.arm.com ([217.140.110.172]:40636 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231869AbhBCN7Q (ORCPT ); Wed, 3 Feb 2021 08:59:16 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8148F13D5; Wed, 3 Feb 2021 05:58:29 -0800 (PST) Received: from C02TD0UTHF1T.local (unknown [10.57.11.206]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A40443F73B; Wed, 3 Feb 2021 05:58:25 -0800 (PST) Date: Wed, 3 Feb 2021 13:58:22 +0000 From: Mark Rutland To: Josh Poimboeuf Cc: Nick Desaulniers , Julien Thierry , Ard Biesheuvel , Mark Brown , Catalin Marinas , Kees Cook , Linux ARM , linux-efi , linux-hardening@vger.kernel.org, LKML , Masahiro Yamada , Michal Marek , Peter Zijlstra , raphael.gault@arm.com, Will Deacon , clang-built-linux , Bill Wendling , swine@google.com, yonghyun@google.com Subject: Re: [RFC PATCH 12/17] gcc-plugins: objtool: Add plugin to detect switch table on arm64 Message-ID: <20210203135822.GN55896@C02TD0UTHF1T.local> References: <20210120173800.1660730-13-jthierry@redhat.com> <20210127221557.1119744-1-ndesaulniers@google.com> <20210127232651.rj3mo7c2oqh4ytsr@treble> <20210201214423.dhsma73k7ccscovm@treble> <671f1aa9-975e-1bda-6768-259adbdc24c8@redhat.com> <20210203001414.idjrcrki7wmhndre@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210203001414.idjrcrki7wmhndre@treble> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 02, 2021 at 06:14:14PM -0600, Josh Poimboeuf wrote: > On Tue, Feb 02, 2021 at 03:01:22PM -0800, Nick Desaulniers wrote: > > > >> Thus far we've been able to successfully reverse engineer it on x86, > > > >> though it hasn't been easy. > > > >> > > > >> There were some particulars for arm64 which made doing so impossible. > > > >> (I don't remember the details.) > > > > > > The main issue is that the tables for arm64 have more indirection than x86. > > > > I wonder if PAC or BTI also make this slightly more complex? PAC at > > least has implications for unwinders, IIUC. > > What is PAC/BTI? PAC is "Pointer Authentication Codes". The gist is that we munge some bits in pointers when they get stored in memory (called "signing"), and undo that with a check (called "authentication") when reading from memory, in order to detect unexpected modification. There's some new instructions that may exist in function prologues and epilogues, etc. There's a basic introduction at: https://events.static.linuxfound.org/sites/events/files/slides/slides_23.pdf https://www.kernel.org/doc/html/latest/arm64/pointer-authentication.html Return address signing/authentication uses the SP as an input, so without knowing the SP something was signed against it's not possible to alter it reliably (or to check it). The arm64 unwinder ignores the PAC bits, and ftrace uses patchable-function-entry so that we don't have to do anything special to manipulate the return address. Today the ABI used by the kernel doesn't mess with the pointers used in jump tables, but that may come in future as toolchain folk are working to define an ABI that might. BTI is "Branch Target Identification", which is a bit like CET's indirect branch tracking -- indirect branches need to land on a specific instruction, or they'll raise an exception. Thanks, Mark.