Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 210010
b: refs/heads/master
c: f181942
h: refs/heads/master
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Aug 28, 2010
1 parent 58165bd commit 19452c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d4348c678977c7093438bbbf2067c49396ae941b
refs/heads/master: f18194275c39835cb84563500995e0d503a32d9a
19 changes: 16 additions & 3 deletions trunk/mm/rmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void __init anon_vma_init(void)
*/
struct anon_vma *page_lock_anon_vma(struct page *page)
{
struct anon_vma *anon_vma;
struct anon_vma *anon_vma, *root_anon_vma;
unsigned long anon_mapping;

rcu_read_lock();
Expand All @@ -327,8 +327,21 @@ struct anon_vma *page_lock_anon_vma(struct page *page)
goto out;

anon_vma = (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON);
anon_vma_lock(anon_vma);
return anon_vma;
root_anon_vma = ACCESS_ONCE(anon_vma->root);
spin_lock(&root_anon_vma->lock);

/*
* If this page is still mapped, then its anon_vma cannot have been
* freed. But if it has been unmapped, we have no security against
* the anon_vma structure being freed and reused (for another anon_vma:
* SLAB_DESTROY_BY_RCU guarantees that - so the spin_lock above cannot
* corrupt): with anon_vma_prepare() or anon_vma_fork() redirecting
* anon_vma->root before page_unlock_anon_vma() is called to unlock.
*/
if (page_mapped(page))
return anon_vma;

spin_unlock(&root_anon_vma->lock);
out:
rcu_read_unlock();
return NULL;
Expand Down

0 comments on commit 19452c8

Please sign in to comment.