From mboxrd@z Thu Jan 1 00:00:00 1970 From: Will Deacon Subject: Re: [PATCH v3 3/9] efi/libstub: Remove .note.gnu.property Date: Wed, 24 Jun 2020 12:26:47 +0100 Message-ID: <20200624112647.GC6134@willie-the-truck> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail.kernel.org ([198.145.29.99]:43634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388811AbgFXL0z (ORCPT ); Wed, 24 Jun 2020 07:26:55 -0400 Content-Disposition: inline In-Reply-To: Sender: linux-arch-owner@vger.kernel.org List-ID: To: Ard Biesheuvel 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 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 Bu= ilt Linux wrote: > > > > arch/arm64/Kconfig enables ARM64_PTR_AUTH by default. When the conf= ig is on > > > > > > > > ifeq ($(CONFIG_ARM64_BTI_KERNEL),y) > > > > branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET_BTI) :=3D -mb= ranch-protection=3Dpac-ret+leaf+bti > > > > else > > > > branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET) :=3D -mbranc= h-protection=3Dpac-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/libstu= b, specifying > > > > -mbranch-protection=3Dnone can override -mbranch-protection=3Dpac-r= et+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. > > >=20 > The latter is the fault of the libstub make rules, that prepend .init > to all section names. Hmm. I tried adding -mbranch-protection=3Dnone 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. Will [1] -mlittle-endian -DKASAN_SHADOW_SCALE_SHIFT=3D3 -Qunused-arguments -Wall= -Wundef -Werror=3Dstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -f= no-common -fshort-wchar -fno-PIE -Werror=3Dimplicit-function-declaration -W= error=3Dimplicit-int -Wno-format-security -std=3Dgnu89 --target=3Daarch64-l= inux-gnu --prefix=3D/usr/local/google/home/willdeacon/bin/ --gcc-toolchain= =3D/usr/local/google/home/willdeacon -no-integrated-as -Werror=3Dunknown-wa= rning-option -mgeneral-regs-only -DCONFIG_CC_HAS_K_CONSTRAINT=3D1 -fno-asyn= chronous-unwind-tables -mbranch-protection=3Dpac-ret+leaf+bti -Wa,-march=3D= armv8.3-a -DKASAN_SHADOW_SCALE_SHIFT=3D3 -fno-delete-null-pointer-checks -W= no-address-of-packed-member -O2 -Wframe-larger-than=3D2048 -fstack-protecto= r-strong -Wno-format-invalid-specifier -Wno-gnu -mno-global-merge -Wno-unus= ed-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -W= declaration-after-statement -Wvla -Wno-pointer-sign -Wno-array-bounds -fno-= strict-overflow -fno-merge-all-constants -fno-stack-check -Werror=3Ddate-ti= me -Werror=3Dincompatible-pointer-types -fmacro-prefix-map=3D./=3D -Wno-ini= tializer-overrides -Wno-format -Wno-sign-compare -Wno-format-zero-length -W= no-tautological-constant-out-of-range-compare -fpie -mbranch-protection=3Dn= one -I./scripts/dtc/libfdt -Os -DDISABLE_BRANCH_PROFILING -include ./driver= s/firmware/efi/libstub/hidden.h -D__NO_FORTIFY -ffreestanding -fno-stack-pr= otector -fno-addrsig -D__DISABLE_EXPORTS -DKBUILD_MODFILE=3D'"drivers/fi= rmware/efi/libstub/lib-ctype"' -DKBUILD_BASENAME=3D'"lib_ctype"' -DKBUILD_M= ODNAME=3D'"lib_ctype"' -c -o drivers/firmware/efi/libstub/lib-ctype.o lib/c= type.c From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.kernel.org ([198.145.29.99]:43634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388811AbgFXL0z (ORCPT ); Wed, 24 Jun 2020 07:26:55 -0400 Date: Wed, 24 Jun 2020 12:26:47 +0100 From: Will Deacon Subject: Re: [PATCH v3 3/9] efi/libstub: Remove .note.gnu.property Message-ID: <20200624112647.GC6134@willie-the-truck> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: Sender: linux-arch-owner@vger.kernel.org List-ID: To: Ard Biesheuvel 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 Message-ID: <20200624112647.m4aRAkzKOEFtEZY4ChB46uO5WCsZ6ftR87faAOfS3Xg@z> 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 Bu= ilt Linux wrote: > > > > arch/arm64/Kconfig enables ARM64_PTR_AUTH by default. When the conf= ig is on > > > > > > > > ifeq ($(CONFIG_ARM64_BTI_KERNEL),y) > > > > branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET_BTI) :=3D -mb= ranch-protection=3Dpac-ret+leaf+bti > > > > else > > > > branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET) :=3D -mbranc= h-protection=3Dpac-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/libstu= b, specifying > > > > -mbranch-protection=3Dnone can override -mbranch-protection=3Dpac-r= et+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. > > >=20 > The latter is the fault of the libstub make rules, that prepend .init > to all section names. Hmm. I tried adding -mbranch-protection=3Dnone 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. Will [1] -mlittle-endian -DKASAN_SHADOW_SCALE_SHIFT=3D3 -Qunused-arguments -Wall= -Wundef -Werror=3Dstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -f= no-common -fshort-wchar -fno-PIE -Werror=3Dimplicit-function-declaration -W= error=3Dimplicit-int -Wno-format-security -std=3Dgnu89 --target=3Daarch64-l= inux-gnu --prefix=3D/usr/local/google/home/willdeacon/bin/ --gcc-toolchain= =3D/usr/local/google/home/willdeacon -no-integrated-as -Werror=3Dunknown-wa= rning-option -mgeneral-regs-only -DCONFIG_CC_HAS_K_CONSTRAINT=3D1 -fno-asyn= chronous-unwind-tables -mbranch-protection=3Dpac-ret+leaf+bti -Wa,-march=3D= armv8.3-a -DKASAN_SHADOW_SCALE_SHIFT=3D3 -fno-delete-null-pointer-checks -W= no-address-of-packed-member -O2 -Wframe-larger-than=3D2048 -fstack-protecto= r-strong -Wno-format-invalid-specifier -Wno-gnu -mno-global-merge -Wno-unus= ed-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -W= declaration-after-statement -Wvla -Wno-pointer-sign -Wno-array-bounds -fno-= strict-overflow -fno-merge-all-constants -fno-stack-check -Werror=3Ddate-ti= me -Werror=3Dincompatible-pointer-types -fmacro-prefix-map=3D./=3D -Wno-ini= tializer-overrides -Wno-format -Wno-sign-compare -Wno-format-zero-length -W= no-tautological-constant-out-of-range-compare -fpie -mbranch-protection=3Dn= one -I./scripts/dtc/libfdt -Os -DDISABLE_BRANCH_PROFILING -include ./driver= s/firmware/efi/libstub/hidden.h -D__NO_FORTIFY -ffreestanding -fno-stack-pr= otector -fno-addrsig -D__DISABLE_EXPORTS -DKBUILD_MODFILE=3D'"drivers/fi= rmware/efi/libstub/lib-ctype"' -DKBUILD_BASENAME=3D'"lib_ctype"' -DKBUILD_M= ODNAME=3D'"lib_ctype"' -c -o drivers/firmware/efi/libstub/lib-ctype.o lib/c= type.c