[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1251129384.22398.7166.camel@nimitz>
Date: Mon, 24 Aug 2009 08:56:24 -0700
From: Dave Hansen <dave@...ux.vnet.ibm.com>
To: David Rientjes <rientjes@...gle.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org
Subject: Re: [patch 3/4 -mm] flex_array: poison free elements
On Fri, 2009-08-21 at 16:21 -0700, David Rientjes wrote:
>
> diff --git a/include/linux/poison.h b/include/linux/poison.h
> --- a/include/linux/poison.h
> +++ b/include/linux/poison.h
> @@ -65,6 +65,9 @@
> #define MUTEX_DEBUG_INIT 0x11
> #define MUTEX_DEBUG_FREE 0x22
>
> +/********** lib/flex_array.c **********/
> +#define FLEX_ARRAY_FREE 0x6c /* for use-after-free poisoning */
This seems like a good idea, but perhaps we should pick a non-ASCII
character as the poison value. If someone ever tried to store strings
as one-byte elements, they'd be in for a rude awakening the first time
they store an 'l'.
Or, maybe we should just disable poisoning if the elements are 4 bytes
or less. Or, perhaps the minimum element size should just be 4 bytes
and we have a 4-byte poison value.
The other alternative is to just use '\0' as the cleared value. We
won't be able to track whether accesses in the middle of the array are
valid, but we can at least always shrink the array with no fear of
misdetection of the poison value. That also rids us of some of the
logic around GFP_ZERO and the poisoning that is a bit confusing.
Do you think it is confusing that passing GFP_ZERO will keep you from
doing a shrink unless you do a clear for all of the allocated data?
Should we expose some of the functions so that users can tell if what
was allocated precisely?
-- Dave
--
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