Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1631660ybv; Thu, 6 Feb 2020 07:14:50 -0800 (PST) X-Google-Smtp-Source: APXvYqyiI7ipnSGBiwskSgSnanxL1PJ/QGkB/jyxWl0D1iVgWXHFUSrHr7pPTxsjFkhd45chKbw0 X-Received: by 2002:a05:6830:231d:: with SMTP id u29mr31540585ote.185.1581002089887; Thu, 06 Feb 2020 07:14:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581002089; cv=none; d=google.com; s=arc-20160816; b=P0wq74zJ12c0gL2YuzH5NT8urYrTcWT/KgBhjqA/9kAoq+6R0MdZnmtvPwN443St5l HKxuyIXolsJ/sTMAMjZTgfSYUmKFUDX+ogmfTX/yW5qmDlzPjABvaAzWqh3XIhHCHbNt 38/VHIrTNLWuw+D0FQOO/Svg3bqBarP6Eb1x2a/+7EQwXCwxl34v+6qn3DKIDQJ5PTMl kaW3bFjK97KCbNZY09pWhHIlct25EtC8Aa1bbbG9E/fHPsTng0PC1BBcQBcSWJOhsRAl gIUgXt1denB0hGbUuZYDRtBMP9UamI5dkjBI7bMAI+nRiROU41oAYcBafSgq+kGSfXs5 DxVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qAWbALPQo8/7ZJiptwDEhRrrdBNpEoxar+lbkVRuAXo=; b=wizYNjS9J/1IQ0+m0sp4nz2zDtllmWMAOeSJj2nPhQ8o1VVhih/t/8LVwVBgK8UbSs sx7kCRRW5FGwha6lZuHyUYExNHTZJ558NTmIly/dKdLGLNbvWCTP4vsShquRvW2p+FKA Dv3YSRm+Fg61Ht4NJeqlKZQL2PftCG6sXoJVh48jXRMc/TIiChGOtLao96ipXWEuKToJ yyvW5sOsex7q8F4Zb6AJl0+9+eKOGEUtnFPOeb84GWJQz5id6+30FAcAbd1T8j9V0fti qJ11H3YQkirtVu672zROisGu8kVFrazo49lfa5x4QprEy8bYMwZ814mfR0Gvsh2KVw4W ubTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=kkG5AvKq; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14si1927070otn.118.2020.02.06.07.14.37; Thu, 06 Feb 2020 07:14:49 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=kkG5AvKq; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727502AbgBFPLy (ORCPT + 99 others); Thu, 6 Feb 2020 10:11:54 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:37516 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727522AbgBFPLn (ORCPT ); Thu, 6 Feb 2020 10:11:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=qAWbALPQo8/7ZJiptwDEhRrrdBNpEoxar+lbkVRuAXo=; b=kkG5AvKqs7FgbTx1sDRnpdMTZc BzBObTMElPe+LuKQATTxfQxOvzCr3lBLeGAPdfZafBDKaD6N+Fky8AcloGDTeDfemb1S9o3tCt5b5 VkwP0brh0w4wzD18UdcrDhuClv2L6gzwKCJLEFR+ZbYALVSceI2+qwGF0tgRyP2yTuGegFc9hv7iI bgoJ8j2XLkrtmkg5E3CXbXjDyKxQUox1dMxnAmCa9sFuohwnzWxKUz7Cg5bLsKE/M7Q6PPhlYZuh0 15zhBPgDeNPdYUSxuBsvE53LMnBRjYeWXa9LizeXtRg8Wz9V9+7J1SjVOs4mK/e9B1qCad6uZ6vD7 l+u1K4uQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iziWV-0004zG-P7; Thu, 06 Feb 2020 14:52:55 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id DC8623016E5; Thu, 6 Feb 2020 15:51:06 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 549F42B811ED7; Thu, 6 Feb 2020 15:52:53 +0100 (CET) Date: Thu, 6 Feb 2020 15:52:53 +0100 From: Peter Zijlstra To: Kees Cook Cc: Kristen Carlson Accardi , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, arjan@linux.intel.com, rick.p.edgecombe@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: Re: [RFC PATCH 08/11] x86: Add support for finer grained KASLR Message-ID: <20200206145253.GT14914@hirez.programming.kicks-ass.net> References: <20200205223950.1212394-1-kristen@linux.intel.com> <20200205223950.1212394-9-kristen@linux.intel.com> <20200206103830.GW14879@hirez.programming.kicks-ass.net> <202002060356.BDFEEEFB6C@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202002060356.BDFEEEFB6C@keescook> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 06, 2020 at 04:06:17AM -0800, Kees Cook wrote: > On Thu, Feb 06, 2020 at 11:38:30AM +0100, Peter Zijlstra wrote: > > On Wed, Feb 05, 2020 at 02:39:47PM -0800, Kristen Carlson Accardi wrote: > > > +static long __start___ex_table_addr; > > > +static long __stop___ex_table_addr; > > > +static long _stext; > > > +static long _etext; > > > +static long _sinittext; > > > +static long _einittext; > > > > Should you not also adjust __jump_table, __mcount_loc, > > __kprobe_blacklist and possibly others that include text addresses? > > These don't appear to be sorted at build time. The ORC tables are though: 57fa18994285 ("scripts/sorttable: Implement build-time ORC unwind table sorting") > AIUI, the problem with > ex_table and kallsyms is that they're preprocessed at build time and > opaque to the linker's relocation generation. I was under the impression these tables no longer had relocation data; that since they're part of the main kernel, the final link stage could completely resolve them. That said, I now see we actually have .rela__extable .rela.orc_unwind_ip etc. > For example, looking at __jump_table, it gets sorted at runtime: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/jump_label.c#n474 For now, yes. Depends a bit on how hard people are pushing on getting jump_labels working earlier and ealier in boot. > As you're likely aware, we have a number of "special" > sections like this, currently collected manually, see *_TEXT: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/vmlinux.lds.S#n128 Right. > I think we can actually add (most of) these to fg-kaslr's awareness (at > which point their order will be shuffled respective to other sections, > but with their content order unchanged), but it'll require a bit of > linker work. I'll mention this series's dependency on the linker's > orphaned section handling in another thread... I have some patches pending where we rely on link script order. That's data sections though, so I suppose that's safe for the moment.