Skip to content

Commit

Permalink
slob: fix memory corruption
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nick Piggin authored and Linus Torvalds committed Nov 15, 2007
1 parent a347422 commit d32ddd8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mm/slob.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
/* Improve fragment distribution and reduce our average
* search time by starting our next search here. (see
* Knuth vol 1, sec 2.5, pg 449) */
if (free_slob_pages.next != prev->next)
if (prev != free_slob_pages.prev &&
free_slob_pages.next != prev->next)
list_move_tail(&free_slob_pages, prev->next);
break;
}
Expand Down

0 comments on commit d32ddd8

Please sign in to comment.