Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4048613ybl; Mon, 27 Jan 2020 15:36:21 -0800 (PST) X-Google-Smtp-Source: APXvYqwhA5SoTNZ9LjSM+VzmYXbtdNaWSeBqXmlBFVAPZLo0SDIbXSiDA6hFZpYzYTP7rcVhYDz/ X-Received: by 2002:a9d:4c06:: with SMTP id l6mr14141493otf.161.1580168181286; Mon, 27 Jan 2020 15:36:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580168181; cv=none; d=google.com; s=arc-20160816; b=LbP9/Rg6SdOGrdKwCPdMtyS7bi7eKPtCi4FaIasTKcSR+Tp5Z5yuRik5geGWiCQerd qm/uqLYdgXubMnG0dnDy25Z5VDPOa5eaH7ZKLWfLUlOl96QZPPtmrVDsG8VAovlHDT+W WEm3I7IphRiavB0VAVTF12nqyC1TggZJfr9OGNZBozAmbnl/ikSmBq9ZvpFPo73IS/G5 ZB3RGerkpQHh8e44N9vT6HEJGBQTIzV5ZkJScPNlH5aTbkKObA/RhOa+3vTrLt1SDgtt EcCpXpF3ib/7V7UJKLMVY3D222MTY2i3uK5QtnczKVKgTRbxDkMgtUL4tz/NSRxQ2ijo xLKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=fwPuLOZX/o8vjqlDCVTFY15+P0fnQe7CE6TakilvlE8=; b=HEQL8LsgApqeZkASwevNUdwZDUE64Hhg6H/H+MKP09FrIaDEwDU2sXpeukKwW2R3LP lHjPUHeZJVAK1Rkru6o5jzIc3o6uGHX8uk77wqfsT6CakNEtQXhrv8Glq5jwkuutMECR rnD+PTGl2/tlwXL9vPDPv5hJJgqh9CSUbRF691SGbi6KanjS3L5SzbqD9QkiLtXJo/Gz F429wRpxYa46qkbO5FfXZEXqnfK344ITkbA3t1RGq0WtP/VCSl7F0SOhy8GPbTQdOp0x YRIBMU0W7juBnZ/HDXL5CzDcdelOJkREba98MnEJQuo9r95fqTpXu84Gl7RvP6FkvV5d Rqgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YRaFDTvc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j19si4129247oij.51.2020.01.27.15.36.02; Mon, 27 Jan 2020 15:36:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YRaFDTvc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726173AbgA0Xel (ORCPT + 99 others); Mon, 27 Jan 2020 18:34:41 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:37783 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725955AbgA0Xel (ORCPT ); Mon, 27 Jan 2020 18:34:41 -0500 Received: by mail-pg1-f195.google.com with SMTP id q127so5967276pga.4 for ; Mon, 27 Jan 2020 15:34:40 -0800 (PST) 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=fwPuLOZX/o8vjqlDCVTFY15+P0fnQe7CE6TakilvlE8=; b=YRaFDTvc4S+IJUd3pcsFBtl6Ja6s2412aP/+AHITNKqpRtSgp0lr0NpuYqb2hbZsgb 6hYgbAeXILIA8DwZ2yHa/+lTWO+aesV9j7exMlhQBlNl+kanOrK5P6PD72NGN6iRCF3B 5cBlns6SfJwQT3aCgq7q9+e2ocFRGBsD5vvjM= 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=fwPuLOZX/o8vjqlDCVTFY15+P0fnQe7CE6TakilvlE8=; b=i+1gA31BDF9p6IIx/PftzUGBZnQ71rtOxc1BrglUJTu4yvq2tlglRsQRvOobdR82qL 2XflhEzUM7/5BSEAX6NnghwXZ0Go7vh77S2Tb1ZHbUrJ67lPR+wRBz7r80K/Lq0PQNjm Z4OPYl8UOaLQLFPLVz8rpN/JQQJaJCoddTaDN/PYGcyHYfHc9BVOcEEddnw5LUEj8QT+ VCoJBCO95T9B+2APGv8rmPMlI0EZOFuqIlNiQ+7CsGr0bWqNY9vhwb7i7szuFlDiJTew 0hXgAMOO9BbG8MQ2x9erN9UNyBqrmKtwBXerrhZcTMjOtjcgkF5RLmA7QPK7p7Rk0+zJ 9BqQ== X-Gm-Message-State: APjAAAUjeVecezHsfG8gdn8SSvs7V4aBvpMtj4lSk4lZHlGOVNp7ibnl 8Z/CU4WsCK9ZUCt6LymeQvTsXmTVkH4= X-Received: by 2002:a62:cec7:: with SMTP id y190mr997401pfg.191.1580168080344; Mon, 27 Jan 2020 15:34:40 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id s22sm173971pji.30.2020.01.27.15.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2020 15:34:39 -0800 (PST) Date: Mon, 27 Jan 2020 15:34:38 -0800 From: Kees Cook To: "H.J. Lu" Cc: linux-kernel@vger.kernel.org, Andy Lutomirski , Thomas Gleixner , Thomas Lendacky , Sami Tolvanen , Heiko Carstens , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, Yu-cheng Yu Subject: Re: [PATCH 2/2] x86: Discard .note.gnu.property sections in vmlinux Message-ID: <202001271531.B9ACE2A@keescook> References: <20200124181819.4840-1-hjl.tools@gmail.com> <20200124181819.4840-3-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200124181819.4840-3-hjl.tools@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 24, 2020 at 10:18:19AM -0800, H.J. Lu wrote: > 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 linker script only contains a signle 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 > ... > } > > which may not be incompatible with note.gnu.property sections. Since > note.gnu.property section in kernel image is unused, this patch discards > .note.gnu.property sections in kernel linker script by adding > > /DISCARD/ : { > *(.note.gnu.property) > } I think this is happening in the wrong place? Shouldn't this be in the DISCARDS macro in include/asm-generic/vmlinux.lds.h instead? > before .notes sections. Since .exit.text and .exit.data sections are > discarded at runtime, it undefines EXIT_TEXT and EXIT_DATA to exclude > .exit.text and .exit.data sections from default discarded sections. This looks like a separate issue (though maybe related to DISCARDS)? -Kees > > Signed-off-by: H.J. Lu > Signed-off-by: Yu-cheng Yu > --- > arch/x86/kernel/vmlinux.lds.S | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S > index 3a1a819da137..6c6cc26b0177 100644 > --- a/arch/x86/kernel/vmlinux.lds.S > +++ b/arch/x86/kernel/vmlinux.lds.S > @@ -150,6 +150,11 @@ SECTIONS > _etext = .; > . = ALIGN(PAGE_SIZE); > > + /* .note.gnu.property sections should be discarded */ > + /DISCARD/ : { > + *(.note.gnu.property) > + } > + > X86_ALIGN_RODATA_BEGIN > RO_DATA(PAGE_SIZE) > X86_ALIGN_RODATA_END > @@ -413,6 +418,12 @@ SECTIONS > STABS_DEBUG > DWARF_DEBUG > > + /* Sections to be discarded. EXIT_TEXT and EXIT_DATA discard at runtime. > + * not link time. */ > +#undef EXIT_TEXT > +#define EXIT_TEXT > +#undef EXIT_DATA > +#define EXIT_DATA > DISCARDS > /DISCARD/ : { > *(.eh_frame) > -- > 2.24.1 > -- Kees Cook