-
Notifications
You must be signed in to change notification settings - Fork 127
CDH: Update secure mount for BlockDevice #1052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
CDH: Update secure mount for BlockDevice #1052
Conversation
fa35e8b
to
61533ef
Compare
The underlying
|
cc @ChengyuZhu6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice PR. I made a few comments.
/// If set to `true`, there will perform a filesystem format before mounting, if | ||
/// any `filesystem_type` is specified. | ||
/// If set to `false`, the block device will be mounted as is. | ||
pub ephemeral: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should call this something more literal, like format_filesystem
. Whether it is ephemeral storage actually depends on a few different things, such as if we format the fs, how we handle the encryption key (see above option), and how the storage is actually provided by the host. So it might be more clear to name this field more specifically. I don't have strong feelings about this though.
Also not sure this needs to be an option. We can probably just use a bool with a default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh. I have lost some more notes upon this. If ephemeral
is true, the original device will also be encrypted which might cause data erasing and overwritting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, with ephemeral mounts there will be a new random key. Any existing data will not be readable.
I am just saying that we have more than one option that relate to ephemeral storage. This one and the encryption key parameter above. Thus, maybe this should be called something more specific rather than ephemeral
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me re-design this with a more clear parameter.
confidential-data-hub/hub/src/storage/volume_type/blockdevice/mod.rs
Outdated
Show resolved
Hide resolved
} | ||
})?; | ||
|
||
self.symbol_files.push(mount_point.to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only see us push one location to this Vec. Do we need a vector? Isn't the link name always going to be the mount point?
Also, I would change the name of this field to be symlink_names
, since symbol file tends to mean something else more generally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for future extension that potentially more symlink files would be generated when doing secure mount.
|
||
Ephemeral storage is a storage that is not persistent. | ||
|
||
1. Mount a block device file, encrypt it using `luks2` with an ephemeral key, and mount the plaintext device to `/mnt/dev-path` as a file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to make it clear that these are two different options not two steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. This is actually a case, neither two steps or two options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the document due to new API design. ptal
confidential-data-hub/docs/use-cases/secure-mount-with-block-device.md
Outdated
Show resolved
Hide resolved
e64b1f0
to
4907ce0
Compare
btw, the most important issue is the musl build. #1052 (comment) wdyt? |
5cd1934
to
279e244
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs re-thinking:
Binary file added BIN +20 MB confidential-data-hub/hub/test_files/luks2-disk
some minor suggestions. will take another tomorrow
@Xynnn007 I think the musl question might be one for the coco slack or the community meeting. |
279e244
to
d96130a
Compare
@fitzthum I change the API with more explicit work mode (named |
f15859b
to
714c815
Compare
This is for unit test to mount an encrypted volume. I tried 16 MB~ but luks2 does not support that small, 20MB is enough. An option is to mark it as git-lfs? |
I was thinking the option where the test generates it runtime. Something like file create + nix fallocate. |
714c815
to
59f534e
Compare
let me take a try. Combining two tests. Updated: Done. |
bdb7c69
to
bc792fb
Compare
3189f24
to
ff316a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I wonder whether the implementation will cover the requirements from the ephemeral space feature in peerpods (afaik the old bash script was just copied 1:1 to the peerpod repo) cc @bpradipt
ff316a0
to
3d2fca9
Compare
3d2fca9
to
0fb4b57
Compare
Do you have any designs/issue/PR for this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The encrytion format we are using is luks2 than luks. This patch fixes this typo. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
mount_path field is specified in the request, thus we do not need it in the response body for duplicaiton. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
random_key helps to generate a random data with specified length. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
we use a rust-c-binding crate libcryptsetup-rs to implement luks2 operations. The related code can be reused so a separate mod is added. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
The SecureMount object would carry some context information when doing mount, like the directories created. It is useful when doing clean jobs. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
filesystem module provides operations for fs. Now it only supports ext4. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
This patch refactors BlockDevice module, including the following: 1. use luks2 rust module to do luks2 related operations. 2. adds a new option named `filesystem_type` to specify what filesystem is used if we need a directory mount 3. adds a new option named `ephemeral` for cases where an ephemeral storage is needed. 4. also some unit tests Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
after the change of block device code, we now support new modes of block device. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
Similar to RESOURCE_PROVIDER, we define STORAGE to control features of secure mounts. Now only luks2 is supported. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
libcryptsetup-dev is required to build luks2 feature of CDH. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
Now libcryptsetup does not support musl build for it cannot be linked statically, thus we use gnu to build cdh in CI pipeline. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
Now libcryptsetup does not support musl build for it cannot be linked statically, thus we use gnu to build cdh in the test. Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
0fb4b57
to
30f656a
Compare
@Xynnn007 this is the tracker issue - confidential-containers/cloud-api-adaptor#2486 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
seems like we are generally ok with ditching musl here, but need to work out the details
let me put a PR for installing dependencies to the rootfs too and merge both at the same time |
This patch mainly reconstructs the block device module of secure mount. It includes the following contents
Please check the specific commit message