[haiku-commits] BRANCH HaikuPM-github.package-management - in src: add-ons/kernel/file_systems/packagefs system/kernel/vm

  • From: HaikuPM-github.package-management <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 5 Apr 2013 17:00:35 +0200 (CEST)

added 2 changesets to branch 'refs/remotes/HaikuPM-github/package-management'
old head: 05940bc51417d34f7cb78bd1f2253d305320c563
new head: d4823423996b12ff7332be5dcf97c35c295129a2
overview: https://github.com/haiku/HaikuPM/compare/05940bc...d482342

----------------------------------------------------------------------------

ce577d8: packagefs: AttributeIndex: Support duplicates correctly
  
  The tree comparisons didn't allow for different Nodes having the same
  attribute value. Therefore only the first node would be added and later
  we would try to remove a node not actually in the tree, leading to a
  crash.
  
  packagefs seems to finally unmount cleanly, now.

d482342: VM: Fix vm_block_address_range() area protection
  
  B_ALREADY_WIRED, which was erroneously passed for the area protection
  parameter to map_backing_store(), has the value 7 which implies user
  readable and writable. Hence the address ranges around 0xdeadbeef and
  0xcccccccc could actually be read and written from anywhere.

                                    [ Ingo Weinhold <ingo_weinhold@xxxxxx> ]

----------------------------------------------------------------------------

2 files changed, 19 insertions(+), 4 deletions(-)
.../file_systems/packagefs/AttributeIndex.cpp     | 19 +++++++++++++++++--
src/system/kernel/vm/vm.cpp                       |  4 ++--

############################################################################

Commit:      ce577d8db0580112cd8dcd60a1c6110f624a3d2a
Author:      Ingo Weinhold <ingo_weinhold@xxxxxx>
Date:        Fri Apr  5 14:50:20 2013 UTC

packagefs: AttributeIndex: Support duplicates correctly

The tree comparisons didn't allow for different Nodes having the same
attribute value. Therefore only the first node would be added and later
we would try to remove a node not actually in the tree, leading to a
crash.

packagefs seems to finally unmount cleanly, now.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_systems/packagefs/AttributeIndex.cpp 
b/src/add-ons/kernel/file_systems/packagefs/AttributeIndex.cpp
index e93a434..1f6f62a 100644
--- a/src/add-ons/kernel/file_systems/packagefs/AttributeIndex.cpp
+++ b/src/add-ons/kernel/file_systems/packagefs/AttributeIndex.cpp
@@ -89,14 +89,29 @@ struct AttributeIndex::TreeDefinition {
 
        int Compare(const Key& a, const Value* b) const
        {
-               return QueryParser::compareKeys(fType, a.data, a.length, 
b->data,
+               int cmp = QueryParser::compareKeys(fType, a.data, a.length, 
b->data,
                        b->length);
+               if (cmp != 0)
+                       return cmp;
+
+               // The attribute value is the same. Since the tree value is the 
tree
+               // node itself, we must not return 0, though. We consider a 
node-less
+               // key always less than an actual tree node with the same 
attribute
+               // value.
+               return -1;
        }
 
        int Compare(const Value* a, const Value* b) const
        {
-               return QueryParser::compareKeys(fType, a->data, a->length, 
b->data,
+               if (a == b)
+                       return 0;
+
+               int cmp = QueryParser::compareKeys(fType, a->data, a->length, 
b->data,
                        b->length);
+               if (cmp != 0)
+                       return cmp;
+
+               return a < b ? -1 : 1;
        }
 
 private:

############################################################################

Commit:      d4823423996b12ff7332be5dcf97c35c295129a2
Author:      Ingo Weinhold <ingo_weinhold@xxxxxx>
Date:        Fri Apr  5 14:58:50 2013 UTC

VM: Fix vm_block_address_range() area protection

B_ALREADY_WIRED, which was erroneously passed for the area protection
parameter to map_backing_store(), has the value 7 which implies user
readable and writable. Hence the address ranges around 0xdeadbeef and
0xcccccccc could actually be read and written from anywhere.

----------------------------------------------------------------------------

diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp
index 9d22d21..120710c 100644
--- a/src/system/kernel/vm/vm.cpp
+++ b/src/system/kernel/vm/vm.cpp
@@ -1005,8 +1005,8 @@ vm_block_address_range(const char* name, void* address, 
addr_t size)
        addressRestrictions.address = address;
        addressRestrictions.address_specification = B_EXACT_ADDRESS;
        status = map_backing_store(addressSpace, cache, 0, name, size,
-               B_ALREADY_WIRED, B_ALREADY_WIRED, REGION_NO_PRIVATE_MAP, 0,
-               &addressRestrictions, true, &area, NULL);
+               B_ALREADY_WIRED, 0, REGION_NO_PRIVATE_MAP, 0, 
&addressRestrictions,
+               true, &area, NULL);
        if (status != B_OK) {
                cache->ReleaseRefAndUnlock();
                return status;


Other related posts:

  • » [haiku-commits] BRANCH HaikuPM-github.package-management - in src: add-ons/kernel/file_systems/packagefs system/kernel/vm - HaikuPM-github . package-management