Skip to content
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

ae: blank out ld-linux.so interpretor path from AEs #435

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

berrange
Copy link

@berrange berrange commented Oct 8, 2024

The enclaves are getting built as ELF executables, and thus the linker will embed the current ld-linux.so path for the host OS environment in the binary:

$ readelf -a libsgx_tdqe.signed.so | grep interpreter
[Requesting program interpreter: /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2]

The SGX enclaves are never loaded using ld-linux.so, as SGX has custom code for loading enclaves in the required manner.

This embedded ld-linux.so path thus serves no functional purpose, while also making it harder to do a reproducible build of the enclaves outside of the NixOS environment.

This patch blanks out the NixOX interpretor path, by setting it to the empty string.

Related: intel/linux-sgx#1040

This is the DCAP counterpart to this SGX PR: intel/linux-sgx#1061

The enclaves are getting built as ELF executables, and thus the linker
will embed the current ld-linux.so path for the host OS environment
in the binary:

 $ readelf -a libsgx_tdqe.signed.so | grep interpreter
      [Requesting program interpreter: /nix/store/xmprbk52mlcdsljz66m8yf7cf0xf36n1-glibc-2.38-44/lib/ld-linux-x86-64.so.2]

The SGX enclaves are never loaded using ld-linux.so, as SGX has custom
code for loading enclaves in the required manner.

This embedded ld-linux.so path thus serves no functional purpose, while
also making it harder to do a reproducible build of the enclaves outside
of the NixOS environment.

This patch blanks out the NixOX interpretor path, by setting it to the
empty string.

Related: intel/linux-sgx#1040
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Copy link
Contributor

@haitaohuang haitaohuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -135,7 +136,8 @@ ENCLAVE_LDFLAGS := -Wl,-z,relro,-z,now,-z,noexecstack -fPIC \
-Wl,-pie,-eenclave_entry -Wl,--export-dynamic -Wl,-Map,qve.map \
-Wl,--defsym,__ImageBase=0 \
-Wl,--build-id \
-Wl,--version-script=Enclave/linux/qve.lds
-Wl,--version-script=Enclave/linux/qve.lds \
-Wl,--dynamic-linker,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, is this equivalent, or different in any way from

-Wl,--no-dynamic-linker

?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are different

  • "-Wl,--dynamic-linker," results in an ELF '.interp' section being present, with zero-length string.
  • "-Wl,--no-dynamic-linker" results in the ELF '.interp' section being entirely absent, and in addition removes the ELF program header

It is possible this difference might not matter, but I don't know enough to be confident suggesting that - similar to how "-Wl,--shared" might another option. It would need an SGX expert to analyse this and make a decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants