mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-11 13:22:33 +00:00
Fix race when removing Cap_index (fix #163)
Removing a Cap_index from Capability_map in core can happen twice, via Cap_session_component or destructor of a Cap_mapping. That it's checked whether the index is part of the map before removing it. This patch puts the check into the remove method, so both operations are within the same lock context, to remove a race condition. This is a follow up fix for commit d287b9d89387d8d307c11594413d7ab47429827f
This commit is contained in:
parent
c1e6657f49
commit
89db981280
8
base-foc/src/base/env/cap_map.cc
vendored
8
base-foc/src/base/env/cap_map.cc
vendored
@ -89,8 +89,12 @@ void Genode::Capability_map::remove(Genode::Cap_index* i)
|
||||
Lock_guard<Spin_lock> guard(_lock);
|
||||
|
||||
if (i) {
|
||||
_tree.remove(i);
|
||||
cap_idx_alloc()->free(i,1);
|
||||
if (_tree.first())
|
||||
i = _tree.first()->find_by_id(i->id());
|
||||
if (i) {
|
||||
_tree.remove(i);
|
||||
cap_idx_alloc()->free(i,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ Cap_mapping::Cap_mapping(Core_cap_index* i, Native_thread_id r)
|
||||
Cap_mapping::~Cap_mapping()
|
||||
{
|
||||
unmap();
|
||||
cap_map()->remove(cap_map()->find(local->id()));
|
||||
cap_map()->remove(local);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user