Commit b5fab14e authored by Christoph Lameter's avatar Christoph Lameter Committed by Linus Torvalds

Add VM_BUG_ON in case someone uses page_mapping on a slab page

Detect slab objects being passed to the page oriented functions of the VM.

It is not sufficient to simply return NULL because the functions calling
page_mapping may depend on other items of the page_struct also to be setup
properly.  Moreover slab object may not be properly aligned.  The page
oriented functions of the VM expect to operate on page aligned, page sized
objects.  Operations on object straddling page boundaries may only affect the
objects partially which may lead to surprising results.

It is better to detect eventually remaining uses and eliminate them.
Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a0acd820
...@@ -599,6 +599,7 @@ static inline struct address_space *page_mapping(struct page *page) ...@@ -599,6 +599,7 @@ static inline struct address_space *page_mapping(struct page *page)
{ {
struct address_space *mapping = page->mapping; struct address_space *mapping = page->mapping;
VM_BUG_ON(PageSlab(page));
if (unlikely(PageSwapCache(page))) if (unlikely(PageSwapCache(page)))
mapping = &swapper_space; mapping = &swapper_space;
#ifdef CONFIG_SLUB #ifdef CONFIG_SLUB
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment