Paul Jackson 55a230aae6 cpuset: zero malloc - revert the old cpuset fix
The cpuset code to present a list of tasks using a cpuset to user space could
write to an array that it had kmalloc'd, after a kmalloc request of zero size.

The problem was that the code didn't check for writes past the allocated end
of the array until -after- the first write.

This is a race condition that is likely rare -- it would only show up if a
cpuset went from being empty to having a task in it, during the brief time
between the allocation and the first write.

Prior to roughly 2.6.22 kernels, this was also a benign problem, because a
zero kmalloc returned a few usable bytes anyway, and no harm was done with the
bogus write.

With the 2.6.22 kernel changes to make issue a warning if code tries to write
to the location returned from a zero size allocation, this problem is no
longer benign.  This cpuset code would occassionally trigger that warning.

The fix is trivial -- check before storing into the array, not after, whether
the array is big enough to hold the store.

Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: "Serge E. Hallyn" <serue@us.ibm.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Cc: Kirill Korotaev <dev@openvz.org>
Cc: Paul Menage <menage@google.com>
Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com>
Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Paul Jackson <pj@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-19 11:53:35 -07:00
..
2007-10-18 14:37:24 -07:00
2007-10-18 14:37:25 -07:00
2007-07-16 09:05:47 -07:00
2007-10-18 14:37:25 -07:00
2007-10-18 14:37:24 -07:00
2007-10-17 08:42:55 -07:00
2007-10-01 07:52:23 -07:00
2007-10-18 14:37:31 -07:00
2007-10-18 14:37:26 -07:00
2006-12-07 08:39:36 -08:00
2007-10-18 14:37:31 -07:00
2007-07-16 09:05:50 -07:00
2007-10-16 09:43:10 -07:00
2006-12-04 02:00:22 -05:00
2007-10-11 22:11:12 +02:00
2007-10-19 11:53:34 -07:00
2007-10-18 14:37:25 -07:00
2007-10-11 22:11:12 +02:00
2007-10-19 11:53:34 -07:00
2007-10-18 14:37:25 -07:00
2007-10-16 09:43:04 -07:00
2007-10-18 14:37:24 -07:00
2007-07-16 09:05:49 -07:00
2007-07-16 09:05:49 -07:00
2007-10-17 16:55:11 +02:00
2007-10-15 17:00:13 +02:00
2007-07-16 09:05:50 -07:00
2007-10-19 11:53:34 -07:00
2007-10-18 14:37:24 -07:00
2007-05-09 08:57:56 +02:00
2007-08-27 10:27:48 -07:00