psw/ae: blank out ld-linux.so interpretor path from AEs #1061
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:
strip
command 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.interp
section-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.interp
section 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,--shared
is 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.