Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1864174pxb; Sat, 7 Nov 2020 01:06:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxredhURY46aET9QRa8of1kabqFbnnqBIrWHRL5TDRNJE0YhqWwlLBCJI5KqjAdVUEHwu60 X-Received: by 2002:a17:906:519e:: with SMTP id y30mr5729142ejk.186.1604739997685; Sat, 07 Nov 2020 01:06:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604739997; cv=none; d=google.com; s=arc-20160816; b=dtl9YqE+xISPOW0wi3ErXMd4mcAS8V0VITEtsOgNt1CEwQGn/v7XSOqn7HWrBti82Z 0drXfekNkr07VV5zVnc2eAbazheeFl5pefFqRZxm96I7Yg2jV71fYdT1ZhylQooyFAyJ iBOK3dznkMqBmG8IYoDVRy73dnSRxbM9bGZVft6mOt1Nf8EFsGTe90wm4jc4NAcgxaxP Yb3iL8sPxROUHwOiaAJKXu5IHkP7q9Q4QD9hv+d/+yzjWIaWAGl4UeyWpXxCcWJDvisb eCsibQd4o6miichq/bVTwTwtKwUJxBrNWzyLsNpNs4YwZt4QzbXYJjZCG0NfNaZunUVH gmYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=f8+saql79WUV7L5gLMVpGfAw9HSYkhJovfzxVrV8yD8=; b=gDxnlILKeM3f5DhCiJV4XlL2sCKrCZO1r3jpVR8bxTHp8yjtzLjR32+TTWczAhIeAG nzFZunRX9UBczQrUah+iVA04yes1r7+Gp1M8BhaYcxhUcl0rwKmZw2esYkI8xdBdCzfI v4YzRxpa/LtLOMKoRQJ0hoVZqSC5DEhwZip3N4L9CvijW1XqcybK+5wPr7nl7z2WE8Sd ccw4s9FvL7+YhXv0acRXE2enqpr7mQXYR3r/ijxVOFRN9nUa6ghhoarK4n2twpUOdhv8 RC2mrziASAUbfEbPVfYRRuoCdj3z7oD9ogHglZ9WUPw3tqyoC3QIDBZ4uN+geWqkdTtz vPDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=eF1vq7rK; 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=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bl19si2737360ejb.301.2020.11.07.01.06.15; Sat, 07 Nov 2020 01:06:37 -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=@nvidia.com header.s=n1 header.b=eF1vq7rK; 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=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728106AbgKGJEw (ORCPT + 99 others); Sat, 7 Nov 2020 04:04:52 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:10055 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727973AbgKGJEv (ORCPT ); Sat, 7 Nov 2020 04:04:51 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Sat, 07 Nov 2020 01:04:54 -0800 Received: from [10.2.49.167] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sat, 7 Nov 2020 09:04:50 +0000 Subject: Re: [PATCH 1/2] tomoyo: Convert get_user_pages*() to pin_user_pages*() To: Souptick Joarder , , , , CC: , , Jan Kara , Matthew Wilcox References: <1604737451-19082-1-git-send-email-jrdr.linux@gmail.com> From: John Hubbard Message-ID: Date: Sat, 7 Nov 2020 01:04:50 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <1604737451-19082-1-git-send-email-jrdr.linux@gmail.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1604739894; bh=f8+saql79WUV7L5gLMVpGfAw9HSYkhJovfzxVrV8yD8=; h=Subject:To:CC:References:From:Message-ID:Date:User-Agent: MIME-Version:In-Reply-To:Content-Type:Content-Language: Content-Transfer-Encoding:X-Originating-IP:X-ClientProxiedBy; b=eF1vq7rKYFI6buH8AXG3THsWAlBxpIRNEgZZfdzdzkm25+SlgZznBSPScwXxE5WcI 3/73IpS6+6ThBd9E0JS0yc2FXMmwix3VqQQiUDYpfswJ999hGH44JNUSTAm28s5nkL 4cIDZd/enhtOxmdu3OEkH1FmqLEAAkh2NSmE4U3JuT4i1IK7FGdUMhTRqjLYBXss4h kKYIrrOYYoOKywMK60+E4mtDMvajf9KVgj17BWusydioS7HqU6+iLiZZyQF6NSAqZO B8rixL5iEPNfX6U2Rhn20SY8Qn1wIg/FEXi4fIOpIQjBebbI6MX3+HfHQoKc5XCNpC pn67CI8azA/vA== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. I was going to track down the Case 5's and do that [1]. +CC Jan and Matthew, to keep us on the straight and narrow, just in case I'm misunderstanding something. [1] https://lore.kernel.org/r/e78fb7af-627b-ce80-275e-51f97f1f3168@nvidia.com thanks, -- John Hubbard NVIDIA > > [1] Documentation/core-api/pin_user_pages.rst > > [2] "Explicit pinning of user-space pages": > https://lwn.net/Articles/807108/ > > Signed-off-by: Souptick Joarder > Cc: John Hubbard > --- > security/tomoyo/domain.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/security/tomoyo/domain.c b/security/tomoyo/domain.c > index dc4ecc0..bd748be 100644 > --- a/security/tomoyo/domain.c > +++ b/security/tomoyo/domain.c > @@ -914,7 +914,7 @@ bool tomoyo_dump_page(struct linux_binprm *bprm, unsigned long pos, > * (represented by bprm). 'current' is the process doing > * the execve(). > */ > - if (get_user_pages_remote(bprm->mm, pos, 1, > + if (pin_user_pages_remote(bprm->mm, pos, 1, > FOLL_FORCE, &page, NULL, NULL) <= 0) > return false; > #else > @@ -936,7 +936,7 @@ bool tomoyo_dump_page(struct linux_binprm *bprm, unsigned long pos, > } > /* Same with put_arg_page(page) in fs/exec.c */ > #ifdef CONFIG_MMU > - put_page(page); > + unpin_user_page(page); > #endif > return true; > } >