Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2931195pxb; Sun, 8 Nov 2020 19:40:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwxG867/SqRErte3IjcNQjQwGtqRk1NpntZ8lMtMBlZXNcCgUKfqOZaGgkXkPZI1hXxgD6 X-Received: by 2002:a17:906:60d4:: with SMTP id f20mr13853053ejk.156.1604893205048; Sun, 08 Nov 2020 19:40:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604893205; cv=none; d=google.com; s=arc-20160816; b=EwyjVCXimGO0m7y/jVZXkcRgYDawZ4qUGEhumDIGjyVWr4E/7goqvEJlgDw63dQ6Bw Uggyg1ZMTa5xDKYz2PpmnecHHpG8Qbo2ya6HwH3EnxZnm0ONtqrBF2jMPcOhVdGzykjt 08luZBECbxB2+QS4hwl+bBu+GOKQO+Ig3a4OXyFrUZ+A+LAs4Ds7elofCSx3ntGxfRhf M5VWoAV4uxFoMA81t9asNv6+Dg0LDWLS3OhAGI7Uu3cW44qqdHpTblQzbNxbV5m4+Yuz AZ8kR2eu2nMt/MqVLDHNgSYuTJyY+oA2W6UawcvUA/B1m929bLVgFwodzkIKHquVxAAp ikIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rMA/ceEW9wS4NZVZe5iS6l5M0I/ugt4xfY3l5BFcub8=; b=qFIRKgN9lroyvSqIciyJlGEknI8AhjQdlTU50iT/qRAlfspKwQC/9gIjW0aMNtyNHc b5I1SEXOxyUmcUm59Z4XG39WwmDlMVxJKmHhOmFIr6G4FCGfMEtZK3nzVQtloXEq3pv5 v++XSgRZAeb8I60IzMJcKVEJBZbpp5wzM8Q0fGCZxuK0+JNo3EueTcFwQlxfNDKN/Zb/ XdknZfcXrSkWt/nN2E8sKJHOwC4UOaKSqFsZfsB9gAnXaoOlaEUui1lH0g3Qyh4OFWal u3BAq5PN4qlZFqWyA6K9qJa0GbZOcYo66OoM9xsqOwNQoQ9zQZNMF8XvXNSfRY90QuhY VVpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cQaSW0rV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id u10si7014909edp.411.2020.11.08.19.39.42; Sun, 08 Nov 2020 19:40:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cQaSW0rV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1729184AbgKIDhH (ORCPT + 99 others); Sun, 8 Nov 2020 22:37:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728038AbgKIDhH (ORCPT ); Sun, 8 Nov 2020 22:37:07 -0500 Received: from mail-vs1-xe43.google.com (mail-vs1-xe43.google.com [IPv6:2607:f8b0:4864:20::e43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BF06C0613CF; Sun, 8 Nov 2020 19:37:07 -0800 (PST) Received: by mail-vs1-xe43.google.com with SMTP id t8so4204951vsr.2; Sun, 08 Nov 2020 19:37:07 -0800 (PST) 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; bh=rMA/ceEW9wS4NZVZe5iS6l5M0I/ugt4xfY3l5BFcub8=; b=cQaSW0rVF4BrsPoBDU3Oa2BOCBbIrkgaNKhzq1pLo+G6KL4XPxC1p5ClouJiYwEuVz 2IacpRUOGvUlw71hukSQLGsXagL/Bmvg2jRZsMDtfmxRAhFGYD8LybFk3dOFT5rXIW+N HJjwLU83wtw7klTQMFJhYawndSUKAfQ9KcDURCJyKfWh+/8P377+HOmoGA6cHpZBfYTo lKNw1wRmx3h6U/C1ReGwT64lpG8II5FCh7Zefu2DgfYPjhz4DOndLpFvvFzVayIZzAuV CAE8nW0TYJ3HLD+o/5KTXP5k87lzIrbF1lf4pHlPt5zX98Rsft4qoqR5r4OdoU/2ZbLI 09Uw== 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; bh=rMA/ceEW9wS4NZVZe5iS6l5M0I/ugt4xfY3l5BFcub8=; b=AFsHA2QJvWl+bB1taJeXo1/X1VRFR0ww0HiiPZkhWHK66nMMVjB1vUDNWyva1EvPLA ouijaiCTAr0Ob7W3QVYdpRagDwBjBAS6T3m4ERZQU7mYwRzkqK9gr6gSx1Ycaeg+8/8d cVBfLAn0FtM/JeVNHToFYOQ9c+EBR4Ta/xewqzw3PqwHPuF3JpSmKoWkMLUkyCQY2SQ/ 90Q5NkpyOENkJ5MSqg72wd6kO7Z5Bw26ubmPmL1+awzqwewHkN/QflmuQ+dVl0Npz5mr MUhtV95kRUr9Lf0+9OG41xcCCNjxAv9fwfe+oyDmtakK9XESKY4eeYMx92xw71YWUQPC ne+g== X-Gm-Message-State: AOAM531hCF/LEfQT4LZkzAe87Sks5XwlmK1odtIZVudv81qUefSV/XM8 +MEuuR5jXTT35+tuvvRmiE7iOSakHjIWUMz2PEs= X-Received: by 2002:a05:6102:671:: with SMTP id z17mr7021650vsf.32.1604893026248; Sun, 08 Nov 2020 19:37:06 -0800 (PST) MIME-Version: 1.0 References: <1604737451-19082-1-git-send-email-jrdr.linux@gmail.com> <5efeb909-3e02-ba14-7a86-f18562a2fe69@i-love.sakura.ne.jp> <8590eb4c-256b-9ab0-5291-de8ec8d75276@nvidia.com> In-Reply-To: <8590eb4c-256b-9ab0-5291-de8ec8d75276@nvidia.com> From: Souptick Joarder Date: Mon, 9 Nov 2020 09:06:54 +0530 Message-ID: Subject: Re: [PATCH 1/2] tomoyo: Convert get_user_pages*() to pin_user_pages*() To: John Hubbard Cc: Tetsuo Handa , linux-security-module , linux-kernel@vger.kernel.org, Jan Kara , Matthew Wilcox , James Morris , "Serge E. Hallyn" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 8, 2020 at 7:47 AM John Hubbard wrote: > > On 11/7/20 5:13 PM, Tetsuo Handa wrote: > > On 2020/11/08 4:17, John Hubbard wrote: > >> On 11/7/20 1:04 AM, John Hubbard wrote: > >>> On 11/7/20 12:24 AM, Souptick Joarder wrote: > >>>> In 2019, we introduced pin_user_pages*() and now we are converting > >>>> get_user_pages*() to the new API as appropriate. [1] & [2] could > >>>> be referred for more information. This is case 5 as per document [1]. > >>> > >>> It turns out that Case 5 can be implemented via a better pattern, as long > >>> as we're just dealing with a page at a time, briefly: > >>> > >>> lock_page() > >>> write to page's data > >>> unlock_page() > >>> > >>> ...which neatly synchronizes with writeback and other fs activities. > >> > >> Ahem, I left out a key step: set_page_dirty()! > >> > >> lock_page() > >> write to page's data > >> set_page_dirty() > >> unlock_page() > >> > > > > Excuse me, but Documentation/core-api/pin_user_pages.rst says > > "CASE 5: Pinning in order to _write_ to the data within the page" > > while tomoyo_dump_page() is for "_read_ the data within the page". > > Do we want to convert to pin_user_pages_remote() or lock_page() ? > > > > Sorry, I missed the direction here, was too focused on the Case 5 > aspect. Yes. Case 5 (which, again, I think we're about to re-document) > is only about *writing* to data within the page. > > So in this case, where it is just reading from the page, I think it's > already from a gup vs pup point of view. > > btw, it's not clear to me whether the current code is susceptible to any > sort of problem involving something writing to the page while it > is being dumped (I am curious). But changing from gup to pup wouldn't > fix that, if it were a problem. It a separate question from this patch. > > (Souptick, if you're interested, the Case 5 documentation change and > callsite retrofit is all yours if you want it. Otherwise it's on > my list.) Sure John, I will take it.