Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7041157ybi; Thu, 13 Jun 2019 08:35:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5GL9lOJleO+eSKu4gNhpBwy7Sa8ZBxBviKeuoak2DpCUM4d7cakp82j6esW7pM3wZIL52 X-Received: by 2002:a17:902:d88e:: with SMTP id b14mr36919785plz.153.1560440103871; Thu, 13 Jun 2019 08:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560440103; cv=none; d=google.com; s=arc-20160816; b=BqacMzGUoWhmPq3UWm/EEtRY2KuH8fwh/fbTHhVpQheqBjFvtmafHoTijc+zNHBTBz YBoAah4kzQhYMaxwhMWfyPm93Fqnik96IdyB+RlCS6v5NmqyeX/4TvenU6/NpyVJPlXX MD9yAcsFwNi6Iniepa+647hv1T0O+UYzp7TyITfSd8vcxy5VC10LKUZ7x5PgML9JYEeZ wdafdy6o2DA6MPbNRnATfzJLReb4yafZWMaBTilTyeONI1Blmm9FvRVScdS/ZthizWdE Ie5bQ0qI6bAnxnYoWtNP3coow04UjBj9l+FgfA1jlx6gXOVrI2k/aatV2VljbNnu1bqH E+Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=r080oZfzTGw4PlNPynE57ID3Ar9Ahtv7iL/o1sb0dx0=; b=m521OOPcPFqDe7ZWFAORU2HZcEt9BcVmmjshbmUR1b6D56lvUCq6Lh76bLUaWbH3yf 4L7rCBG5KsZ/62uqjGu2OyUxk2j3eqR43Qshw7W/x6YwgkSSqHd55wxbzPc0OXdvlOCk pqTjBLtp0NDB1ew/W80Pxvs1mAQcPD84+XrwEDYTxPE+XgErjAK2bXFWr7sgJq4qbFCM rNFQThBdMWsflPW++zogKYIla242YledOX5vO5NKxClVpDVKdWXc9LvRtH/hlnfATaHP 0hf2Z3Gyve5qM26TAF9yECj/4iFs7VRtug7nV/9CEfBxqWFXFO7qZYfiHSzAG9tUBh95 blmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ea1jZnIt; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 206si94052pga.414.2019.06.13.08.34.47; Thu, 13 Jun 2019 08:35:03 -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=@gmail.com header.s=20161025 header.b=ea1jZnIt; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729075AbfFMPcd (ORCPT + 99 others); Thu, 13 Jun 2019 11:32:33 -0400 Received: from mail-io1-f54.google.com ([209.85.166.54]:36735 "EHLO mail-io1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726817AbfFMKs1 (ORCPT ); Thu, 13 Jun 2019 06:48:27 -0400 Received: by mail-io1-f54.google.com with SMTP id h6so15819034ioh.3 for ; Thu, 13 Jun 2019 03:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=r080oZfzTGw4PlNPynE57ID3Ar9Ahtv7iL/o1sb0dx0=; b=ea1jZnItELWGPu6bHxAH/mmHocHpLmDlCmmIL2DjSC0Sx7VqH0Ol3gF4IcXRnmg9yM aWTdWeTpwVEK5N9uUKAIwBKzkS7fWKmfEIRb4V668/k38X++IMjsYMDuE8rpvMNrJuD9 SClkbjfnhXP8mup6eWm/jU0ElYl3JLd+TbWXANcbeoSguFsZy3w4qGPngJy267Wcejx5 187akwnOcJwaH/eSOVrX0sKBU0vjA0jroIvFe1D6BMipVWVj5sRIyhYESsYCEq6n5n0J xj2uKE6W4zMuksq/Co6nd2kNVQRx/U0czve+f4jvbuPoLaM87hVgS5WovV2HN3YRdQqk RO4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=r080oZfzTGw4PlNPynE57ID3Ar9Ahtv7iL/o1sb0dx0=; b=tMJhGGJLCmSbvHwvqd+zKN1nMPI5w/jV2vGYgR27XEardGEVuhWj93i8Z0Pt5qpvXs X2/cZ3MZu3enW9hWY53GzXFoJIll370uqdEjVAnpB+mNQoKrcXXV5gjSnvQHmkyLa3r5 kTjbsVocXA5QQmPQRw9x9XJc0EmsTd5yddH17LFuOk3Nh61rjKOJ46mVf2zv6wTOVkPs kz/oqF7413wnrRsnj+eh3za20Y2Wy5PZCOjzN8bgCFi+K0RheOC0z7ug9LasS+bfTdoW ezsdZZXdxRIw6Jy9zfyTkM0zTpHzymgllzghBrDt6JT3sYMlU6U6MWGL72eB0mq66hsj ZCXQ== X-Gm-Message-State: APjAAAUydCS8f9TCvIqc3erBWWwQ2xcocUGDq/Aqc4QBTImyAFU9dExI ekG+49S4V6Kta3xnCgAXWJ18kJQuZHWrV0gGDg== X-Received: by 2002:a6b:4107:: with SMTP id n7mr10681260ioa.12.1560422905974; Thu, 13 Jun 2019 03:48:25 -0700 (PDT) MIME-Version: 1.0 References: <1559725820-26138-1-git-send-email-kernelfans@gmail.com> <87tvcwhzdo.fsf@linux.ibm.com> <2807E5FD2F6FDA4886F6618EAC48510E79D8D79B@CRSMSX101.amr.corp.intel.com> <20190612135458.GA19916@dhcp-128-55.nay.redhat.com> <20190612235031.GF14336@iweiny-DESK2.sc.intel.com> In-Reply-To: <20190612235031.GF14336@iweiny-DESK2.sc.intel.com> From: Pingfan Liu Date: Thu, 13 Jun 2019 18:48:14 +0800 Message-ID: Subject: Re: [PATCHv3 1/2] mm/gup: fix omission of check on FOLL_LONGTERM in get_user_pages_fast() To: Ira Weiny Cc: "Aneesh Kumar K.V" , "linux-mm@kvack.org" , Andrew Morton , Mike Rapoport , "Williams, Dan J" , Matthew Wilcox , John Hubbard , "Busch, Keith" , Christoph Hellwig , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 13, 2019 at 7:49 AM Ira Weiny wrote: > > On Wed, Jun 12, 2019 at 09:54:58PM +0800, Pingfan Liu wrote: > > On Tue, Jun 11, 2019 at 04:29:11PM +0000, Weiny, Ira wrote: > > > > Pingfan Liu writes: > > > > > > > > > As for FOLL_LONGTERM, it is checked in the slow path > > > > > __gup_longterm_unlocked(). But it is not checked in the fast path= , > > > > > which means a possible leak of CMA page to longterm pinned requir= ement > > > > > through this crack. > > > > > > > > Shouldn't we disallow FOLL_LONGTERM with get_user_pages fastpath? W= .r.t > > > > dax check we need vma to ensure whether a long term pin is allowed = or not. > > > > If FOLL_LONGTERM is specified we should fallback to slow path. > > > > > > Yes, the fastpath bails to the slowpath if FOLL_LONGTERM _and_ DAX. = But it does this while walking the page tables. I missed the CMA case and = Pingfan's patch fixes this. We could check for CMA pages while walking the= page tables but most agreed that it was not worth it. For DAX we already = had checks for *_devmap() so it was easier to put the FOLL_LONGTERM checks = there. > > > > > Then for CMA pages, are you suggesting something like: > > I'm not suggesting this. OK, then I send out v4. > > Sorry I wrote this prior to seeing the numbers in your other email. Give= n > the numbers it looks like performing the check whilst walking the tables = is > worth the extra complexity. I was just trying to summarize the thread. = I > don't think we should disallow FOLL_LONGTERM because it only affects CMA = and > DAX. Other pages will be fine with FOLL_LONGTERM. Why penalize every ca= ll if > we don't have to. Also in the case of DAX the use of vma will be going > away...[1] Eventually... ;-) A good feature. Trying to catch up. Thanks, Pingfan