Re: [PATCH 1/2] Introduce check_readable_bytes()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux