-
-
Notifications
You must be signed in to change notification settings - Fork 14k
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
hardening flags: enable fortify3
by default
#224822
Conversation
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 think it's a reasonable change.
There is a mild chance to produce crashing binaries as a result, but it should be fixable on one-by-one case and should not be too widespread (my guesstimate is less than 10 affected packages).
This is meant to miss 23.05, right? |
Open for discussion as far as I'm concerned. |
FYI, freeze for similar kind of stuff is within two weeks latest. |
I'm very much in favour of this, but I think I prefer merging this after the branch-off so that we don't end up having to put a lot of fixes in both 23.05 and master after the release, so this lands in 23.11 having had plenty of testing on unstable. |
aad33d6
to
db3e94c
Compare
(just a straight rebase) |
Some links to information/discussion about this:
Since performance came up on Matrix: per the above links, there is no measured impact on the SPEC2000/SPEC2017 benchmarks (in fact a slight improvement in parts of the former), and the average binary size change is ~0.00%. Any performance impacts would be edge-cases where the compiler cannot hoist/optimize away the checks inside a tight loop. Since this is on track for wide adoption (accepted by Fedora, already enabled for OpenSUSE ALP and for Gentoo's hardened profile, not sure about Debian/Ubuntu) I think any such relevant edge-cases will be found regardless of what we do; I believe the benefits are clearly worth the extremely minimal cost. |
Thanks for providing the references. I think I have seen something like that but I couldn't find it on the links at the top of this PR. Here's a -small evaluation: https://hydra.nixos.org/eval/1797023?compare=1797074#tabs-now-fail |
Those all seem to trickle back to |
Personally I would just add |
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.
libfido2 changes ACK
I went through the references, and it really does sound good to me. And yes, on my last post I somehow forgot that recognized issues should be trivially solved by that line, so I think it's better to deal with regressions during |
Those redefinition errors happen in quite a lot of packages. So disabling fortify3 really seems the best way for them? (before "we" copy&paste it on so many places) |
Is it an actual incompatibility or packages trying to "opt in" to |
Of course I meant disabling individually, like the second commit in this PR. |
Sorry, rephrase: maybe we can handle the cases where |
I suspect that some global |
Maybe some inspiration could be found in Fedora or OpenSUSE, too 🤷🏽 |
It looks like in the case of libfido2, it's just passing |
It broke build: https://hydra.nixos.org/build/227264335 Motivation: coreboot-toolchain.* depend on gnat11. It's just a hack-fix. gnat12 seems OK, just as other languages on 11, at least those built on Hydra. /cc PR #224822 which enabled the flag.
It's enabled by default in nixos: NixOS/nixpkgs#224822
These warnings are quite widespread and annoying. I also note that, because our hardening flags are prepended to the invocation's command line, in cases where the build process also sets So.. a few options to resolve this:
Opinions? I think in principal I'd prefer forcing our setting, but the simplicity of the first option is seductive and is closest to what is already happening. |
I expect that packages setting this to 2 didn't mean to lower fortification and won't cause issues when 3 is forced. (in 99% cases) |
Fun fact: With more widespread |
See #246067 for an implementation of the first (least intrusive) option. |
In #246067, @amjoseph-nixpkgs and @emilazy seem to prefer the alternative idea of appending our In particular I'm thinking less about cc as used in derivations, but more cc used as a command-line development tool. Trying to test something with e.g. Still, I'll put up a PR with that approach.. |
Hmm, the command-line usage example does point to a tension here, since my intuitive expectation there would be that it overrides. It's arcane enough that I'm not sure whether it overrides my concern about packages silently (or deliberately due to log noise) getting downgraded hardening, though. The Nix toolchains are already a little weird for non-Nix use. I think ideally we would get upstream to stop overriding hardening flags or patch them out ourselves, but I realize that that's a lot of work. |
Have added some tests covering the flags-before/after behaviour to #217390 |
Caused |
#246244 is currently looking like the least-unpopular option. |
Description of changes
See #212498 where
fortify3
support was added for more information.This is mostly to get the discussion going ahead of 23.05. I personally think we should follow other distributions' lead (fedora and opensuse) in enabling it by default - they have reported few if any problems with it AFAIK.See #217390 for some tests around this and #219421 for an attempt to add basic fortify support for musl.
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)