From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3EFFC433E2 for ; Thu, 3 Sep 2020 07:23:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 99AC020737 for ; Thu, 3 Sep 2020 07:23:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="CCWZt9gQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 99AC020737 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0B6246B0002; Thu, 3 Sep 2020 03:23:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 03E3B8E0001; Thu, 3 Sep 2020 03:23:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E74A76B0037; Thu, 3 Sep 2020 03:23:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id D1A1D6B0002 for ; Thu, 3 Sep 2020 03:23:35 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9348F1EF1 for ; Thu, 3 Sep 2020 07:23:35 +0000 (UTC) X-FDA: 77220909990.24.mom18_3305ec7270a7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 6896D1A4A5 for ; Thu, 3 Sep 2020 07:23:35 +0000 (UTC) X-HE-Tag: mom18_3305ec7270a7 X-Filterd-Recvd-Size: 4714 Received: from hqnvemgate24.nvidia.com (hqnvemgate24.nvidia.com [216.228.121.143]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Thu, 3 Sep 2020 07:23:34 +0000 (UTC) Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 03 Sep 2020 00:21:24 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Thu, 03 Sep 2020 00:23:33 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Thu, 03 Sep 2020 00:23:33 -0700 Received: from [10.2.53.12] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 3 Sep 2020 07:23:24 +0000 Subject: Re: [PATCH] mm/gup: don't permit users to call get_user_pages with FOLL_LONGTERM To: Souptick Joarder CC: Barry Song , Andrew Morton , Linux-MM , , , Jan Kara , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , "Matthew Wilcox (Oracle)" , Al Viro , Christoph Hellwig , "Dan Williams" , Dave Chinner , Jason Gunthorpe , Jonathan Corbet , "Michal Hocko" , Mike Kravetz , Shuah Khan , Vlastimil Babka References: <20200819110100.23504-1-song.bao.hua@hisilicon.com> From: John Hubbard Message-ID: <14e62718-a8fc-f41d-7c4a-2767cbd65c7b@nvidia.com> Date: Thu, 3 Sep 2020 00:23:24 -0700 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: X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1599117684; bh=jUExDbKjqVqcLv5dEUKCzQYjKag+aQT+X4HUSyIZ59Y=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=CCWZt9gQTcL+N+ivitisGhKJUdlkj/dUkQ8rWWwJecO2vZw4RUHdwbxS7+FGai+pr RetiQgJNalU/IEYNdhyfJazILE3UvbU8M5OiwImK/WM1dqTq58SB1o/9EyrAzdvJcp MuK9xqXBmY2LYEzH9njFrAEw3CAj1jYnkhnu7G7/fRbXw3OVSLkBP0Vt8Dil7FRsnf So24/WkIVnBFtgLZw2MBbXjK0sGytFmNoeC10dGfAhcOxjKghcoUrK6k0H9gDaGibi OI+pNDesCV5UxwnU0UXci+H/pBkfqPGrZYWtB4CCVOsaH48vY3j1bUvZIe4BeJe1BH Lut0/zwgDU7lA== X-Rspamd-Queue-Id: 6896D1A4A5 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 9/3/20 12:12 AM, Souptick Joarder wrote: > On Wed, Aug 19, 2020 at 11:45 PM John Hubbard wrote: >> >> On 8/19/20 4:01 AM, Barry Song wrote: >>> gug prohibits users from calling get_user_pages() with FOLL_PIN. But it >> >> Maybe Andrew can fix the typo above: gug --> gup. >> >> >>> allows users to call get_user_pages() with FOLL_LONGTERM only. It seems >>> insensible. >>> >>> since FOLL_LONGTERM is a stricter case of FOLL_PIN, we should prohibit >>> users from calling get_user_pages() with FOLL_LONGTERM while not with >>> FOLL_PIN. >>> >>> mm/gup_benchmark.c used to be the only user who did this improperly. >>> But it has been fixed by moving to use pin_user_pages(). >> >> For future patches, you don't have to write everything in the >> commit log. Some things are better placed in a cover letter or after >> the "---" line, because they don't need to be recorded forever. >> >> Anyway, the diffs seem fine, assuming that you've audited the call sites. > > We can use is_valid_gup_flags() inside -> > get_user_pages_locked(), > get_user_pages_unlocked(), > pin_user_pages_locked() as well. Probably it's best to discern between valid pup flags, and valid gup flags. As in: separate functions for those. Maybe one is a subset of the other, but still. > > Are you planning to add it in future patches ? > It's not on my list. I don't see anything wrong with doing so, other than avoiding the minor pitfall I called out above. So if you want to do that, then feel free... thanks, -- John Hubbard NVIDIA