Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp467315ybt; Wed, 24 Jun 2020 03:46:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzb7exyWOf0jAqpfMHzV87V9puyc7az+qjcuPhtGCRcsr3/K5ANSsCXLs8ie+2N7ifm4pIA X-Received: by 2002:a17:906:538e:: with SMTP id g14mr11101389ejo.300.1592995606361; Wed, 24 Jun 2020 03:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592995606; cv=none; d=google.com; s=arc-20160816; b=FNdM/mHOHgzQc7Vmph2qEtSD5V2JP5B2DmQhpEmHwScGX5rzjycX7u5jV5nxIoTWJu VP6dopudvsL2B6Wpn3vAGBNHSIR62SerSl6RHoUCyazWDey/RuFndLBLZjDV3jeSivRZ YCdVjFYjiplwvPrNzGwS44WEA5bu7vKdAKTQhwH4fEi0Pcz2/YkRwLSad8jocen1xqdD J/mcuUiaOQggn0el0Dg71P/IS4M+y8VaeMvnJkqKWsiGz1Y2t9D7UM1ufYmrFyNxtKUb Z/cFOba2z4KArOqQ8XM7Yc8Ig9vA0p1u70ssQ+dTQ28MTnYXcq7B1IPXS2lLQp+aX2f3 NevQ== 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=dxg/VdEAKu9Oyur7G2pIrn9EV2xRGtMW/ziEj7AS4CQ=; b=iQ8MbfeDsgheZmMnouZaAYDjHSJIbc2K+M7pIS2fkQehKWWB14OAIOFoRVYhr7zs+V N1LNKv5+wZVs5gO4sQvYGdoMNuIbCgGHN93prHV7mgpQPi9kiOc0KuJqn5WGUDHBS5Is GKvg0H/RtHi+dhp3KRog+pdRnTpQL091dpnWfKu5CrdkDE6JDJDbWMtpsjylfdjXTbRU GO+dRbk1N1P2ft2mrpe4YnIpzgfNoQo6VhugtB80IfGX/gjf+T0RUUoI8kAO5IR82BA9 9QRvOH+hs5ykNtpDyQ30acjwe3a4RTewFw8c+RIy5UuBkUEsknCN0dnRXtEJ81GDIaBJ 3rpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tw0YgqlB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si13085975ejb.286.2020.06.24.03.46.21; Wed, 24 Jun 2020 03:46:46 -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; dkim=pass header.i=@kernel.org header.s=default header.b=tw0YgqlB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388950AbgFXKoE (ORCPT + 99 others); Wed, 24 Jun 2020 06:44:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:60664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388421AbgFXKoD (ORCPT ); Wed, 24 Jun 2020 06:44:03 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DC61F20644; Wed, 24 Jun 2020 10:43:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592995443; bh=mdTAfhkDJYCASKqPut+490INXl3yMYXb8omd1AxIpR4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tw0YgqlBzSkYR/8dx7x7agmXiX8h/g6EpRmEO/a+1MwBTs1pSuTCrSWZC5vI/je1Y B8zTuAPx69gOyfVPgWUiRzAt6Ps2l+kX6KH9h9vy5X05ox3kvM9GqlQXGjW5kCT8lk WRLAu0eli8TOtr0mprB99/5d9B7o1GRFfm+BjnNo= Date: Wed, 24 Jun 2020 11:43:56 +0100 From: Will Deacon To: Kees Cook Cc: Fangrui Song , Catalin Marinas , Mark Rutland , Ard Biesheuvel , Peter Collingbourne , James Morse , Borislav Petkov , Thomas Gleixner , Ingo Molnar , Russell King , Masahiro Yamada , Arvind Sankar , Nick Desaulniers , Nathan Chancellor , Arnd Bergmann , x86@kernel.org, clang-built-linux@googlegroups.com, linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/9] efi/libstub: Remove .note.gnu.property Message-ID: <20200624104356.GA6134@willie-the-truck> References: <20200624014940.1204448-1-keescook@chromium.org> <20200624014940.1204448-4-keescook@chromium.org> <20200624033142.cinvg6rbg252j46d@google.com> <202006232143.66828CD3@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202006232143.66828CD3@keescook> 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 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: > > On 2020-06-23, Kees Cook wrote: > > > In preparation for adding --orphan-handling=warn to more architectures, > > > make sure unwanted sections don't end up appearing under the .init > > > section prefix that libstub adds to itself during objcopy. > > > > > > Signed-off-by: Kees Cook > > > --- > > > drivers/firmware/efi/libstub/Makefile | 3 +++ > > > 1 file changed, 3 insertions(+) > > > > > > diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile > > > index 75daaf20374e..9d2d2e784bca 100644 > > > --- a/drivers/firmware/efi/libstub/Makefile > > > +++ b/drivers/firmware/efi/libstub/Makefile > > > @@ -66,6 +66,9 @@ lib-$(CONFIG_X86) += x86-stub.o > > > CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) > > > CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) > > > > > > +# Remove unwanted sections first. > > > +STUBCOPY_FLAGS-y += --remove-section=.note.gnu.property > > > + > > > # > > > # For x86, bootloaders like systemd-boot or grub-efi do not zero-initialize the > > > # .bss section, so the .bss section of the EFI stub needs to be included in the > > > > 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. Will