mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
fix some more edge cases in PDDB key deletion
This commit is contained in:
parent
ea913a6fb4
commit
71a1dddf15
2 changed files with 17 additions and 1 deletions
|
|
@ -572,7 +572,11 @@ impl BasisCache {
|
||||||
// this implementation is still in progress
|
// this implementation is still in progress
|
||||||
dict_entry.key_erase(key);
|
dict_entry.key_erase(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sync the key pools to disk
|
// sync the key pools to disk
|
||||||
|
if !dict_entry.sync_small_pool(hw, &mut basis.v2p_map, &basis.cipher) {
|
||||||
|
return Err(Error::new(ErrorKind::OutOfMemory, "Ran out of memory syncing small pool"));
|
||||||
|
}
|
||||||
dict_entry.sync_large_pool();
|
dict_entry.sync_large_pool();
|
||||||
// encrypt and write the dict entry to disk
|
// encrypt and write the dict entry to disk
|
||||||
basis.dict_sync(hw, dict)?;
|
basis.dict_sync(hw, dict)?;
|
||||||
|
|
@ -1697,6 +1701,13 @@ impl BasisCacheEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for dict in dictnames {
|
for dict in dictnames {
|
||||||
|
if let Some(dict_entry) = self.dicts.get_mut(&dict) {
|
||||||
|
if !dict_entry.sync_small_pool(hw, &mut self.v2p_map, &self.cipher) {
|
||||||
|
return Err(Error::new(ErrorKind::OutOfMemory, "Ran out of memory syncing small pool"));
|
||||||
|
}
|
||||||
|
dict_entry.sync_large_pool();
|
||||||
|
}
|
||||||
|
|
||||||
match self.dict_sync(hw, &dict) {
|
match self.dict_sync(hw, &dict) {
|
||||||
Ok(_) => {},
|
Ok(_) => {},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
||||||
|
|
@ -307,6 +307,10 @@ impl DictCacheEntry {
|
||||||
fn try_fill_small_key(&mut self, hw: &mut PddbOs, v2p_map: &HashMap::<VirtAddr, PhysPage>, cipher: &Aes256GcmSiv,
|
fn try_fill_small_key(&mut self, hw: &mut PddbOs, v2p_map: &HashMap::<VirtAddr, PhysPage>, cipher: &Aes256GcmSiv,
|
||||||
data_cache: &mut PlaintextCache, key_name: &str) {
|
data_cache: &mut PlaintextCache, key_name: &str) {
|
||||||
if let Some(kcache) = self.keys.get_mut(key_name) {
|
if let Some(kcache) = self.keys.get_mut(key_name) {
|
||||||
|
if !kcache.flags.valid() {
|
||||||
|
// nothing to fill, the key entry isn't valid
|
||||||
|
return;
|
||||||
|
}
|
||||||
if let Some(pool_index) = small_storage_index_from_key(&kcache, self.index) {
|
if let Some(pool_index) = small_storage_index_from_key(&kcache, self.index) {
|
||||||
// if the key is within the small pool space, create a bookkeeping record for it, and pre-cache its data.
|
// if the key is within the small pool space, create a bookkeeping record for it, and pre-cache its data.
|
||||||
// generate the index within the small pool based on the address
|
// generate the index within the small pool based on the address
|
||||||
|
|
@ -1014,7 +1018,8 @@ impl DictCacheEntry {
|
||||||
log::error!("Double-free error in free_keys()");
|
log::error!("Double-free error in free_keys()");
|
||||||
log::info!("free_key_vec[i].0: {:?}", free_key_vec[i].0);
|
log::info!("free_key_vec[i].0: {:?}", free_key_vec[i].0);
|
||||||
log::info!("index: {}", index);
|
log::info!("index: {}", index);
|
||||||
panic!("Double-free error in free_keys()");
|
panic!("Double-free error in free_keys(). free_key_vec[i].0: {:?}, index: {}, free_key_vec.len(): {}",
|
||||||
|
free_key_vec[i].0, index, free_key_vec.len());
|
||||||
}
|
}
|
||||||
FreeKeyCases::RightAdjacent => {
|
FreeKeyCases::RightAdjacent => {
|
||||||
// see if we should merge to the right
|
// see if we should merge to the right
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue