Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp469077ybt; Wed, 24 Jun 2020 03:49:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhK86M3sDAaX8jlN0DrWw0AZVXNSB2Sm1ZCPhtgZ19/CofTvSwKsvzlt+psZHgGQmaxt8D X-Received: by 2002:a17:906:b24d:: with SMTP id ce13mr6480416ejb.546.1592995789721; Wed, 24 Jun 2020 03:49:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592995789; cv=none; d=google.com; s=arc-20160816; b=nqM1rZb1KZ/GfdeXNlBepg1jsFvEduRief5Afl8xr0s/xU/qXfzNwXtRbRd3f7cL42 BR1hIH3TnkzfPsssi/E3lZlvUnVKeJ0u0tp6nO9Md02BPoW1h3cucSzYRU4ak/B/583l KivAepDejZpE1vbSia4Q1JW3Fp3+tp/ZmJYytSM6x4fwycpfSD0K+V3NdoB8x1lHT34w hg5URtLai6kd5SUsmHWi/4m4yHToNwGhclY35Yj4kpq9sE3lSKG51Uzpmkd+0MM1q1ek y1PqkqDO5vRtv5otkABa5qjHbx0J/x6BgM2gKWsh2TWE1NCrpXv+ywwR9TEOoLeFBbtB oGMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=D8seSPwVn5lx6TNIU/PmFCUTleF1Iys9dcT264oBYQE=; b=UmeCOT84xjmMnprLuvdkgtBmh5KxUk+UZmvN7tLK0n368cmz1KU+0w6ajX0BDupFMy 3JSiTdmiXLa69AZxVtycIREoAuT+zVnwbPOYfk+1wm0f5Pj7rY4kMMZciGshNy8lBD28 x3Scl5Rw9lYVCl0v/vq82aLrV87rQmJw98bkactdZSPCEWh8fDk6t/fdGjrn5/DMH+70 H9/KXlSSJX83bDF3JG+9up/SiBLJboLZ9IbvQmDnTkLyREeIPM0UvV9XduXi6kz71Lfd n3PQ8yk3JYu4bDbibRAK9ML/hGIp7PkfJWUnJf3TE8HooxvsO7EHpivNuMEfenLI+3H4 2xrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OGlxeWyH; 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 qc28si12543822ejb.292.2020.06.24.03.49.25; Wed, 24 Jun 2020 03:49:49 -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=OGlxeWyH; 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 S2390445AbgFXKqp (ORCPT + 99 others); Wed, 24 Jun 2020 06:46:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:33472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388516AbgFXKqp (ORCPT ); Wed, 24 Jun 2020 06:46:45 -0400 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8C05C21473; Wed, 24 Jun 2020 10:46:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592995604; bh=6CP6qxsVEuOjCrX7ZFGs1e/lcJ7AgipGLIXDdr4Rzeo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=OGlxeWyHhToHjXuphDyewr/kdrQyHf5oTZ1Rd8L/ZPUhRgE9Oqyr8efXiLjfy1vdv wlqn5JPvj4FaKpYJ6WF69t7WpuuIxuemrWnnyJi9jESZKOBx3OvSptVs38MLk1wikH QJHljm0q17sC5Q87Y9duCOxbj/6cpfnUcK6K3J/4= Received: by mail-oi1-f178.google.com with SMTP id k4so1446032oik.2; Wed, 24 Jun 2020 03:46:44 -0700 (PDT) X-Gm-Message-State: AOAM532yNUAWLMtyWZF+xQXb//ztaM67Sm+mft1/zJVMu5lCHJJuPvDR 6Ue/+dhDNr+Z92ynXj75rcq1t/FTftbuTGI8L08= X-Received: by 2002:aca:b241:: with SMTP id b62mr18670182oif.47.1592995603880; Wed, 24 Jun 2020 03:46:43 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <20200624104356.GA6134@willie-the-truck> From: Ard Biesheuvel Date: Wed, 24 Jun 2020 12:46:32 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 3/9] efi/libstub: Remove .note.gnu.property To: Will Deacon Cc: Kees Cook , Fangrui Song , Catalin Marinas , Mark Rutland , Peter Collingbourne , James Morse , Borislav Petkov , Thomas Gleixner , Ingo Molnar , Russell King , Masahiro Yamada , Arvind Sankar , Nick Desaulniers , Nathan Chancellor , Arnd Bergmann , X86 ML , clang-built-linux , linux-arch , linux-efi , Linux ARM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: > > > 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. > The latter is the fault of the libstub make rules, that prepend .init to all section names. 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.