aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Lameter <clameter@sgi.com>2007-07-17 07:03:33 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-17 13:23:02 -0400
commitb5fab14e5d87df4d94161ae5f5e0c8625f9ffda2 (patch)
tree80e206d025be3823797924a8ea8b70c56a6deab9
parenta0acd820807680d2ccc4ef3448387fcdbf152c73 (diff)
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: Christoph Lameter <clameter@sgi.com> Cc: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/mm.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 4c482a3ee870..a5c451816fdc 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -599,6 +599,7 @@ static inline struct address_space *page_mapping(struct page *page)
599{ 599{
600 struct address_space *mapping = page->mapping; 600 struct address_space *mapping = page->mapping;
601 601
602 VM_BUG_ON(PageSlab(page));
602 if (unlikely(PageSwapCache(page))) 603 if (unlikely(PageSwapCache(page)))
603 mapping = &swapper_space; 604 mapping = &swapper_space;
604#ifdef CONFIG_SLUB 605#ifdef CONFIG_SLUB