From 329866d1d09d577de7188bb9f81bfd621ef4684c Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 10 Aug 2019 19:45:57 -0400 Subject: [PATCH] kernel/vm: Set CLONEABLE_AREA before cloning areas for transfer. --- src/system/kernel/vm/vm.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index 28cb59bcdb..3d64c4d184 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -5992,6 +5992,11 @@ transfer_area(area_id id, void** _address, uint32 addressSpec, team_id target, if (info.team != thread_get_current_thread()->team->id) return B_PERMISSION_DENIED; + // We need to mark the area cloneable so the following operations work. + status = set_area_protection(id, info.protection | B_CLONEABLE_AREA); + if (status != B_OK) + return status; + area_id clonedArea = vm_clone_area(target, info.name, _address, addressSpec, info.protection, REGION_NO_PRIVATE_MAP, id, kernel); if (clonedArea < 0) @@ -6003,6 +6008,9 @@ transfer_area(area_id id, void** _address, uint32 addressSpec, team_id target, return status; } + // Now we can reset the protection to whatever it was before. + set_area_protection(clonedArea, info.protection); + // TODO: The clonedArea is B_SHARED_AREA, which is not really desired. return clonedArea;