Re: [RFC v3 2/5] slab: implement slab object boundaries assertion

From: Vasiliy Kulikov
Date: Thu Jul 21 2011 - 14:14:09 EST


On Thu, Jul 21, 2011 at 11:28 -0500, Christoph Lameter wrote:
> On Thu, 21 Jul 2011, Vasiliy Kulikov wrote:
>
> > +bool slab_access_ok(const void *ptr, unsigned long len)
> > +{
> > + struct page *page;
> > + struct kmem_cache *s = NULL;
>
> Useless assignment.
>
> > + unsigned long offset;
> > +
> > + if (!virt_addr_valid(ptr))
> > + return true;
> > + page = virt_to_head_page(ptr);
> > + if (!PageSlab(page))
> > + return true;
> > +
> > + s = page->slab;
> > + offset = (ptr - page_address(page)) % s->size;
> > + if (offset <= s->objsize && len <= s->objsize - offset)
> > + return true;
>
> I thought this was going to be offset < s->objectsize ...?

Looks like I did these 2 things in SLAB only, left SLUB untouched.
Will fix, thanks.

--
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/