-
Notifications
You must be signed in to change notification settings - Fork 13.6k
update fortanix tests #144395
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: master
Are you sure you want to change the base?
update fortanix tests #144395
Conversation
|
This PR modifies cc @jieyouxu |
tests/assembly-llvm/x86_64-fortanix-unknown-sgx-lvi-generic-load.rs
Outdated
Show resolved
Hide resolved
// - C/C++ code compiled as part of Rust crates | ||
// For those different kinds, we do have very small code examples that should be | ||
// mitigated in some way. Mostly we check that ret instructions should no longer be present. | ||
cargo().arg("-v").arg("run").arg("--target").arg(target()).current_dir("enclave").run(); |
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.
Can this instead be cargo build
? That means to run the test one would not need the whole fortanix toolchain setup.
Also, when I do make that change, this test actually fails. So, that again suggests this test does not actually run on CI. When this test was introduced in #77008, nothing is changed to CI to make it run, so unless that was added before I don't think this ever actually worked.
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 cargo build
should work just as good.
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.
In order to mitigate LVI, all binary code needs to be mitigated. This test includes code generation for Rust code, inline assembly, global assembly and C/C++ code compiled as part of Rust crates. For the latter there need to be environment variables set:
CC_x86_64_fortanix_unknown_sgx=clang-11 \
CFLAGS_x86_64_fortanix_unknown_sgx="-D__ELF__ -isystem/usr/include/x86_64-linux-gnu -mlvi-hardening -mllvm -x86-experimental-lvi-inline-asm-hardening" \
CXX_x86_64_fortanix_unknown_sgx=clang++-11 \
CXXFLAGS_x86_64_fortanix_unknown_sgx="-D__ELF__ -isystem/usr/include/x86_64-linux-gnu -mlvi-hardening -mllvm -x86-experimental-lvi-inline-asm-hardening" \
we do that in src/ci/docker/host-x86_64/dist-various-2/Dockerfile
. When testing this locally, you may not have this set.
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.
So, it is my understanding that the dist-
jobs do not actually run any tests. From https://rustc-dev-guide.rust-lang.org/tests/ci.html?highlight=try#ci-workflow:
Dist jobs build a full release of the compiler for a specific platform, including all the tools we ship through rustup; Those builds are then uploaded to the rust-lang-ci2 S3 bucket and are available to be locally installed with the rustup-toolchain-install-master tool. The same builds are also used for actual releases: our release process basically consists of copying those artifacts from rust-lang-ci2 to the production endpoint and signing them.
and
Non-dist jobs run our full test suite on the platform
Hence, I don't think the fortanix tests ever ran on CI
In order to mitigate LVI, all binary code needs to be mitigated. This test includes code generation for Rust code, inline assembly, global assembly and C/C++ code compiled as part of Rust crates
This is just up to the programmer though right? In the sense that you'd need to set a bunch of rather non-obvious flags for this to work at all. So I think testing the interaction with C and especially C++ is quite low.
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.
Also, clang-11
is ancient, why is that still used? It looks like modern clang has -mlvi-hardening
, but since llvm 11 the output of llvm IR has changed quite a bit so just using a more recent LLVM makes some of the tests fail.
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 afraid that description about dist jobs not running any tests isn't quite accurate nowadays, because opt-dist
do run tests (cc @Kobzol)
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.
Well, yeah, but only on x64 Linux and MSVC, nowhere else.
triagebot edited your pings out, I'll reping manually: |
I'll have to wait to hear back from the SGX target maintainers regarding the tests, as I don't have the context either. @rustbot blocked (waiting to hear back) |
tests/assembly-llvm/x86_64-fortanix-unknown-sgx-lvi-generic-load.rs
Outdated
Show resolved
Hide resolved
// - C/C++ code compiled as part of Rust crates | ||
// For those different kinds, we do have very small code examples that should be | ||
// mitigated in some way. Mostly we check that ret instructions should no longer be present. | ||
cargo().arg("-v").arg("run").arg("--target").arg(target()).current_dir("enclave").run(); |
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 cargo build
should work just as good.
// - C/C++ code compiled as part of Rust crates | ||
// For those different kinds, we do have very small code examples that should be | ||
// mitigated in some way. Mostly we check that ret instructions should no longer be present. | ||
cargo().arg("-v").arg("run").arg("--target").arg(target()).current_dir("enclave").run(); |
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.
In order to mitigate LVI, all binary code needs to be mitigated. This test includes code generation for Rust code, inline assembly, global assembly and C/C++ code compiled as part of Rust crates. For the latter there need to be environment variables set:
CC_x86_64_fortanix_unknown_sgx=clang-11 \
CFLAGS_x86_64_fortanix_unknown_sgx="-D__ELF__ -isystem/usr/include/x86_64-linux-gnu -mlvi-hardening -mllvm -x86-experimental-lvi-inline-asm-hardening" \
CXX_x86_64_fortanix_unknown_sgx=clang++-11 \
CXXFLAGS_x86_64_fortanix_unknown_sgx="-D__ELF__ -isystem/usr/include/x86_64-linux-gnu -mlvi-hardening -mllvm -x86-experimental-lvi-inline-asm-hardening" \
we do that in src/ci/docker/host-x86_64/dist-various-2/Dockerfile
. When testing this locally, you may not have this set.
@rustbot author |
Reminder, once the PR becomes ready for a review, use |
We're a tier 2 target. So the Rust project doesn't run any tests. Fortanix has internal CI that watches the Rust repo. |
e240476
to
afe48b4
Compare
Right, that makes some sense historically then. Though there is a lot of variance in what tests do get run for tier-2 targets. e.g. s390x-unknown-linux-gnu gets exercised quite a bit despite being tier 2. For For the |
If the Rust project's policy has changed is this regard we would very much like the test suite to be run for this target as well. |
I don't think it's changed for But run-make requires more setup, and is usually more fragile, so I do think those are limited to tier 1 targets. And then I'm still not sure why the fortanix test is in-tree. |
As a general answer, I doubt there is a clear reason for this. The way we run tests is quite arbitrary in many ways, and there's a lot of historical cruft. So the answer can very possibly be "it's by accident". |
Why wouldn't the test be in-tree? Citing from the target tier policy:
I realize this doesn't require it to be in tree, but that does seem like a logical place for it. In addition, having it in-tree makes the most sense for future promotion to tier 1. |
The test changes look good to me, but since the run-make test is not exercised in CI, can one of the target maintainers @jethrogb @raoulstrackx @aditijannu confirm it works locally on the target as expected and that the test changes look good to you as well? |
ftr even with
(the llvm/clang is from https://www.kernel.org/pub/tools/llvm/) |
Make it more idiomatic with the new run-make infra
afe48b4
to
659ca90
Compare
Firstly, as far as I can tell, no CI job actually runs any of the fortanix tests? Maybe I'm missing the job that runs these tests though?
In any case, the
assembly
tests now useminicore
, meaning that they will run regardless of the host architecture (specifically, they will run during a standard PR CI build).The run-make test is actually broken, and I'd propose to make it just
cargo build
rather thancargo run
. We can have a separate test for actually running the program, if desired.Also this test is subject to #128733, so I'd like to re-evaluate what parts of the C/C++ compilation are actually required or useful.
cc @jethrogb @raoulstrackx @aditijannu
r? @jieyouxu