Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp254124imu; Tue, 8 Jan 2019 19:09:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN4d1Iw9qpWMvrFbfOG2hz6cTjUbm22W5Hb8DtSkzTZyYODVaLjAmxSO8WxmVRfu2dRmaJEO X-Received: by 2002:a17:902:8484:: with SMTP id c4mr4240236plo.59.1547003367957; Tue, 08 Jan 2019 19:09:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547003367; cv=none; d=google.com; s=arc-20160816; b=D4lxtoJp2Ne9Ksbn8S0neFK7fxL1d+mpXDWe65tt7lOOBe7lJATJS3skpxU2o6AGID q7TTItvsxuyqukk+5gpP/NLNz8c/Qv23rWalGFNYw5e6SZ5wupARqie5HjSSBL2INAVk 1WBDF1uyaRlx/Ix9tJDXiOq8K+i9isLgOcjTi+2IpMZFpOjoXZW1YHEinhq7Z6BM/V8x +qVqXwVkP1IgY6pNk7+ZIcFthkupKyhKg4BcMtKXMYhtx8wMnQqjQxpuwOZztkoSJClB 1LU+Gw7LEy1evPum/I48jUk1nqIpa9p2KKX+X7PCGACUMKKNLg0bd+tlp8Yguj7pQiCa PTlQ== 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; bh=qIyrfM7SVvLzPs7NLJUXp8G2q4E//CdwUn+Y0E30l4E=; b=VxHTQb122BXnMiuv1iN48o6g8EpqjllonC3BHk4TPGgvjDwsOuinccwfhH1rW7uOiK zFEkbi/E/uVaxgl3TPu5UbcCE+JP8p/P2x6jgbqwQNsurvqLht2KSFBpRdHwEd3Sqau5 Ed7E7H2tjcCUf2KBOqsqec+XidRXGB93ZfPKhHwM0MzQv834hdcBQBxSo2P/TEfL0OCx Qo1+Tey3mzo2zN413OXPxfl5mv7Q+0cUNa3sxpAlhMRqjnaAPl4kWtdvJm76GKc7OPfM kF94g6wUPQ6KYWeIg5ZvbrdJpWQV8IEJvmUxWqLGMcdNVYXKIXEMDQ8uPWMZKEZvzr63 OEjw== ARC-Authentication-Results: i=1; mx.google.com; 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 o10si18532886pls.76.2019.01.08.19.09.01; Tue, 08 Jan 2019 19:09:27 -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; 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 S1729191AbfAICYf (ORCPT + 99 others); Tue, 8 Jan 2019 21:24:35 -0500 Received: from ipmail07.adl2.internode.on.net ([150.101.137.131]:24420 "EHLO ipmail07.adl2.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728253AbfAICYe (ORCPT ); Tue, 8 Jan 2019 21:24:34 -0500 Received: from ppp59-167-129-252.static.internode.on.net (HELO dastard) ([59.167.129.252]) by ipmail07.adl2.internode.on.net with ESMTP; 09 Jan 2019 12:54:31 +1030 Received: from dave by dastard with local (Exim 4.80) (envelope-from ) id 1gh3Xi-0000Ox-8Y; Wed, 09 Jan 2019 13:24:30 +1100 Date: Wed, 9 Jan 2019 13:24:30 +1100 From: Dave Chinner To: Linus Torvalds Cc: Matthew Wilcox , Jann Horn , Jiri Kosina , Andrew Morton , Greg KH , Peter Zijlstra , Michal Hocko , Linux-MM , kernel list , Linux API Subject: Re: [PATCH] mm/mincore: allow for making sys_mincore() privileged Message-ID: <20190109022430.GE27534@dastard> References: <20190106001138.GW6310@bombadil.infradead.org> <20190108044336.GB27534@dastard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 08, 2019 at 09:57:49AM -0800, Linus Torvalds wrote: > On Mon, Jan 7, 2019 at 8:43 PM Dave Chinner wrote: > > > > So, I read the paper and before I was half way through it I figured > > there are a bunch of other similar page cache invalidation attacks > > we can perform without needing mincore. i.e. Focussing on mmap() and > > mincore() misses the wider issues we have with global shared caches. > > Oh, agreed, and that was discussed in the original report too. > > The thing is, you can also depend on our pre-faulting of pages in the > page fault handler, and use that to get the cached status of nearby > pages. So do something like "fault one page, then do mincore() to see > how many pages near it were mapped". See our "do_fault_around()" > logic. Observing fault-around could help you detect what code an application is running, but it's not necessary (and can be turned off). Also, such an it observation is not dependent on using mincore. neither fault-around nor mincore are required functionality to exploit the information leaks. And, FWIW, fault-around actually destroys the information in the exfiltration channel described in the paper because it perturbs the carefully constructed page cache residency pattern that encodes the message. > But mincore is certainly the easiest interface, and the one that > doesn't require much effort or setup. Off the top of my head, here's a few vectors for reading the page cache residency state without perturbing the page cache residency pattern: - mincore - preadv2(RWF_NOWAIT) - fadvise(POSIX_FADV_RANDOM); timed read(2) syscalls - madvise(MADV_RANDOM); timed read of first byte in each page i.e. mincore is a messenger, but it's not the only trivial observation technique available. The only difference between mincore and the others will be the observation latency and hence channel bandwidth. IOWs, the question we need to focus on now is not "does breaking mincore affect anyone", it is "how the hell do we mitigate and isolate an information leak exposed by fundamental OS functionality that *everything* depends on for performance"? > It's also the one where our old > behavior was actually arguably simply stupid and actively wrong (ie > "in caches" isn't even strictly speaking a valid question, since the > caches in question may be invalid). This is irrelevant to the problem reported. Sure, mincore may be an awful interface, but it's semantics are not the cause of the information leak. You're just shooting the messenger... > I do think that the RWF_NOWAIT case might also be interesting to look at. As are all the other mechanisms you can use to observer page cache residency without perturbing it's state. Keep in mind that the researchers documented a remote observation technique that leaked the information across the network to a remote host, so this leak has much, much wider scope than changing mincore can address... Cheers, Dave. -- Dave Chinner david@fromorbit.com