[lkml]   [2009]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [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

 \ /
  Last update: 2009-08-24 17:59    [W:0.079 / U:1.232 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site