diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-08-16 12:54:41 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-08-28 15:47:56 +0200 |
commit | b06275e65f012db0ea85c65bc4e30fb9b7197cf8 (patch) | |
tree | ea7af0f465659a0acc4cd32da2339a73c3f3751d /vm/vm_pageout.c | |
parent | 2c1cccc529737527ad9ef981952d2c14d3dd13ec (diff) |
vm: fix locking issues
Avoid accessing fields of `vm_object' objects without having it
locked. These problems have been found using a code transformation
done by Coccinelle that instrumented all accesses with a runtime
check, and manual inspection.
* vm/memory_object.c (memory_object_data_supply): Avoid accessing
fields without the lock.
* vm/vm_fault.c (vm_fault_page): Likewise.
* vm/vm_map.c (vm_map_submap): Properly lock `object'.
(vm_map_copy_overwrite): Avoid accessing fields without the lock.
(vm_map_copyin): Lock `src_object'.
* vm/vm_object.c (_vm_object_setup): Likewise.
(vm_object_allocate): Likewise.
(vm_object_terminate): Avoid accessing fields without the lock.
(vm_object_copy_slowly): Lock `new_object'.
(vm_object_copy_delayed): Lock `src_object' earlier, lock `new_copy'.
(vm_object_shadow): Lock `result'.
(vm_object_enter): Properly lock `object'. Avoid accessing fields
without the lock.
* vm/vm_pageout.c (vm_pageout_setup): Properly lock `old_object'.
Diffstat (limited to 'vm/vm_pageout.c')
-rw-r--r-- | vm/vm_pageout.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/vm/vm_pageout.c b/vm/vm_pageout.c index 51a6a0d..b676c7b 100644 --- a/vm/vm_pageout.c +++ b/vm/vm_pageout.c @@ -252,6 +252,8 @@ vm_pageout_setup( vm_object_unlock(new_object); } + vm_object_lock(old_object); + if (flush) { /* * Create a place-holder page where the old one was, @@ -262,7 +264,6 @@ vm_pageout_setup( == VM_PAGE_NULL) vm_page_more_fictitious(); - vm_object_lock(old_object); vm_page_lock_queues(); vm_page_remove(m); vm_page_unlock_queues(); @@ -281,8 +282,6 @@ vm_pageout_setup( VM_EXTERNAL_STATE_EXISTS); #endif /* MACH_PAGEMAP */ - vm_object_unlock(old_object); - vm_object_lock(new_object); /* @@ -305,7 +304,6 @@ vm_pageout_setup( */ vm_page_copy(m, new_m); - vm_object_lock(old_object); m->dirty = FALSE; pmap_clear_modify(m->phys_addr); @@ -328,8 +326,6 @@ vm_pageout_setup( VM_EXTERNAL_STATE_EXISTS); #endif /* MACH_PAGEMAP */ - vm_object_unlock(old_object); - vm_object_lock(new_object); /* @@ -383,6 +379,7 @@ vm_pageout_setup( */ vm_object_unlock(new_object); + vm_object_unlock(old_object); /* * Return the placeholder page to simplify cleanup. |