-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
sgx-psw: init package and module #148593
sgx-psw: init package and module #148593
Conversation
# nix develop "github:yaxitech/nix-linux-sgx/sgxs-tools" --command "sgx-detect"
SGX_SDK = /nix/store/m3sna34srcj8s2q98kcz43aly57wxynk-sgx-sdk-2.14.100.2
SGX_PSW = /nix/store/17zbdsmmc1w11maxqbhff4i6wc7bn5ck-sgx-psw-2.14.100.2
LD_LIBRARY_PATH = /nix/store/17zbdsmmc1w11maxqbhff4i6wc7bn5ck-sgx-psw-2.14.100.2/lib:/nix/store/m3sna34srcj8s2q98kcz43aly57wxynk-sgx-sdk-2.14.100.2/lib
Detecting SGX, this may take a minute...
✔ SGX instruction set
✔ CPU support
✔ CPU configuration
✔ Enclave attributes
✔ Enclave Page Cache
SGX features
✘ SGX2 ✘ EXINFO ✘ ENCLV ✘ OVERSUB ✘ KSS
Total EPC size: 93.5MiB
✔ Flexible launch control
✔ CPU support
? CPU configuration
✔ Able to launch production mode enclave
✔ SGX system software
✔ SGX kernel device (/dev/sgx/enclave)
✔ libsgx_enclave_common
✔ AESM service
✔ Able to launch enclaves
✔ Debug mode
✔ Production mode
✔ Production mode (Intel whitelisted)
You're all set to start running SGX programs! |
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 looks very nice! Thanks for bringing SGX forward on NixOS. 👍
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
|
||
users.groups = { | ||
"${cfg.group}" = { }; | ||
"sgx_prv" = { }; |
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'm still curious about https://github.com/systemd/systemd-stable/blob/main/rules.d/50-udev-default.rules.in#L43 and if we need the "sgx" group or how "sgx_prv" is different.
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.
The sgx
group is for managing access to the application enclave device, i.e., /dev/sgx_enclave
. The sgx_prv
group is for the provisioning device, i.e., /dev/sgx_provision
. Using the group sgx
for sgx_enclave
and the group sgx_prv
for sgx_provision
is a convention which we should follow.
Access to the provisioning device implies access to the CPU-unique provisioning certificate key. Therefore, a user which is allowed to create application enclaves usually should not be allowed to create provisioning enclaves. The AESM service is a privileged exception as it provides remote attestation.
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.
What is the right module in which to create the sgx group? I keep bringing this up because the existence or nonexistence of this group caused some problems in systemd startup in stage2 when there were differing bios settings.
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.
Before #148649, we did not create the sgx
group for the systemd-bundled udev rule you mentioned above. This led to a warning during boot which is now resolved. We currently take care of the sgx_prv
group in this PR only: create the group (the position you annotated) and the AESM-bundled udev rules assign permissions and create symlinks.
As an alternative, we could take an approach similar to #148649 and create the sgx_prv
and the respective udev rule (change group to sgx_prv
, assign permissions 0660
) independent of having the AESM service enabled or not. I think that would make sense and would leave us with the following permissions:
# stat -c '%U %G %a %n' /dev/sgx_*
root sgx 660 /dev/sgx_enclave
root sgx_prv 660 /dev/sgx_provision
Anyone who should be allowed to create application enclaves joins the sgx
group. Anyone who should be allowed to create provisioning enclaves (for example the AESM service of this PR) joins the sgx_prv
group.
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.
Maybe something like veehaitch@0666d1b?
See latest commits.
Note for other reviewers: This needs the changes from #147693 to work. It has already been merged, but still sits in staging. |
If you expect a fully working setup on your SGX-capable bare-metal hardware by just setting This PR is certainly more useful with #147693 being part of the |
@veehaitch True, given that everything comes together anyhow when staging is merged, there is no reason to keep this PR sitting around. :) Meanwhile, I've been able to test this on a Intel Celeron J4005 and everything seems to be working just fine! 🥳
|
Following a discussion with @tomberek, I decided to take a different approach regarding the users and groups involved. I considered opening another PR following the merge of this one but I think it makes sense to discuss and ideally incorporate the changes in this PR already:
I'm going to rebase those commits as soon as I heard back from you. I didn't do that yet to make it easier to review the latest changes. |
@veehaitch Sounds reasonable to me. 👍 |
Co-authored-by: Alex Zero <joseph@marsden.space>
Co-authored-by: Alex Zero <joseph@marsden.space>
Rebased. |
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 think we're good to go. Any thoughts, @Mic92? |
Thanks. Looks solid! |
Motivation for this change
debug
argumentSupersedes #129432
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes