From da73ed96dd833549c0d24544a5113e942f7e6be6 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 10 Aug 2019 19:49:24 -0400 Subject: [PATCH] kernel/vm: Enable area-cloning protection for userland areas, too. We allow teams to clone areas within themselves, but I'm not sure exactly what use that has. The kernel can of course clone anything it wants to, still. Hopefully this will prove substantially less disruptive than the reverse change last year, as the preceding commits are likely the only major consumers of this API, rather than a variety of drivers that need to be individually tested. --- src/system/kernel/vm/vm.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index 3d64c4d184..2e1ce01cd4 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -2108,13 +2108,12 @@ vm_clone_area(team_id team, const char* name, void** address, VMCache* cache = vm_area_get_locked_cache(sourceArea); - if (!kernel && sourceAddressSpace == VMAddressSpace::Kernel() - && targetAddressSpace != VMAddressSpace::Kernel() - && !(sourceArea->protection & B_CLONEABLE_AREA)) { + if (!kernel && sourceAddressSpace != targetAddressSpace + && (sourceArea->protection & B_CLONEABLE_AREA) == 0) { // kernel areas must not be cloned in userland, unless explicitly // declared user-cloneable upon construction #if KDEBUG - panic("attempting to clone kernel area \"%s\" (%" B_PRId32 ")!", + panic("attempting to clone area \"%s\" (%" B_PRId32 ")!", sourceArea->name, sourceID); #endif status = B_NOT_ALLOWED;