Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp187420imu; Thu, 10 Jan 2019 21:33:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN4iAqnrLIkpEmtmeas/SN5lUz9U4WcS5p9k/scG19rQN8y72k4IyhmJqrUgrn8wZCpZ6fgH X-Received: by 2002:a65:4ccb:: with SMTP id n11mr12294062pgt.257.1547184813290; Thu, 10 Jan 2019 21:33:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547184813; cv=none; d=google.com; s=arc-20160816; b=CF5I4VrtyoEK2BgJ3ltb365Hp2BwNyfxjMKKEp+eovIwd1OrJ+eh7IiMrXDE9R2+Iq lQdY/1zgrbOSOJ/nIEGM6f/n6TkqjMrrjvV5Uq/fjWGXzmN3F8NsJC91tfas6TLlh47l Tcg8JlX9ar28O1br6EP+hStkltA6egKEIPopt6XJt7mRKBBqRbWHSG0ttll+PmXTY0Cp Q52ynOJScT4h5cA4YzfMuzip2RJ1bVhACDVnMp7QFFIkWbg8dP7P6JXAiqeyC8nTVXJV XIwDGyHhsMxtkXJP2ZvFV4csvtW8klSBy0RSd8xNeWfmndUff3VaxVV32FHPtHu7daZ0 fpfw== 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=iZE9SSCEjdXC/Vakrfytkc401eZDD/Q32H+TKwekhoM=; b=gAv07DR97IyR3Biq7IaK7FKvJ+/dhBXuuQq2+FfJfmohU26gWVS29KpGSTmvOWYM/k j0Uj0YrX3vKaJV8n13C4Z46eQ4INf23kGnjKesICto1+seSRykjqasyo4Ee6ZPFffwN+ tURoOQ3FJUi8WtsMh/RUg9Iajw0diw+mE0piejyw+Odd+VYc9YKWaXAF5tbX8EEj2kHj K9tjBosogNBMwcOk00+YtVxaljbFQ7obJbJYP86/TU1wrqrvtZ4OPq8Sjmm4KtyIfnSK UioU/l2D46bg4VVdPAjYsUoS85wWcnes7ZUInlbO08p0SjWPSzd7s5Seaat6rwKk90/O crvA== 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 i63si15053876pgc.116.2019.01.10.21.33.16; Thu, 10 Jan 2019 21:33:33 -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 S1729413AbfAKEEr (ORCPT + 99 others); Thu, 10 Jan 2019 23:04:47 -0500 Received: from ipmail06.adl2.internode.on.net ([150.101.137.129]:56140 "EHLO ipmail06.adl2.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728129AbfAKEEr (ORCPT ); Thu, 10 Jan 2019 23:04:47 -0500 Received: from ppp59-167-129-252.static.internode.on.net (HELO dastard) ([59.167.129.252]) by ipmail06.adl2.internode.on.net with ESMTP; 11 Jan 2019 14:34:36 +1030 Received: from dave by dastard with local (Exim 4.80) (envelope-from ) id 1gho3f-0003Sa-1b; Fri, 11 Jan 2019 15:04:35 +1100 Date: Fri, 11 Jan 2019 15:04:35 +1100 From: Dave Chinner To: Linus Torvalds Cc: Dominique Martinet , Jiri Kosina , Matthew Wilcox , Jann Horn , 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: <20190111040434.GN27534@dastard> References: <20190109043906.GF27534@dastard> <20190110004424.GH27534@dastard> <20190110070355.GJ27534@dastard> <20190110122442.GA21216@nautica> <20190111020340.GM27534@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 Thu, Jan 10, 2019 at 06:18:16PM -0800, Linus Torvalds wrote: > On Thu, Jan 10, 2019 at 6:03 PM Dave Chinner wrote: > > > > On Thu, Jan 10, 2019 at 02:11:01PM -0800, Linus Torvalds wrote: > > > And we *can* do sane things about RWF_NOWAIT. For example, we could > > > start async IO on RWF_NOWAIT, and suddenly it would go from "probe the > > > page cache" to "probe and fill", and be much harder to use as an > > > attack vector.. > > > > We can only do that if the application submits the read via AIO and > > has an async IO completion reporting mechanism. > > Oh, no, you misunderstand. > > RWF_NOWAIT has a lot of situations where it will potentially return > early (the DAX and direct IO ones have their own), but I was thinking > of the one in generic_file_buffered_read(), which triggers when you > don't find a page mapping. That looks like the obvious "probe page > cache" case. > > But we could literally move that test down just a few lines. Let it > start read-ahead. > > .. and then it will actually trigger on the *second* case instead, where we have > > if (!PageUptodate(page)) { > if (iocb->ki_flags & IOCB_NOWAIT) { > put_page(page); > goto would_block; > } > > and that's where RWF_MNOWAIT would act. > > It would still return EAGAIN. > > But it would have started filling the page cache. So now the act of > probing would fill the page cache, and the attacker would be left high > and dry - the fact that the page cache now exists is because of the > attack, not because of whatever it was trying to measure. > > See? Except for fadvise(POSIX_FADV_RANDOM) which triggers this code in page_cache_sync_readahead(): /* be dumb */ if (filp && (filp->f_mode & FMODE_RANDOM)) { force_page_cache_readahead(mapping, filp, offset, req_size); return; } So it will only read the single page we tried to access and won't perturb the rest of the message encoded into subsequent pages in file. Cheers, Dave. -- Dave Chinner david@fromorbit.com