lkml.org 
[lkml]   [2020]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm/gup.c: Handling ERR within unpin_user_pages()
On Mon, Sep 14, 2020 at 07:20:34AM +0530, Souptick Joarder wrote:
> On Sun, Sep 13, 2020 at 8:25 PM Matthew Wilcox <willy@infradead.org> wrote:
> >
> > On Sun, Sep 13, 2020 at 08:02:35PM +0530, Souptick Joarder wrote:
> > > It is possible that a buggy caller of unpin_user_pages()
> > > (specially in error handling path) may end up calling it with
> > > npages < 0 which is unnecessary.
> > > @@ -328,6 +328,9 @@ void unpin_user_pages(struct page **pages, unsigned long npages)
> > > {
> > > unsigned long index;
> > >
> > > + if (WARN_ON_ONCE(npages < 0))
> > > + return;
> >
> > But npages is unsigned long. So it can't be less than zero.
>
> Sorry, I missed it.
>
> Then, it means if npages is assigned with -ERRNO by caller, unpin_user_pages()
> may end up calling a big loop, which is unnecessary.

How will a caller allocate memory of the right size and still manage
to call with the wrong npages? Do you have an example of a broken caller?

Jason

\
 
 \ /
  Last update: 2020-09-14 16:09    [W:0.052 / U:0.380 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site