aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2007-11-15 06:32:04 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-11-15 11:36:27 -0500
commitd32ddd8f20e7d7a49c45c337c2079be03c77dc41 (patch)
treea56dae80e045a8928bb8da74e6edb3874d297ee2
parenta3474224e6a01924be40a8255636ea5522c1023a (diff)
slob: fix memory corruption
Previously, it would be possible for prev->next to point to &free_slob_pages, and thus we would try to move a list onto itself, and bad things would happen. It seems a bit hairy to be doing list operations with the list marker as an entry, rather than a head, but... this resolves the following crash: http://bugzilla.kernel.org/show_bug.cgi?id=9379 Signed-off-by: Nick Piggin <npiggin@suse.de> Signed-off-by: Ingo Molnar <mingo@elte.hu> Acked-by: Matt Mackall <mpm@selenic.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/slob.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/slob.c b/mm/slob.c
index 5bc2ceb692ec..08a9bd91a1aa 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -321,7 +321,8 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
321 /* Improve fragment distribution and reduce our average 321 /* Improve fragment distribution and reduce our average
322 * search time by starting our next search here. (see 322 * search time by starting our next search here. (see
323 * Knuth vol 1, sec 2.5, pg 449) */ 323 * Knuth vol 1, sec 2.5, pg 449) */
324 if (free_slob_pages.next != prev->next) 324 if (prev != free_slob_pages.prev &&
325 free_slob_pages.next != prev->next)
325 list_move_tail(&free_slob_pages, prev->next); 326 list_move_tail(&free_slob_pages, prev->next);
326 break; 327 break;
327 } 328 }