lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d11d52f8-d54c-bb45-bde9-198235a03921@nvidia.com>
Date:   Sun, 31 May 2020 12:52:21 -0700
From:   John Hubbard <jhubbard@...dia.com>
To:     Souptick Joarder <jrdr.linux@...il.com>
CC:     Andrew Morton <akpm@...ux-foundation.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Linux-MM <linux-mm@...ck.org>
Subject: Re: [PATCH 1/2] mm/gup: introduce pin_user_pages_locked()

On 2020-05-31 00:04, Souptick Joarder wrote:
...
>> +/*
>> + * pin_user_pages_locked() is the FOLL_PIN variant of get_user_pages_locked().
>> + * Behavior is the same, except that this one sets FOLL_PIN and rejects
>> + * FOLL_GET.
>> + */
>> +long pin_user_pages_locked(unsigned long start, unsigned long nr_pages,
>> +                          unsigned int gup_flags, struct page **pages,
>> +                          int *locked)
>> +{
>> +       /*
>> +        * FIXME: Current FOLL_LONGTERM behavior is incompatible with
>> +        * FAULT_FLAG_ALLOW_RETRY because of the FS DAX check requirement on
>> +        * vmas.  As there are no users of this flag in this call we simply
>> +        * disallow this option for now.
>> +        */
>> +       if (WARN_ON_ONCE(gup_flags & FOLL_LONGTERM))
>> +               return -EINVAL;
>> +
>> +       /* FOLL_GET and FOLL_PIN are mutually exclusive. */
>> +       if (WARN_ON_ONCE(gup_flags & FOLL_GET))
>> +               return -EINVAL;
>> +
>> +       gup_flags |= FOLL_PIN;
> 
> Right now get_user_pages_locked() doesn't have similar check for FOLL_PIN

Yes, that should be added...

> and also not setting FOLL_GET internally irrespective of gup_flags
> passed by user.
> Do we need to add the same in get_user_pages_locked() ?

...and no, that should not.

Yes, it's prudent to assert that FOLL_PIN is *not* set, at all the
get_user_pages*() API calls, thanks for spotting that. I'll add that to
this patch and send out a v2.

The same check should also be added to get_user_pages_unlocked(). I'll send
out a correction (I think just a v3 of that patchset) to add that.

The setting of FOLL_GET, on the other hand, is something best left as-is
so far. Some call sites set FOLL_GET, some want it *not* set, and some
expect that FOLL_GET is implied, and at the moment, the delicate balance is
correct. :)


thanks,
-- 
John Hubbard
NVIDIA

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ