Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4134295ybz; Tue, 28 Apr 2020 06:23:23 -0700 (PDT) X-Google-Smtp-Source: APiQypL/MbgPt+H8nec0hr4K5XsyUK/tF40r1p1KaOyRsL3dzmAIRqh8FI2CINWRGoJ2SqQm/wiM X-Received: by 2002:aa7:c1ca:: with SMTP id d10mr23084121edp.152.1588080203647; Tue, 28 Apr 2020 06:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588080203; cv=none; d=google.com; s=arc-20160816; b=WjDIJDyIElaqNHH9oS/f75wVhVj3hvU19zBrxscKh0XjcyLGwhHedTodU7Rcl1R9md fqp31Jw79I2L2vjoTlix1Gj5ernr97B0JcDFouDCQktcLPT82cGLpZgQ94ySTphgYXVj bKWY5ykmodKkNkET7iNygwDrp1EJlbNXZZvoM9ClVSJK/hucoXnPVwJTUxYTUDbUSwlk +VsSKIM4Jb2UlaLRIg+FVooWKFBE2xO4LQI0P6N2FPmGxTkLNOk408hmRfuyzNf8Wjwl joA4S5PtoU89rRBXy3UhbiOR8LfrJj6DhyTrABlHGrTJKjMIorc1N7QqBeeuni+pRW/8 qsLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vloW/Le5uTQWcHYDSa4UBFwJd+x/1yJE7+IrW0Uir68=; b=jyiRCBj+V24TXCcL39i0BXSVzpUw+zO608QxR0IepgLQwilR1MX6MwX4kQP/XKtQaC jMaT2cjaAchvDjjh2Q87TFEJxvZIN0CcBhtWlyVZtA1VtVkK1XjUerDtr5+tSmC8+lYH J/T8eFNRxFuJOpmjmfHvrwCW+flC8i6kWPjoYsoTrxXcnxARnfChS5D8F+OS4xvTwHdu Yjb4D6GzkTl+WmCKgRZOjfjQIDWhV5IcAbsDgMOMfui5L+eRw+vojoUwutBhjKaRXAfa smGf+PbewrmywuqWn+yV4lP9HYKe3cZcEieBC1cJGyRKtGW+QwzCrxJfPOP9dM/U8GTN kR+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uugDtdaa; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qq22si1726692ejb.523.2020.04.28.06.23.00; Tue, 28 Apr 2020 06:23:23 -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=@gmail.com header.s=20161025 header.b=uugDtdaa; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727988AbgD1NVK (ORCPT + 99 others); Tue, 28 Apr 2020 09:21:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727804AbgD1NVJ (ORCPT ); Tue, 28 Apr 2020 09:21:09 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7698DC03C1AB; Tue, 28 Apr 2020 06:21:08 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id h11so8348810plr.11; Tue, 28 Apr 2020 06:21:08 -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=uugDtdaaPea9Qem1yWXNMLi9gRG0GI/Vgl/Z+2D8dNgR0YSKpud6IPhbq5RS8gDIWD zdrj7X8QwHwITgj6rGtnWk9zsSUe+HdFNCjSJgQycxot+o2TGvW23sKBdrguYrSdNXYW kyPeeRIVqQ4jme4VsO/ZAU0BbglFDS24Lg4v/vb9GO3GmRnykawt7JA36rysNz8P02yx QChX37YVxcMRuhA6NgC8s81uDJU3cyxsab1R1vx0DHFubvApL6dvSBOXChEPEbdHtvlb rUrB40lVSAlmD+hrnrNFidfvV/YfhQjh3KiwIOO5XfmR3Sy8QiL2HnXDuhL7p0kxD2Hf 2/hg== 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=uCU74+P03q+UTYRGdURrdZWRx5L1fyrmiAc5sl/D+WQ79CiWcAa6YSMJTRZRAGSHHn Pc2H7U2c3id/cmhw37erhn1wKa4TNwqz1nvJSTpveSbLNiOG0sp2Ixp+G7hhltYSOA+Q zNzGp0mvGd99W9jV0ciNCEDVYUuhpDW/GUArBgRLVpF2dZA557iFQ6s2PivchjdUjQlF RBa4VTjBAX+CqrF60wydHPOZfVQ1MwUupStrG+EoG8mhFLyh9VD9tF78GXB1ddecB+tW 5kHzv+L1xQaMJeLyINQZlVJ1sDHe5iTV1lIxWmJmTrN5eyiv4/rCUsthrUH9ptoA87Yy Ql/w== X-Gm-Message-State: AGi0PuYtnumI1dIT0ptp9tyaXDL7mVl8p/jh+zBHojh3x7uO55jEDJH0 EIF6xgzYNUsCf33bZ6lYHSk= X-Received: by 2002:a17:90a:3268:: with SMTP id k95mr4895519pjb.185.1588080067940; Tue, 28 Apr 2020 06:21:07 -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 r12sm12957662pgv.59.2020.04.28.06.21.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 06:21:07 -0700 (PDT) Received: from gnu-cfl-2.localdomain (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 511E7C037D; Tue, 28 Apr 2020 06:21:06 -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: Tue, 28 Apr 2020 06:21:05 -0700 Message-Id: <20200428132105.170886-2-hjl.tools@gmail.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200428132105.170886-1-hjl.tools@gmail.com> References: <20200428132105.170886-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