Re: [PATCH v3 2/2] slub: Add method to verify memory is notfreed.

From: Christoph Lameter
Date: Thu Jul 07 2011 - 14:48:57 EST


On Thu, 7 Jul 2011, greearb@xxxxxxxxxxxxxxx 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@xxxxxxxxx>

--
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/