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] [day] [month] [year] [list]
Date:   Sat, 2 May 2020 03:16:40 +0530
From:   Souptick Joarder <jrdr.linux@...il.com>
To:     John Hubbard <jhubbard@...dia.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Linux-MM <linux-mm@...ck.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/gup.c: Handle error at earliest for incorrect nr_pages value

On Sat, May 2, 2020 at 3:03 AM John Hubbard <jhubbard@...dia.com> wrote:
>
> On 2020-04-30 13:11, Souptick Joarder wrote:
> > As per documentation, pin_user_pages_fast() & get_user_pages_fast()
> > will return 0, if nr_pages <= 0. But this can be figure out only after
> > going inside the internal_get_user_pages_fast().
> >
> > This can be handled early. Adding a check for the same.
>
>
> Please, no. For precisely the reasons that Andrew gave: you are
> attempting to optimize for a case that doesn't matter other than
> for error handling, and which is already handled adequately. And
> as he also pointed out, it very slightly UN-optimizes the path that
> we *do* care about. So why are you still advocating for this?
>
> If you want to change the gup/pup API so that asking for zero pages
> means -EINVAL, then fine, go for it. That's a large thing, and a
> tree-wide audit, but if you feel it's worth pursuing then it's at
> least consistent.
>
> But this patch here needs to be abandoned.

Sure, will drop this patch.
>
>
> thanks,
> --
> John Hubbard
> NVIDIA
>
> >
> > Signed-off-by: Souptick Joarder <jrdr.linux@...il.com>
> > ---
> >   mm/gup.c | 4 ++++
> >   1 file changed, 4 insertions(+)
> >
> > diff --git a/mm/gup.c b/mm/gup.c
> > index 50681f0..a13aaa6 100644
> > --- a/mm/gup.c
> > +++ b/mm/gup.c
> > @@ -2817,6 +2817,8 @@ int get_user_pages_fast(unsigned long start, int nr_pages,
> >        */
> >       if (WARN_ON_ONCE(gup_flags & FOLL_PIN))
> >               return -EINVAL;
> > +     if (nr_pages <= 0)
> > +             return 0;
> >
> >       /*
> >        * The caller may or may not have explicitly set FOLL_GET; either way is
> > @@ -2854,6 +2856,8 @@ int pin_user_pages_fast(unsigned long start, int nr_pages,
> >       /* FOLL_GET and FOLL_PIN are mutually exclusive. */
> >       if (WARN_ON_ONCE(gup_flags & FOLL_GET))
> >               return -EINVAL;
> > +     if (nr_pages <= 0)
> > +             return 0;
> >
> >       gup_flags |= FOLL_PIN;
> >       return internal_get_user_pages_fast(start, nr_pages, gup_flags, pages);
> >
>

Powered by blists - more mailing lists