psw/ae: blank out ld-linux.so interpretor path from AEs#1061
Open
berrange wants to merge 1 commit intointel:mainfrom
Open
psw/ae: blank out ld-linux.so interpretor path from AEs#1061berrange wants to merge 1 commit intointel:mainfrom
berrange wants to merge 1 commit intointel:mainfrom
Conversation
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_pce.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.
Fixes: intel#1040
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Contributor
Author
|
The DCAP counterpart of this is intel/confidential-computing.tee.dcap#435 |
haitaohuang
approved these changes
Oct 11, 2024
Contributor
|
I realize we probably do not want to re-sign AEs for this change only if this affects the sigstruct (likely not but did not check) |
Contributor
Author
In Fedora context, I've got a local workaround to do reproducible builds by matching the current nixos path. So I'm fine if this only applies to future AEs, no need to re-sign anything that already exists IMHO. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_pce.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 NixOS interpretor path, by setting it to the empty string.
Fixes: #1040
Two alternatives I considered:
stripcommand to add--remove-section=.interp. This has the undesirable side effect that 'readelf' will complain that the AE ELF file is malformed, because ELF executables are expected to have an.interpsection-Wl,--shared. This tells the linker to create an ELF file that is a shared library rather than an executable, and thus avoids creating a.interpsection in the first place. This has a bunch of changes to the overall ELF file, however, and I was not confident that the result would be functionally correct for the SGX enclave loader.I still believe that using
-Wl,--sharedis probably the more semantically logical approach, but using-Wl,--dynamic-loader,is the approach that has fewer chances of unexpected behaviour changes, hence I picked the latter here.