Messages in this thread | | | Subject | Re: [patch 3/4 -mm] flex_array: poison free elements | From | Dave Hansen <> | Date | Mon, 24 Aug 2009 08:56:24 -0700 |
| |
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
| |