mirror of
https://github.com/fail0verflow/switch-linux.git
synced 2025-05-04 02:34:21 -04:00
rmap: add anon_vma bug checks
Verify the refcounting doesn't go wrong, and resurrect the check in __page_check_anon_rmap as in old anon-vma code. Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Rik van Riel <riel@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
21d0d443cd
commit
44ab57a06d
1 changed files with 3 additions and 0 deletions
|
@ -811,6 +811,7 @@ static void __page_check_anon_rmap(struct page *page,
|
||||||
* are initially only visible via the pagetables, and the pte is locked
|
* are initially only visible via the pagetables, and the pte is locked
|
||||||
* over the call to page_add_new_anon_rmap.
|
* over the call to page_add_new_anon_rmap.
|
||||||
*/
|
*/
|
||||||
|
BUG_ON(page_anon_vma(page)->root != vma->anon_vma->root);
|
||||||
BUG_ON(page->index != linear_page_index(vma, address));
|
BUG_ON(page->index != linear_page_index(vma, address));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1408,6 +1409,7 @@ int try_to_munlock(struct page *page)
|
||||||
*/
|
*/
|
||||||
void drop_anon_vma(struct anon_vma *anon_vma)
|
void drop_anon_vma(struct anon_vma *anon_vma)
|
||||||
{
|
{
|
||||||
|
BUG_ON(atomic_read(&anon_vma->external_refcount) <= 0);
|
||||||
if (atomic_dec_and_lock(&anon_vma->external_refcount, &anon_vma->root->lock)) {
|
if (atomic_dec_and_lock(&anon_vma->external_refcount, &anon_vma->root->lock)) {
|
||||||
struct anon_vma *root = anon_vma->root;
|
struct anon_vma *root = anon_vma->root;
|
||||||
int empty = list_empty(&anon_vma->head);
|
int empty = list_empty(&anon_vma->head);
|
||||||
|
@ -1419,6 +1421,7 @@ void drop_anon_vma(struct anon_vma *anon_vma)
|
||||||
* the refcount on the root and check if we need to free it.
|
* the refcount on the root and check if we need to free it.
|
||||||
*/
|
*/
|
||||||
if (empty && anon_vma != root) {
|
if (empty && anon_vma != root) {
|
||||||
|
BUG_ON(atomic_read(&root->external_refcount) <= 0);
|
||||||
last_root_user = atomic_dec_and_test(&root->external_refcount);
|
last_root_user = atomic_dec_and_test(&root->external_refcount);
|
||||||
root_empty = list_empty(&root->head);
|
root_empty = list_empty(&root->head);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue