Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2129206ybl; Thu, 30 Jan 2020 11:52:55 -0800 (PST) X-Google-Smtp-Source: APXvYqzlVx3Fm92j/ErGxImuwf2NlU+o6ic0jO9SEXJE3T9d5jeq7e698//PXo6Xe2qm5vXsdx/R X-Received: by 2002:a05:6808:9b4:: with SMTP id e20mr3828404oig.37.1580413975182; Thu, 30 Jan 2020 11:52:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580413975; cv=none; d=google.com; s=arc-20160816; b=F57slVfE33vXxP60U8o3mmFhf50Y1hBbEpyPpfwfWAJseE5haS9oKGUxaszaF203ne 0LL5dM5olClh8mPy1DU+s+LN7BeJ9YAyEn/uZuYttjMUlcrd75JLC85BvH6RtxNZXrcX uwPfBDnO5e/md0a8EllkBNDZowmeEzhJnznm2ylpNjKHmdhJAK79uGRdc6cd5XCb2ZYz qbmb9VTfg99625FEUdSRx4egoasx8GddWkZsRCTdxJ2NwfqDJs6Te5PcYiRu2yNkSWeB ltozzzHOCvxToT/9F3f8vx55T6dfQdqfyrs1a4CRYf2+0ZURA0X/32nfG0AeW/SgYLdu iEfA== 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=TwjNbXymeOMhcl0LSyYVyfzACL3qLvRJ0ybZ68hQvaU=; b=g+TUNRejdrixmqoIZyi6wQkzdDtQJbeso2vdW/xf8BZYAQsOeX44Td8pATZnSA8kUQ 1QXRyptakmBjlvrg4IiJUTsyadymMxgSIvryoXu+doz+dAJWZvOIMaex/AU0fP8U1hCM SvIVtnEjcDLXIOmLl7lk1OI+Th+UI8cnLYokkoRKRC0N2s8W/pnR3EYjZjZtAeql64PB bBoW2zZXahxUBbNZtN34fECt7zt1xM2sJ9ih1vayFcqZPjjVtZmwhzeJO8RS+DQR5Z5s qqVxPPeU5KkOU95MEeSgi4a1P8KPjTIDr7ykuQb/eayoX80o3RT4KeasmmeTSrX8c43u 23Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=QQLpki6M; 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 i8si3176550oih.206.2020.01.30.11.52.40; Thu, 30 Jan 2020 11:52:55 -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=QQLpki6M; 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 S1727538AbgA3TvR (ORCPT + 99 others); Thu, 30 Jan 2020 14:51:17 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45792 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726267AbgA3TvQ (ORCPT ); Thu, 30 Jan 2020 14:51:16 -0500 Received: by mail-pl1-f193.google.com with SMTP id b22so1729038pls.12 for ; Thu, 30 Jan 2020 11:51:16 -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=TwjNbXymeOMhcl0LSyYVyfzACL3qLvRJ0ybZ68hQvaU=; b=QQLpki6MkN8PIxiN6Hz8Og58+QkkAVx/FfxeMuJaKICMKQuTkLkt08YKUjO15mTgvW hT8KtRFTuu+a8GmAzda75+NlKxKvclPjN3i/aw4X+euWpL9P3ov30l3ZXOz+C5WjpQeN Zi9eBmiT92RN3SglclboI4ukVWG4/oZyVf9oA= 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=TwjNbXymeOMhcl0LSyYVyfzACL3qLvRJ0ybZ68hQvaU=; b=W/bXqKCutv1hfVjddO14Hb+D3Qlqk7A1a4DqyPq8ZemUMZBbC5FwvZGY1Q2yBgAP43 30jvvNU52Vil5RYJgFHgtKiqrUDVc/DGgaPldhNORH99Og3RM9FthngnM4bXIHYyPmD6 dRdn+EYAz0NedRoDwQOWW/QvDD8XAkfN20DPHLWzaFsftabAw9mc9kdaJEXajJWuUBB9 Mm+lRj+69HmGPHmDgcv85fzrkwEDxWoJeUeLtC2DdnjBRUZk5nfxjwJM3Q+bcpYUGtHW uvKD/qi77ViRJU7mhlNkTJ/tCvc5LOwz2JmV3lxPmIU4rMjLue3rIaTKc7ZhkYE6T7Fv j+JA== X-Gm-Message-State: APjAAAUcFL/qR1Pz6sZqmX/PzSpi4mU697NH9LL9KnVOm7NUjqFHKPcY iDNZ0KQ+hQkhfGb1FvVgI0yrwA== X-Received: by 2002:a17:902:9a8f:: with SMTP id w15mr6630467plp.30.1580413875978; Thu, 30 Jan 2020 11:51:15 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 2sm7197678pgo.79.2020.01.30.11.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 11:51:15 -0800 (PST) Date: Thu, 30 Jan 2020 11:51:14 -0800 From: Kees Cook To: "H.J. Lu" Cc: LKML , Andy Lutomirski , Thomas Gleixner , Thomas Lendacky , Sami Tolvanen , Heiko Carstens , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , the arch/x86 maintainers , Yu-cheng Yu Subject: Re: [PATCH 2/2] x86: Discard .note.gnu.property sections in vmlinux Message-ID: <202001301143.288B55DCC1@keescook> References: <20200124181819.4840-1-hjl.tools@gmail.com> <20200124181819.4840-3-hjl.tools@gmail.com> <202001271531.B9ACE2A@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 30, 2020 at 09:51:38AM -0800, H.J. Lu wrote: > On Mon, Jan 27, 2020 at 3:34 PM Kees Cook wrote: > > > > 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 I don't understand this. "may not be incompatible"? Is there an error generated? If so, what does it look like? > > > 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? > > Please read my commit message closely. We can't discard .note.gnu.property > sections by adding .note.gnu.property to default discarded sections > since default > discarded sections are placed AFTER .notes sections in x86 kernel > linker scripts. I see what you mean now, /DISCARD/ happens after the NOTES macro (now in the RO_DATA macro). To this end, I think this should be in include/asm-generic/vmlinux.lds.h in the NOTES macro? It's x86-specific right now, but why not make this future-proof? I'd like to avoid as much arch-specific linker stuff as we can. I spent a lot of time trying to clean up NOTES specifically. :) > + /* .note.gnu.property sections should be discarded */ This comment should say _why_ -- the script already shows _what_ is happening... > + /DISCARD/ : { > + *(.note.gnu.property) > + } -Kees -- Kees Cook