lkml.org 
[lkml]   [2009]   [May]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] Introduce check_readable_bytes()
At Thu, 14 May 2009 13:40:09 -0400, Josef Bacik wrote:

> > + volatile char c;
> > + int ret = 0;
> > + long page_begin = (unsigned long)uaddr & PAGE_MASK;
> > + long page_end = ((unsigned long)uaddr + size) & PAGE_MASK;
> > + long ptr = page_begin;
> > +
>
> Firstly page_begin/page_end/ptr should all be unsigned long. Secondly page_end
> should be uaddr+size-1.
>
> > + if (unlikely(size == 0))
> > + goto out;
> > +
> > + while (!ret && ptr <= page_end) {
> > + ret = __get_user(c, (const char __user*)ptr);
> > + if (!ret)
> > + ptr += PAGE_SIZE;
> > + }
> > +
> > + if (likely(!ret))
> > + ret = size;
> > + else
> > + ret = (ptr == page_begin) ?
> > + -EFAULT : (const char __user *)ptr - uaddr;
>
> This isn't quite right either, we do some pointer math, and return that and its
> casted as an int? That seems like a bad idea in general. Thanks,

Did you like the approach in general?

--
wbr, Vitaly


\
 
 \ /
  Last update: 2009-05-14 20:01    [W:0.243 / U:0.756 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site