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.7 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,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 473A9C43331 for ; Thu, 26 Mar 2020 17:43:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2805320722 for ; Thu, 26 Mar 2020 17:43:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728177AbgCZRnU (ORCPT ); Thu, 26 Mar 2020 13:43:20 -0400 Received: from mga12.intel.com ([192.55.52.136]:18316 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726260AbgCZRnT (ORCPT ); Thu, 26 Mar 2020 13:43:19 -0400 IronPort-SDR: BYiMiEJFweRY/VwnTCkor6tpJ2ANlt+LBzB5VEr84yq04p5EoOY6qHwuf6WPzKL4vsoX256VOZ ouHUCH+lT+4A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2020 10:43:15 -0700 IronPort-SDR: Aiz4wpGnnts9pYITigz6S4zpogVfkUa6rpXlocHUuwSLYrOzs4JpG5xSdlTkZq/AOvL/SqvRfK bucNzjqS98IQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,309,1580803200"; d="scan'208";a="238865881" Received: from scymds01.sc.intel.com ([10.148.94.138]) by fmsmga007.fm.intel.com with ESMTP; 26 Mar 2020 10:43:15 -0700 Received: from gnu-skx-1.sc.intel.com (gnu-skx-1.sc.intel.com [172.25.70.205]) by scymds01.sc.intel.com with ESMTP id 02QHhEAg006801; Thu, 26 Mar 2020 10:43:15 -0700 Received: from gnu-skx-1.sc.intel.com (localhost [IPv6:::1]) by gnu-skx-1.sc.intel.com (Postfix) with ESMTP id C14912C006A; Thu, 26 Mar 2020 10:43:14 -0700 (PDT) From: "H.J. Lu" To: linux-kernel@vger.kernel.org Cc: Andy Lutomirski , Thomas Gleixner , Kees Cook , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, Yu-cheng Yu Subject: [PATCH] x86: Discard .note.gnu.property sections in vDSO Date: Thu, 26 Mar 2020 10:43:14 -0700 Message-Id: <20200326174314.254662-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.25.1 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 x86 kernel vDSO linker script only contains a single NOTE segment: PHDRS { text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */ dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ note PT_NOTE FLAGS(4); /* PF_R */ eh_frame_hdr 0x6474e550; } The NOTE segment generated by vDSO 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 vdso]$ readelf -n vdso64.so Displaying notes found in: .note Owner Data size Description Linux 0x00000004 Unknown note type: (0x00000000) description data: 06 00 00 00 readelf: Warning: note with invalid namesz and/or descsz found at offset 0x20 readelf: Warning: type: 0x78, namesize: 0x00000100, descsize: 0x756e694c, alignment: 8 [hjl@gnu-skx-1 vdso]$ Since note.gnu.property section in vDSO is not checked by dynamic linker, this patch discards .note.gnu.property sections in vDSO by adding /DISCARD/ : { *(.note.gnu.property) } before .notes sections in vDSO linker script. Signed-off-by: H.J. Lu Reviewed-by: Kees Cook --- arch/x86/entry/vdso/vdso-layout.lds.S | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vdso-layout.lds.S index ea7e0155c604..4d152933547d 100644 --- a/arch/x86/entry/vdso/vdso-layout.lds.S +++ b/arch/x86/entry/vdso/vdso-layout.lds.S @@ -57,6 +57,13 @@ SECTIONS *(.gnu.linkonce.b.*) } :text + /* + * Discard .note.gnu.property sections which are unused and have + * different alignment requirement from vDSO note sections. + */ + /DISCARD/ : { + *(.note.gnu.property) + } .note : { *(.note.*) } :text :note .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr -- 2.25.1