Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp598011ybt; Wed, 24 Jun 2020 06:50:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWo75Ra8WcCn2LrpV8w5bFEAx5sZDvHxRkWZR3BbGVwxQwqhYnLf0tU+8UCU2AcdoB3PTA X-Received: by 2002:a17:906:455:: with SMTP id e21mr14440862eja.550.1593006626778; Wed, 24 Jun 2020 06:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593006626; cv=none; d=google.com; s=arc-20160816; b=e42/d6UgawHJLAQKhIrceFaSmH0GHcMiRCahYdC4PCz00WO4yWWHTZFgsl636OLufh 67sUVhhvAp1QT5k6rw8u2LWsZfcZaeNAQoQhvzu+J66Knaw1pri/NTTzGegm/DYT1QVf E2XU9l99wpiAp5qXZj/khD19xZOgXcATq1qtp+8j43xnkYgvlVXEfda2MrwO37TmmXpI yOl1DtO6nOqGnqD3NUJGZ6ZaFy6B5JRjTh6EmpkYVrI69sfnhmg6kqOoTv9PJYfeEu7y 5k/UGrpLFQ+Jwi13B4uwhUERE0hamcSO34o5tzX6dC/lQmb3zGQ4vqBrUxsUZ+IP9fgT omew== 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; bh=QJl0ICDfUrXmXoP6VK70zTy+gh2G1ZiyLGrAGyJ7tH0=; b=Ouhg9KwOfmqOvZzG2OEmAyY5iaO6CuIOOlnaRCAO39RSY1cEi3QihRrmP5ik+y6B5J UMa2175iGdk/o3inEItrf2qzKLAH5p8fb85jelHzuKgV9Cjj/IXolx6eojs965Tr6Vq9 1jzdmVt+Qbelhaj3fvqs7/HR0+kcQ6Kaz9Y+8K/BF0mimzoiBrAwyPYxWjuwzBM2BbbR pqaHQ2RfUPSbM1h4f5Qt9H2SE2foe1PGFqsIn9vTuqm3rSLv07I4K8wDZONe1AUvSZZf dHpxx5AV079gCq6sqkX/uBxANZSvCnlkefZuHIZ8bJdSyI1tgLlMhY9UD4JZYZ0JYZKA FzJQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u29si4377832edi.469.2020.06.24.06.49.59; Wed, 24 Jun 2020 06:50:26 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391073AbgFXNtB (ORCPT + 99 others); Wed, 24 Jun 2020 09:49:01 -0400 Received: from foss.arm.com ([217.140.110.172]:51856 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389590AbgFXNtB (ORCPT ); Wed, 24 Jun 2020 09:49:01 -0400 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 2F21631B; Wed, 24 Jun 2020 06:49:00 -0700 (PDT) Received: from arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6E3913F6CF; Wed, 24 Jun 2020 06:48:57 -0700 (PDT) Date: Wed, 24 Jun 2020 14:48:55 +0100 From: Dave Martin To: Will Deacon Cc: Ard Biesheuvel , Mark Rutland , linux-arch , linux-efi , Kees Cook , Fangrui Song , Catalin Marinas , Masahiro Yamada , X86 ML , Nick Desaulniers , Russell King , Linux Kernel Mailing List , clang-built-linux , Arvind Sankar , Ingo Molnar , James Morse , Linux ARM , Thomas Gleixner , Borislav Petkov , Peter Collingbourne , Nathan Chancellor , Arnd Bergmann Subject: Re: [PATCH v3 3/9] efi/libstub: Remove .note.gnu.property Message-ID: <20200624134854.GF25945@arm.com> References: <20200624014940.1204448-1-keescook@chromium.org> <20200624014940.1204448-4-keescook@chromium.org> <20200624033142.cinvg6rbg252j46d@google.com> <202006232143.66828CD3@keescook> <20200624104356.GA6134@willie-the-truck> <20200624112647.GC6134@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200624112647.GC6134@willie-the-truck> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 24, 2020 at 12:26:47PM +0100, Will Deacon wrote: > On Wed, Jun 24, 2020 at 12:46:32PM +0200, Ard Biesheuvel wrote: > > On Wed, 24 Jun 2020 at 12:44, Will Deacon wrote: > > > On Tue, Jun 23, 2020 at 09:44:11PM -0700, Kees Cook wrote: > > > > On Tue, Jun 23, 2020 at 08:31:42PM -0700, 'Fangrui Song' via Clang Built Linux wrote: > > > > > arch/arm64/Kconfig enables ARM64_PTR_AUTH by default. When the config is on > > > > > > > > > > ifeq ($(CONFIG_ARM64_BTI_KERNEL),y) > > > > > branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET_BTI) := -mbranch-protection=pac-ret+leaf+bti > > > > > else > > > > > branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET) := -mbranch-protection=pac-ret+leaf > > > > > endif > > > > > > > > > > This option creates .note.gnu.property: > > > > > > > > > > % readelf -n drivers/firmware/efi/libstub/efi-stub.o > > > > > > > > > > Displaying notes found in: .note.gnu.property > > > > > Owner Data size Description > > > > > GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 > > > > > Properties: AArch64 feature: PAC > > > > > > > > > > If .note.gnu.property is not desired in drivers/firmware/efi/libstub, specifying > > > > > -mbranch-protection=none can override -mbranch-protection=pac-ret+leaf > > > > > > > > We want to keep the branch protection enabled. But since it's not a > > > > "regular" ELF, we don't need to keep the property that identifies the > > > > feature. > > > > > > For the kernel Image, how do we remove these sections? The objcopy flags > > > in arch/arm64/boot/Makefile look both insufficient and out of date. My > > > vmlinux ends up with both a ".notes" and a ".init.note.gnu.property" > > > segment. > > > > > > > The latter is the fault of the libstub make rules, that prepend .init > > to all section names. > > Hmm. I tried adding -mbranch-protection=none to arm64 cflags for the stub, > but I still see this note in vmlinux. It looks like it comes in via the > stub copy of lib-ctype.o, but I don't know why that would force the > note. The cflags look ok to me [1] and I confirmed that the note is > being generated by the compiler. > > > I'm not sure if there is a point to having PAC and/or BTI in the EFI > > stub, given that it runs under the control of the firmware, with its > > memory mappings and PAC configuration etc. > > Agreed, I just can't figure out how to get rid of the note. Because this section is generated by the linker itself I think you might have to send it to /DISCARD/ in the link, or strip it explicitly after linking. Cheers ---Dave