Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6512836yba; Tue, 14 May 2019 08:46:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtEZwUnUFUiTSv6NcMUIeyixrCqgr4U+E68WMOQ5g9Zjgu+XZAQ1uXsPAUz/FD6aU2r3c4 X-Received: by 2002:a17:902:5acb:: with SMTP id g11mr37514786plm.198.1557848775458; Tue, 14 May 2019 08:46:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557848775; cv=none; d=google.com; s=arc-20160816; b=0pqXPBxzWstVq6/1y0wV+ECg9YKyUoX0oxtOTxixzwbL6kYUURdJyTr9CmfIYoxybn WiiLU0FFPzR5QSQVCkTVKod/TESdA5dpLC/4BTcpgG3W8i+rEO89TsiMuOYKQHNOvmcP YdjX1+5KP9IjKlaIUhSfdwMY7Y49+8qt4Rrq+t7laT64yH0TZnFB2Lj3LJbsw2hmaA4l 88ddA/+Cow5ViozxBSgM0LnNuIPNXLNr3DkUdNXliPI84+lDWCP8V//f3WdGOLoqYtu/ QYddfAVtNlZawYnIfsBuGEeY0tMRKB1rWINw2UejBXFeAiPExWUWp2jBeTlCIktuzHOt JW/Q== 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=a+kzP7bTSrlqs6pxiIkhPgzkbpOEzOvI/LVVdexE6gA=; b=dSQL5SUYJU3yIc5fPfzXiVcnJdir6modXbsomBkQBCp2vpenf+XfKfBpNXTArWL/Jh 6ooj7+rdhN8+15y4sVOIFUlRd9OmlWu1VXWPXbQbMZBxt14vlsDxlgvrLGa+O3yyHm3d ErLugzyam7GrN/Viot3cWBVON2w758XeRU9JDEZ3O0A3wy7EeTTatS0xj5jM2uhr9j05 L0CZm5vmEhyi6xZqj1E8mXiDeBZeQ0Ky+JXouYpEz/i1vbuvBkb6XzoR+vK72Rlm3/V4 svcmrcUqwFzXtyVxcvdaF1W+NsgQ9DRTTNqcjGKHiibEvQk6iA4yna07okaKcnV09o3q 380Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NmEJgE98; 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 k15si21516927pfi.61.2019.05.14.08.46.00; Tue, 14 May 2019 08:46:15 -0700 (PDT) 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=NmEJgE98; 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 S1726281AbfENPnW (ORCPT + 99 others); Tue, 14 May 2019 11:43:22 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:46319 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725901AbfENPnW (ORCPT ); Tue, 14 May 2019 11:43:22 -0400 Received: by mail-pg1-f193.google.com with SMTP id t187so8815443pgb.13 for ; Tue, 14 May 2019 08:43:21 -0700 (PDT) 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=a+kzP7bTSrlqs6pxiIkhPgzkbpOEzOvI/LVVdexE6gA=; b=NmEJgE98WryIUtsub6GRiQIiyIsE2uwPAreI69Pj4fx4ojw38vOcHXKjmFyjBBfiiG thRok67oRcIMUQwR25v4IQ9agD0nPS6lCTLMk10ghl9oWnjMQra/JzrXqV3GxUIUvtz/ zLEkWIBMhRjDJpPnAmIAL8zF2uH8A7phi5uFI= 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=a+kzP7bTSrlqs6pxiIkhPgzkbpOEzOvI/LVVdexE6gA=; b=EPabsEc5vr64nGpJ/37RpynLwJdpBbqsb3RopNUz92e/+dE/4GKnTVE2EMJAGJHnXP SpYpdsqogYeWr6G1te7jd2Jpigqt14+s+2OvAqlyh/RR+PaYZuNSuNKUEuNe7r40mytB pzoB7apDVO8mlW5RJ3HU64b5cSnGPEzX12BywsWBDtyk6Lo47WQwfTbGicw2qnKWZFx7 44A3bGGr6JBGG20ZlYScjfPMqfm0y2DQVOGbRS4SgfFqVHandgwFUO27+gyi6dWLT3ia YvR40T8FyEAwQ+IMBXh0wBEdNY/L2vUT+bU9lX2L0+8aKmAtEGKz+sQOUJ1bOzKPXL6w UJ3Q== X-Gm-Message-State: APjAAAXwlNABu/H6ygFUjIHCdGxo5Hr72nFRM/C/LpGuL9h8PmMaD7K4 y50zlhjpPeYHwvmTaVeBZO4ogA== X-Received: by 2002:a63:5742:: with SMTP id h2mr38531680pgm.194.1557848601184; Tue, 14 May 2019 08:43:21 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g19sm18095082pgj.75.2019.05.14.08.43.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 May 2019 08:43:20 -0700 (PDT) Date: Tue, 14 May 2019 08:43:19 -0700 From: Kees Cook To: Johannes Hirte Cc: Borislav Petkov , Sami Tolvanen , linux-kernel@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH] x86/build: Move _etext to actual end of .text Message-ID: <201905140842.21066115C5@keescook> References: <20190423183827.GA4012@beast> <20190514120416.GA11736@probook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190514120416.GA11736@probook> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 14, 2019 at 02:04:21PM +0200, Johannes Hirte wrote: > On 2019 Apr 23, Kees Cook wrote: > > When building x86 with Clang LTO and CFI, CFI jump regions are > > automatically added to the end of the .text section late in linking. As a > > result, the _etext position was being labelled before the appended jump > > regions, causing confusion about where the boundaries of the executable > > region actually are in the running kernel, and broke at least the fault > > injection code. This moves the _etext mark to outside (and immediately > > after) the .text area, as it already the case on other architectures > > (e.g. arm64, arm). > > > > Reported-and-tested-by: Sami Tolvanen > > Signed-off-by: Kees Cook > > --- > > arch/x86/kernel/vmlinux.lds.S | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S > > index bad8c51fee6e..de94da2366e7 100644 > > --- a/arch/x86/kernel/vmlinux.lds.S > > +++ b/arch/x86/kernel/vmlinux.lds.S > > @@ -141,11 +141,11 @@ SECTIONS > > *(.text.__x86.indirect_thunk) > > __indirect_thunk_end = .; > > #endif > > - > > - /* End of text section */ > > - _etext = .; > > } :text = 0x9090 > > > > + /* End of text section */ > > + _etext = .; > > + > > NOTES :text :note > > > > EXCEPTION_TABLE(16) :text = 0x9090 > > -- > > 2.17.1 > > This breaks the build on my system: > > RELOCS arch/x86/boot/compressed/vmlinux.relocs > CC arch/x86/boot/compressed/early_serial_console.o > CC arch/x86/boot/compressed/kaslr.o > AS arch/x86/boot/compressed/mem_encrypt.o > CC arch/x86/boot/compressed/kaslr_64.o > Invalid absolute R_X86_64_32S relocation: _etext > make[2]: *** [arch/x86/boot/compressed/Makefile:130: arch/x86/boot/compressed/vmlinux.relocs] Error 1 > make[2]: *** Deleting file 'arch/x86/boot/compressed/vmlinux.relocs' > make[2]: *** Waiting for unfinished jobs.... > make[1]: *** [arch/x86/boot/Makefile:112: arch/x86/boot/compressed/vmlinux] Error 2 > make: *** [arch/x86/Makefile:283: bzImage] Error 2 Interesting! Can you send along your .config and compiler details? -- Kees Cook