Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp333027pxk; Thu, 3 Sep 2020 00:25:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrS2DGhSgJ1fajdS54av/wyrHiUhtHs72RL1nBiTxVjFDech7Pn52m0N1lypTTE7MQ6gGb X-Received: by 2002:a05:6402:1c07:: with SMTP id ck7mr1761252edb.84.1599117908031; Thu, 03 Sep 2020 00:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599117908; cv=none; d=google.com; s=arc-20160816; b=vCP49iCjZtrEfNMQ4ZnggnoiMlwWae/p+2bnrd3KdCbX+zvOV7Jjx2fhi9rAYlFMyB YqkXoN0MtRZNKb8qpiLZ4T80zdteBDUWccLeSyd707wi4o4odSBM+Vkv+pDfQJnC0EKV 55MyhlLoZr6Nofmf57m36NtjzzFY8cPgi7xbO16NgoTIQFCra5dxVl0Z3o1IgGDcJDS4 tHFO44a7pazfnf4XCzfsjzIDmpA0ZS6RrMlEx7nzEmAg3wcOOpEByDEwmSW9OncX35+7 UmRBHu/+WB26O3kg5DSWvUlkTXTHks68MU/8ZZ2m7nwy4nNLHbfTMApqVi9W+NcgYhkH 6gYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=jUExDbKjqVqcLv5dEUKCzQYjKag+aQT+X4HUSyIZ59Y=; b=UgmNfcQVbBWdoquXiUSRwUGm7wmIG9GhZl6AHt4KfTvvskh/+vpMrCT5idhL3H38JU cgtRbGEsgJ0NcYj73zmC6KKovG58I67ZXrC4OIpHOLEnmmU0oOx0x8idxZ87U+AcpbSl OtHart/ax4XrC3EXFW4NZp1KaTtAfQYGsz4cq9igsvHe6LNCb1ddSOofL7CinfTxK7vz S7RL/hBBrP2q6bvtz1d7Y+aeJxAqWKBItjl0sEO009R3s7YPRWvjIk++8y4JptepQZLD jq4mUzxSr1uclpWScGBedILojqngtHbI3xt3n3emXFSzjlTv8WBI5VnF2CuR4iO9YSYs 0JeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=CCWZt9gQ; 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 ds5si1475785ejc.703.2020.09.03.00.24.45; Thu, 03 Sep 2020 00:25:08 -0700 (PDT) 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=CCWZt9gQ; 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 S1728032AbgICHXh (ORCPT + 99 others); Thu, 3 Sep 2020 03:23:37 -0400 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:19279 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbgICHXf (ORCPT ); Thu, 3 Sep 2020 03:23:35 -0400 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== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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