Skip to content

Commit

Permalink
slub: Fix kmem_ptr_validate() for non-kernel pointers
Browse files Browse the repository at this point in the history
As suggested by Linus, fix up kmem_ptr_validate() to handle non-kernel pointers
more graciously. The patch changes kmem_ptr_validate() to use the newly
introduced kern_ptr_validate() helper to check that a pointer is a valid kernel
pointer before we attempt to convert it into a 'struct page'.

Cc: Andrew Morton <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Matt Mackall <[email protected]>
Cc: Nick Piggin <[email protected]>
Signed-off-by: Pekka Enberg <[email protected]>
Acked-by: Christoph Lameter <[email protected]>
Acked-by: David Rientjes <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Pekka Enberg authored and torvalds committed Apr 9, 2010
1 parent fc1c183 commit d3e06e2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2386,6 +2386,9 @@ int kmem_ptr_validate(struct kmem_cache *s, const void *object)
{
struct page *page;

if (!kern_ptr_validate(object, s->size))
return 0;

page = get_object_page(object);

if (!page || s != page->slab)
Expand Down

0 comments on commit d3e06e2

Please sign in to comment.