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=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 54F70C433E0 for ; Mon, 22 Jun 2020 20:49:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31E612075A for ; Mon, 22 Jun 2020 20:49:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="KGrufEOt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730225AbgFVUtX (ORCPT ); Mon, 22 Jun 2020 16:49:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728512AbgFVUtV (ORCPT ); Mon, 22 Jun 2020 16:49:21 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D331C061796 for ; Mon, 22 Jun 2020 13:49:20 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id r18so8766181pgk.11 for ; Mon, 22 Jun 2020 13:49:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r1CVChw5lv6qJCnYUjb6+Q15TOtyE7dXeIu2ryL/SHg=; b=KGrufEOtpDgs2nOg9wb3X5+aCdoDBcU2BbqBJF9JnFiN7NYhGx8YRWkjEsx1innFuW 9AoEF8lI0idh1cywRxfFl46gPAtmITrhRGTpwyb9cDX6wWdAo/AUl9rtqtLADYyRSUjL w7JkfvilcJwN8sldL7jdsQIGufYkLtY7/Y9Ts= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r1CVChw5lv6qJCnYUjb6+Q15TOtyE7dXeIu2ryL/SHg=; b=C4IlzQZapUkV5uf8RPuNS9uXsIWsVABDPVQFLUzS4Ozd6FiqJi1g6HMiIOfOm7EoMS hQVw+rXPwkpXXcOxFE0F362vlXocnZAg0wo6CsCyYBLvsUSOf5hbb6Dlh7FCls2Jq2ss 0djM0mqjH7SFTnfi0GRZatp4ZG80/+5gIIHvz3EZmB+j8usR0R8Fpnej1WKGGGJoTQ9V NLxOWV1JXFMOwUWMSM4LzCz/eWunb/+FCcErX1Cutz1BhlsnEFp3JRBh/WZS9/foKuFw 9PiNXLB60gAg6miTIqtOC4QuKEqVwkqBKiD8AxEewsDF5CyYPHja25cZIMVGNylwiHiM TxzA== X-Gm-Message-State: AOAM532vL8U8NCTQvJbgCOf3jibR/qxUpd/vw6tZ6ynXfzAF4OStwEOf oA+ZNjKZ6qvAqRii+tQVL1GzaQ== X-Google-Smtp-Source: ABdhPJxPxpqqRtjCVllhoqkxjmNgjtYDQxIQ16KOwWiOWFtnPCAZVrzEjz24KyaZYQPU/nCq+BLAsw== X-Received: by 2002:a63:a1f:: with SMTP id 31mr14066354pgk.228.1592858960160; Mon, 22 Jun 2020 13:49:20 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id i7sm12270469pgr.86.2020.06.22.13.49.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 13:49:17 -0700 (PDT) From: Kees Cook To: Russell King Cc: Kees Cook , Masahiro Yamada , Nick Desaulniers , Nathan Chancellor , Will Deacon , Ard Biesheuvel , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] arm/boot: Warn on orphan section placement Date: Mon, 22 Jun 2020 13:49:15 -0700 Message-Id: <20200622204915.2987555-3-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200622204915.2987555-1-keescook@chromium.org> References: <20200622204915.2987555-1-keescook@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Use common macros for debug sections, discards, and text stubs. Add discards for unwanted .note, and .rel sections. Finally, enable orphan section warning. Signed-off-by: Kees Cook --- arch/arm/boot/compressed/Makefile | 2 ++ arch/arm/boot/compressed/vmlinux.lds.S | 17 +++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 00602a6fba04..b8a97d81662d 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -128,6 +128,8 @@ endif LDFLAGS_vmlinux += --no-undefined # Delete all temporary local symbols LDFLAGS_vmlinux += -X +# Report orphan sections +LDFLAGS_vmlinux += --orphan-handling=warn # Next argument is a linker script LDFLAGS_vmlinux += -T diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S index 09ac33f52814..c2a8509f876f 100644 --- a/arch/arm/boot/compressed/vmlinux.lds.S +++ b/arch/arm/boot/compressed/vmlinux.lds.S @@ -2,6 +2,7 @@ /* * Copyright (C) 2000 Russell King */ +#include #ifdef CONFIG_CPU_ENDIAN_BE8 #define ZIMAGE_MAGIC(x) ( (((x) >> 24) & 0x000000ff) | \ @@ -17,8 +18,11 @@ ENTRY(_start) SECTIONS { /DISCARD/ : { + ARM_COMMON_DISCARD *(.ARM.exidx*) *(.ARM.extab*) + *(.note.*) + *(.rel.*) /* * Discard any r/w data - this produces a link error if we have any, * which is required for PIC decompression. Local data generates @@ -36,9 +40,7 @@ SECTIONS *(.start) *(.text) *(.text.*) - *(.gnu.warning) - *(.glue_7t) - *(.glue_7) + ARM_STUBS_TEXT } .table : ALIGN(4) { _table_start = .; @@ -128,12 +130,7 @@ SECTIONS PROVIDE(__pecoff_data_size = ALIGN(512) - ADDR(.data)); PROVIDE(__pecoff_end = ALIGN(512)); - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } + STABS_DEBUG + DWARF_DEBUG } ASSERT(_edata_real == _edata, "error: zImage file size is incorrect"); -- 2.25.1