-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
cc-wrapper: disable incompatible hardening options in cpu bit size cross #335023
base: staging
Are you sure you want to change the base?
cc-wrapper: disable incompatible hardening options in cpu bit size cross #335023
Conversation
0344866
to
32cd5ee
Compare
@ofborg eval |
32cd5ee
to
15546e4
Compare
@ofborg eval |
c32e6ae
to
11284d6
Compare
11284d6
to
388a28d
Compare
Nice! Would this let us drop some of the various |
Likely, it'll probably a more reasonable change to use |
I think it's important @Ericson2314 has a look at the lib changes before this goes in. I'm not sure myself whether it makes sense to try to map between 64-bit and 32-bit triples, because there could be multiple sensible options. |
Yeah, the problem here is we have to detect when clang is using the 32 bit or 64 bit triple. I figured it was easier to use lib.systems to help with that and then pulling only the arch out and matching based on that inside cc-wrapper. More feedback on this implementation would be great. |
388a28d
to
a10ec98
Compare
Currently blocked on review. (@Ericson2314 , can you take a look?) |
a10ec98
to
547ffcb
Compare
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.
After further discussion on Matrix, I don’t believe this is the right approach to the problem. The fundamental issue is that we are setting default hardening flags for a different host platform than we’re compiling for. This is essentially a cross‐compilation scenario and so #354622 would be a step in the right direction. In this case, it wouldn’t fix it, because we’re using the same wrapped compiler to build for two different architectures. Unfortunately, that is fundamentally broken right now in general. Maintaining a mapping between 64‐ and 32‐bit architectures is also not really something that can make sense in general. I believe the appropriate ways forward are:
-
Use an unwrapped compiler to compile the VDSO32 for now; this would work with Clang since it’s natively multi‐target, and with GCC since it’s effectively “dual‐target”. I think this is the most expedient short‐term fix.
-
Make it easier to re‐wrap our compilers for different architectures, and use a re‐wrapped compiler.
-
Rework our wrappers to work natively multi‐target. This would be the best option but would be a large undertaking.
Description of changes
As the title says, this disables incompatible hardening options when cross compiling between the same ISA but different bit size. This prevents the issue of the
zerocallregs
hardening option from being used when using clang to build Linux and Linux is building for aarch64 but builds vdso32.@K900 initially suggested the idea that we prevent that behavior inside of the cc-wrapper instead of hardcoding derivations to disable the
zerocallregs
hardening option altogether inside of the Linux kernel derivation.Can be tested by building
pkgsLLVM.linux
on aarch64-linux.Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.