From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15A3DC433E0 for ; Tue, 23 Jun 2020 21:08:49 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D97CA20663 for ; Tue, 23 Jun 2020 21:08:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="VaD4D/dK"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="j78DWRbT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D97CA20663 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7of9uvGmA07Wz9SSFMe6d37SDZRHv2882JyVTLuvpk0=; b=VaD4D/dK0jNxvx+uoRCmC3+hp o4g45kCQq77HaVuEpJRtmX+g7I8qhRHdFwOyUjxCbIoLUGLI4UAP4eRNEyjVYvC6LqdYLIuIxTZ+4 zBzEbDRgvTd7LUNGFluIgK/ajNLvjDefp30e7MIzE3x5l/bKTalWHGHLaqp2F0Pkhh6RKx+i0aD5G 4XP6AnOcoOt5LCLe+xtImvQ7t7Gm+rg/FEAWLmcEoDYcqUFMrbBZdCxUH1bBqSBPkmHb1CYTmkB2F 9KFX2i8jFmC3bqsmIswLuZlmTT1DG0o9WdYdyfuSZJ8YBuQo/D6Y+cCwYAL4+kbpoGCPtNgH4Z+XV soQt/y/wg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnq7y-0008VO-7f; Tue, 23 Jun 2020 21:06:46 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnq7v-0008UT-HV for linux-arm-kernel@lists.infradead.org; Tue, 23 Jun 2020 21:06:44 +0000 Received: by mail-pg1-x544.google.com with SMTP id t6so161879pgq.1 for ; Tue, 23 Jun 2020 14:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZBL2aRcchnq3anZZCmM/n3YdrJxQ1yPcC64pjaJoEnQ=; b=j78DWRbTC/yWle9y06TBfnGl82zH2z/FQhgsLF1sXV2iIZzR7abFb6067YGEgre2UJ Fba921ZmQN/ZNbV1/1hATIvk6Ge9XhEKu43z3J44AJsIsMH9tfsCDMYWF7qlXlNADA8a 52MSYeNt6i+ongIcgGx4MqoEnibhEDCwUkg3o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZBL2aRcchnq3anZZCmM/n3YdrJxQ1yPcC64pjaJoEnQ=; b=dyY3O2oZnYPKqnFcKF3U7D6xYrkWTxHrM3sDg0MV0oEZtdH2LWVGv9JwLFxyPSyY4y 9RmPHmvyiGPs1TZ1plAI3kR2evKuO0AoX33HZ/EzjiuVF55kVE/PKyxEQZg593PUjW+E etpJD1lebqvUW4HUkrhRC2EMBBUy+skb42K1tCfw0T4X8G0lI8XcuZzgPMQy6xYsN4EA sayeMKwm21Qt7BAWeIov0DQMVId51HyWbduI2uUPdeZvS4gxcIZgnrZqZAiyaM67gHhY TzDKZnao/OG9NXSyPquwLXrxr72qxEXtWIQmoqOnMmz2unuxtWcOIPa0XaLaLdkzFFoV c/vg== X-Gm-Message-State: AOAM531ORkWihOxXXTfyzm8+Xi5ErfgDt4RGdvftcVSLl68dFq/q0vtB YxOPhhHmKfWTo/5/4Fxxe3j5LnE8QJo= X-Google-Smtp-Source: ABdhPJx3Vnft3VkW+IN3ZfC4PaZbxkxZHWmBGNutKlw1+vohd+J2dRi8SVvFwd+LojipRVgS91GF3g== X-Received: by 2002:a63:9347:: with SMTP id w7mr18414729pgm.409.1592946399794; Tue, 23 Jun 2020 14:06:39 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g17sm3167286pju.11.2020.06.23.14.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jun 2020 14:06:39 -0700 (PDT) Date: Tue, 23 Jun 2020 14:06:37 -0700 From: Kees Cook To: Ard Biesheuvel Subject: Re: [PATCH v2 2/2] arm64/build: Warn on orphan section placement Message-ID: <202006231208.F3DA600E18@keescook> References: <20200622205815.2988115-1-keescook@chromium.org> <20200622205815.2988115-3-keescook@chromium.org> <20200623145218.GC4336@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Arnd Bergmann , Peter Collingbourne , Catalin Marinas , Nick Desaulniers , Linux Kernel Mailing List , clang-built-linux , James Morse , Nathan Chancellor , Will Deacon , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jun 23, 2020 at 04:59:39PM +0200, Ard Biesheuvel wrote: > On Tue, 23 Jun 2020 at 16:52, Will Deacon wrote: > > > > On Mon, Jun 22, 2020 at 01:58:15PM -0700, Kees Cook wrote: > > > We don't want to depend on the linker's orphan section placement > > > heuristics as these can vary between linkers, and may change between > > > versions. All sections need to be explicitly named in the linker > > > script. > > > > > > Explicitly include debug sections when they're present. Add .eh_frame* > > > to discard as it seems that these are still generated even though > > > -fno-asynchronous-unwind-tables is being specified. Add .plt and > > > .data.rel.ro to discards as they are not actually used. Add .got.plt > > > to the image as it does appear to be mapped near .data. Finally enable > > > orphan section warnings. > > > > Can you elaborate a bit on what .got.plt is being used for, please? I > > wonder if there's an interaction with an erratum workaround in the linker > > or something. > > > > .got.plt is not used at all, but it has three magic entries at the > start that the dynamic linker uses for lazy dispatch, so it turns up > as a non-empty section of 0x18 bytes. Is there a way to suppress the generation? I haven't found a way, so I'd left it as-is. > We should be able to discard it afaict, but given that it does not > actually take up any space, it doesn't really matter either way. I will add it to the discards then. > > > diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile > > > index a0d94d063fa8..3e628983445a 100644 > > > --- a/arch/arm64/Makefile > > > +++ b/arch/arm64/Makefile > > > @@ -29,6 +29,10 @@ LDFLAGS_vmlinux += --fix-cortex-a53-843419 > > > endif > > > endif > > > > > > +# We never want expected sections to be placed heuristically by the > > > +# linker. All sections should be explicitly named in the linker script. > > > +LDFLAGS_vmlinux += --orphan-handling=warn > > > + > > > ifeq ($(CONFIG_ARM64_USE_LSE_ATOMICS), y) > > > ifneq ($(CONFIG_ARM64_LSE_ATOMICS), y) > > > $(warning LSE atomics not supported by binutils) > > > diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S > > > index 5427f502c3a6..c9ecb3b2007d 100644 > > > --- a/arch/arm64/kernel/vmlinux.lds.S > > > +++ b/arch/arm64/kernel/vmlinux.lds.S > > > @@ -94,7 +94,8 @@ SECTIONS > > > /DISCARD/ : { > > > *(.interp .dynamic) > > > *(.dynsym .dynstr .hash .gnu.hash) > > > - *(.eh_frame) > > > + *(.plt) *(.data.rel.ro) > > > + *(.eh_frame) *(.init.eh_frame) > > > > Do we need to include .eh_frame_hdr here too? > > It would be better to build with -fno-unwind-tables, in which case > these sections should not even exist. Nothing seems to help with the .eh_frame issue (even with -fno-asynchronous-unwind-tables and -fno-unwind-tables): $ aarch64-linux-gnu-gcc -Wp,-MMD,arch/arm64/kernel/.smccc-call.o.d \ -nostdinc -isystem /usr/lib/gcc-cross/aarch64-linux-gnu/9/include \ -I./arch/arm64/include -I./arch/arm64/include/generated -I./include \ -I./arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi \ -I./include/uapi -I./include/generated/uapi -include \ ./include/linux/kconfig.h -D__KERNEL__ -mlittle-endian \ -DCC_USING_PATCHABLE_FUNCTION_ENTRY -DKASAN_SHADOW_SCALE_SHIFT=3 \ -D__ASSEMBLY__ -fno-PIE -mabi=lp64 -fno-asynchronous-unwind-tables \ -fno-unwind-tables -DKASAN_SHADOW_SCALE_SHIFT=3 -Wa,-gdwarf-2 -c -o \ arch/arm64/kernel/smccc-call.o arch/arm64/kernel/smccc-call.S $ readelf -S arch/arm64/kernel/smccc-call.o | grep eh_frame [17] .eh_frame PROGBITS 0000000000000000 000001f0 [18] .rela.eh_frame RELA 0000000000000000 00000618 > > > } > > > > > > . = KIMAGE_VADDR + TEXT_OFFSET; > > > @@ -209,6 +210,7 @@ SECTIONS > > > _data = .; > > > _sdata = .; > > > RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN) > > > + .got.plt : ALIGN(8) { *(.got.plt) } > > > > > > /* > > > * Data written with the MMU off but read with the MMU on requires > > > @@ -244,6 +246,7 @@ SECTIONS > > > _end = .; > > > > > > STABS_DEBUG > > > + DWARF_DEBUG > > > > I know you didn't add it, but do we _really_ care about stabs debug? Who > > generates that for arm64? It's also where .comment and the .symtab ends up living. As a result, I think it's correct to keep it. (If we wanted to split .stabs from .comment/.symtab, we could do that, but I'd kind of like to avoid it for this series, as it feels kind of unrelated.) -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel