This is a note to let you know that I've just added the patch titled
flex_arrays: allow zero length flex arrays
to the 2.6.38-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
flex_arrays-allow-zero-length-flex-arrays.patch
and it can be found in the queue-2.6.38 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.
>From bf69d41d198138e3c601e9a6645f4f1369aff7e0 Mon Sep 17 00:00:00 2001
From: Eric Paris <[email protected]>
Date: Thu, 28 Apr 2011 15:55:52 -0400
Subject: flex_arrays: allow zero length flex arrays
From: Eric Paris <[email protected]>
commit bf69d41d198138e3c601e9a6645f4f1369aff7e0 upstream.
Just like kmalloc will allow one to allocate a 0 length segment of memory
flex arrays should do the same thing. It should bomb if you try to use
something, but it should at least allow the allocation.
This is needed because when SELinux switched to using flex_arrays in 2.6.38
the inability to allocate a 0 length array resulted in SELinux policy load
returning -ENOSPC when previously it worked.
Based-on-patch-by: Steffen Klassert <[email protected]>
Signed-off-by: Eric Paris <[email protected]>
Tested-by: Chris Richards <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
lib/flex_array.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
--- a/lib/flex_array.c
+++ b/lib/flex_array.c
@@ -253,9 +253,16 @@ int flex_array_prealloc(struct flex_arra
unsigned int end;
struct flex_array_part *part;
+ if (!start && !nr_elements)
+ return 0;
+ if (start >= fa->total_nr_elements)
+ return -ENOSPC;
+ if (!nr_elements)
+ return 0;
+
end = start + nr_elements - 1;
- if (start >= fa->total_nr_elements || end >= fa->total_nr_elements)
+ if (end >= fa->total_nr_elements)
return -ENOSPC;
if (elements_fit_in_base(fa))
return 0;
@@ -346,6 +353,8 @@ int flex_array_shrink(struct flex_array
int part_nr;
int ret = 0;
+ if (!fa->total_nr_elements)
+ return 0;
if (elements_fit_in_base(fa))
return ret;
for (part_nr = 0; part_nr < FLEX_ARRAY_NR_BASE_PTRS; part_nr++) {
Patches currently in stable-queue which might be from [email protected] are
queue-2.6.38/flex_arrays-allow-zero-length-flex-arrays.patch
queue-2.6.38/flex_array-flex_array_prealloc-takes-a-number-of-elements-not-an-end.patch
_______________________________________________
stable mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/stable