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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 319F8C83003 for ; Tue, 28 Apr 2020 01:49:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EAB02070B for ; Tue, 28 Apr 2020 01:49:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tMY7Nqx0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726397AbgD1BtG (ORCPT ); Mon, 27 Apr 2020 21:49:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726261AbgD1BtE (ORCPT ); Mon, 27 Apr 2020 21:49:04 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CCB4C03C1A8; Mon, 27 Apr 2020 18:49:03 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id 18so9911032pfx.6; Mon, 27 Apr 2020 18:49:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vloW/Le5uTQWcHYDSa4UBFwJd+x/1yJE7+IrW0Uir68=; b=tMY7Nqx0yqobkZe58YFhx1OG8yv4pf1IV9qs+bvamO0ssZ2DNHnvG9NWFBdyJ9zDhq 3NhdKMcuGNglY0QeMweyW3U2rebJhB5xvUW03S8hTpb2axpkIL4LmSie7xv3Bz62ZwM1 2BMffB9lJb7ZswTHs481noJ5CUOIo//yGyCBf6lVS0VEEeSowKcgM/eOn9EdY2nFKUkq OuxDgnm0HxCUwwMHMvGyGKQwpiGmQzpwRM23EMdJHC83mqrQ09+TuyCh8iShhOD/Uad0 QE8Zuj8UnFf0Ani8mhF33kVeWYBepv5F7VAhs2ZOz2yfKR8tuVrSbpNaAa/3885mDRi5 uMAw== 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=vloW/Le5uTQWcHYDSa4UBFwJd+x/1yJE7+IrW0Uir68=; b=jUR5FBaq2ssqcdUdivAQRrt8U1CLt8wuGaUdmhKNKx9/wBqIfpDDiIfoXSOeSZXsFg MmDszkS+1Gpq0FYZyRqIP2sziK5/9M4ePEyQJjGoARWjyAN+8mTbk66poQru6vUJNY53 5MmmOF3A+Na4j84KQRGKPtWX9zCQyD6DD3oCOwdof/4OTkZuKVTHOHlemXHRCrswmmQg 8t95UqH47eTE+KDX00EGSmEtAd3ci5xEODzOkYA+SgNA3MeExjHp5yYy+1tJUT0wJaoQ Fe9gYr/E2KwN9fZib8R+535lyRRAU/7mpci+trU8PcApsVkim6kJXCz5E6QAvCd7lira iB0g== X-Gm-Message-State: AGi0Pub3IUMxANSAUC6/uvRbRSviNAmgWGO/GR41vSWrFkEqsTsZkB0o gBgmmGXncnyaOpPYJYYCu8k= X-Google-Smtp-Source: APiQypIrs/KyEZGo9isIYbNHduvrckXj0XCrJMMoQhBOT/pJSBv9dMK3h8aO2de9vySF1HvRt3aMWg== X-Received: by 2002:a63:f958:: with SMTP id q24mr6909810pgk.338.1588038542846; Mon, 27 Apr 2020 18:49:02 -0700 (PDT) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id t188sm11667641pgb.80.2020.04.27.18.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2020 18:49:01 -0700 (PDT) Received: from gnu-cfl-2.localdomain (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 9E060C034D; Mon, 27 Apr 2020 18:49:00 -0700 (PDT) From: "H.J. Lu" To: linux-kernel@vger.kernel.org Cc: Yu-cheng Yu , Arnd Bergmann , linux-arch@vger.kernel.org, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Kees Cook , Borislav Petkov , "Naveen N . Rao" , linuxppc-dev@lists.ozlabs.org Subject: [PATCH 2/2] Discard .note.gnu.property sections in generic NOTES Date: Mon, 27 Apr 2020 18:49:00 -0700 Message-Id: <20200428014900.407098-2-hjl.tools@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200428014900.407098-1-hjl.tools@gmail.com> References: <20200428014900.407098-1-hjl.tools@gmail.com> 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 With the command-line option, -mx86-used-note=yes, the x86 assembler in binutils 2.32 and above generates a program property note in a note section, .note.gnu.property, to encode used x86 ISAs and features. But kernel linker script only contains a single NOTE segment: PHDRS { text PT_LOAD FLAGS(5); data PT_LOAD FLAGS(6); percpu PT_LOAD FLAGS(6); init PT_LOAD FLAGS(7); note PT_NOTE FLAGS(0); } SECTIONS { ... .notes : AT(ADDR(.notes) - 0xffffffff80000000) { __start_notes = .; KEEP(*(.not e.*)) __stop_notes = .; } :text :note ... } The NOTE segment generated by kernel linker script is aligned to 4 bytes. But .note.gnu.property section must be aligned to 8 bytes on x86-64 and we get [hjl@gnu-skx-1 linux]$ readelf -n vmlinux Displaying notes found in: .notes Owner Data size Description Xen 0x00000006 Unknown note type: (0x00000006) description data: 6c 69 6e 75 78 00 Xen 0x00000004 Unknown note type: (0x00000007) description data: 32 2e 36 00 xen-3.0 0x00000005 Unknown note type: (0x006e6558) description data: 08 00 00 00 03 readelf: Warning: note with invalid namesz and/or descsz found at offset 0x50 readelf: Warning: type: 0xffffffff, namesize: 0x006e6558, descsize: 0x80000000, alignment: 8 [hjl@gnu-skx-1 linux]$ Since note.gnu.property section in kernel image is never used, this patch discards .note.gnu.property sections in kernel linker script by adding /DISCARD/ : { *(.note.gnu.property) } before kernel NOTE segment in generic NOTES. Signed-off-by: H.J. Lu Reviewed-by: Kees Cook --- include/asm-generic/vmlinux.lds.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 71e387a5fe90..95cd678428f4 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -833,7 +833,14 @@ #define TRACEDATA #endif +/* + * Discard .note.gnu.property sections which are unused and have + * different alignment requirement from kernel note sections. + */ #define NOTES \ + /DISCARD/ : { \ + *(.note.gnu.property) \ + } \ .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \ __start_notes = .; \ KEEP(*(.note.*)) \ -- 2.25.4