From 95c577fb1a65d1e351f28b64eee72ec9aaa9e90e Mon Sep 17 00:00:00 2001 From: g2flyer Date: Fri, 10 May 2024 15:39:46 -0700 Subject: [PATCH] fixup! [LibOS] Single-process-lifetime rollback protection for protected files (WIP) Signed-off-by: g2flyer --- libos/src/fs/libos_fs_encrypted.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/libos/src/fs/libos_fs_encrypted.c b/libos/src/fs/libos_fs_encrypted.c index 67126ba5d5..e290c197c3 100644 --- a/libos/src/fs/libos_fs_encrypted.c +++ b/libos/src/fs/libos_fs_encrypted.c @@ -897,14 +897,20 @@ BEGIN_CP_FUNC(encrypted_volume) { struct libos_encrypted_volume* new_volume = NULL; size_t off = ADD_CP_OFFSET(sizeof(struct libos_encrypted_volume)); + new_volume = (struct libos_encrypted_volume*)(base + off); + // TODO (MST): do something with remaining fields of struct + log_debug("CP(encrypted_volume): protection_mode=%d file_state_mape=%p", + volume->protection_mode, volume->files_state_map); // TODO (MST): DEBUG + // - protection_mode -> automatically copied + // - files_state_map + // - files_state_map_lock + lock(&g_keys_lock); DO_CP_MEMBER(encrypted_files_key, volume, new_volume, key); unlock(&g_keys_lock); - // TODO (MST): do something with remaining fields of struct - ADD_CP_FUNC_ENTRY(off); if (objp) @@ -917,11 +923,19 @@ BEGIN_RS_FUNC(encrypted_volume) { struct libos_encrypted_volume* volume = (void*)(base + GET_CP_FUNC_ENTRY()); __UNUSED(offset); - CP_REBASE(volume->key); - // TODO (MST): do something with remaining fields of struct + log_debug("RS(encrypted_volume): protection_mode=%d file_state_mape=%p", + volume->protection_mode, volume->files_state_map); // TODO (MST): DEBUG + // - protection_mode -> automatically copied + // - files_state_map + // - files_state_map_lock + if (!create_lock(&volume->files_state_map_lock)) { + return -ENOMEM; + } + + CP_REBASE(volume->key); } -END_CP_FUNC(encrypted_volume) +END_RS_FUNC(encrypted_volume) BEGIN_CP_FUNC(encrypted_file) { __UNUSED(size); @@ -940,6 +954,7 @@ BEGIN_CP_FUNC(encrypted_file) { new_enc->use_count = enc->use_count; DO_CP_MEMBER(str, enc, new_enc, uri); + DO_CP_MEMBER(str, enc, new_enc, norm_path); DO_CP_MEMBER(encrypted_volume, enc, new_enc, volume); @@ -963,6 +978,8 @@ BEGIN_RS_FUNC(encrypted_file) { __UNUSED(offset); CP_REBASE(enc->uri); + CP_REBASE(enc->norm_path); + CP_REBASE(enc->volume); /* If the file was used, recreate `enc->pf` based on the PAL handle */