[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.1107010909060.2458@router.home>
Date: Fri, 1 Jul 2011 09:11:31 -0500 (CDT)
From: Christoph Lameter <cl@...ux.com>
To: Ben Greear <greearb@...delatech.com>
cc: penberg@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/2] slub: Add method to verify memory is not
freed.
On Tue, 28 Jun 2011, greearb@...delatech.com wrote:
> diff --git a/include/linux/slab.h b/include/linux/slab.h
> index ad4dd1c..916ce0f 100644
> --- a/include/linux/slab.h
> +++ b/include/linux/slab.h
> @@ -302,6 +302,19 @@ extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
>
> #endif /* CONFIG_NUMA */
>
> +/**
> + * Calling this on allocated memory will check that the memory
> + * is expected to be in use, and print warnings if not.
> + */
> +#if defined(CONFIG_SLUB) && defined(CONFIG_SLUB_DEBUG)
> +extern bool verify_mem_not_deleted(const void *x);
> +#else
> +static inline bool verify_mem_not_deleted(const void *x)
> +{
> + return true;
> +}
> +#endif
> +
Why is this in slab.h and not slub_def.h?
> diff --git a/mm/slub.c b/mm/slub.c
> index 3477ce5..f64caca 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -2958,6 +2958,42 @@ size_t ksize(const void *object)
> }
> EXPORT_SYMBOL(ksize);
>
> +#ifdef CONFIG_SLUB_DEBUG
> +bool verify_mem_not_deleted(const void *x)
> +{
> + 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? */
> + rv = true;
> + goto out_unlock;
> + }
The above check is problematic for slabs that have SLAB_DESTROY_BY_RCU
set. PageSlab(page) may be true to the next rcu interval.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists