From 63d8dcaa66f8ee0a4462fca58055a4057821eeb1 Mon Sep 17 00:00:00 2001 From: Dmitrii Kuvaiskii Date: Mon, 20 Jun 2022 00:36:19 -0700 Subject: [PATCH] [LibOS] Do not flush unopened Encrypted File during checkpoint Without this check, the called `encrypted_file_flush(enc)` assumes that the Encrypted File is opened and fails on an assert / with a segfault because it tries to access `enc->pf`. Kudos to Anees Sahib for root causing the bug. Signed-off-by: Dmitrii Kuvaiskii --- LibOS/src/fs/shim_fs_encrypted.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/LibOS/src/fs/shim_fs_encrypted.c b/LibOS/src/fs/shim_fs_encrypted.c index d568fdeb71..1c47ba8c55 100644 --- a/LibOS/src/fs/shim_fs_encrypted.c +++ b/LibOS/src/fs/shim_fs_encrypted.c @@ -739,9 +739,11 @@ BEGIN_CP_FUNC(encrypted_file) { struct shim_encrypted_file* enc = obj; struct shim_encrypted_file* new_enc = NULL; - int ret = encrypted_file_flush(enc); - if (ret < 0) - return ret; + if (enc->pf) { + int ret = encrypted_file_flush(enc); + if (ret < 0) + return ret; + } size_t off = ADD_CP_OFFSET(sizeof(struct shim_encrypted_file)); new_enc = (struct shim_encrypted_file*)(base + off);