lkml.org 
[lkml]   [2011]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 2/2] slub: Add method to verify memory is not freed.
On Thu, 7 Jul 2011, greearb@candelatech.com wrote:

> + struct page *page;
> + void *object = (void *)x;
> + unsigned long flags;
> + bool rv;
> +
> + if (unlikely(ZERO_OR_NULL_PTR(x)))
> + return false;
> +
> + local_irq_save(flags);
> +
> + page = virt_to_head_page(x);
> + if (unlikely(!PageSlab(page))) {
> + /* maybe it was from stack? */

Or it is a compound page that was used because the allocation was larger
than an order 2 alloc. Same result though.

> + rv = true;
> + goto out_unlock;
> + }
> +
> + slab_lock(page);
> + if (on_freelist(page->slab, page, object)) {
> + object_err(page->slab, page, object, "Object is on free-list");
> + rv = false;
> + } else {
> + rv = true;
> + }
> + slab_unlock(page);
> +
> +out_unlock:
> + local_irq_restore(flags);
> + return rv;
> +}
> +EXPORT_SYMBOL(verify_mem_not_deleted);
> +#endif
> +
> void kfree(const void *x)
> {
> struct page *page;
>

Acked-by: Christoph Lameter <cl@linux.com>



\
 
 \ /
  Last update: 2011-07-07 20:51    [W:0.036 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site