提交 28e4d965 编写于 作者: N Nick Piggin 提交者: Linus Torvalds

[PATCH] mm: remove_mapping() safeness

Some users of remove_mapping had been unsafe.

Modify the remove_mapping precondition to ensure the caller has locked the
page and obtained the correct mapping.  Modify callers to ensure the
mapping is the correct one.

[hugh@veritas.com: swapper_space fix]
Signed-off-by: NNick Piggin <npiggin@suse.de>
Signed-off-by: NHugh Dickins <hugh@veritas.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 bfa5bf6d
...@@ -377,8 +377,8 @@ static pageout_t pageout(struct page *page, struct address_space *mapping) ...@@ -377,8 +377,8 @@ static pageout_t pageout(struct page *page, struct address_space *mapping)
int remove_mapping(struct address_space *mapping, struct page *page) int remove_mapping(struct address_space *mapping, struct page *page)
{ {
if (!mapping) BUG_ON(!PageLocked(page));
return 0; /* truncate got there first */ BUG_ON(mapping != page_mapping(page));
write_lock_irq(&mapping->tree_lock); write_lock_irq(&mapping->tree_lock);
...@@ -547,7 +547,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, ...@@ -547,7 +547,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,
goto free_it; goto free_it;
} }
if (!remove_mapping(mapping, page)) if (!mapping || !remove_mapping(mapping, page))
goto keep_locked; goto keep_locked;
free_it: free_it:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册