Skip to content
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

[staging] {cc,binutils}-wrapper: fixes for PIE hardening #135619

Merged
merged 5 commits into from Sep 24, 2021

Conversation

r-burns
Copy link
Contributor

@r-burns r-burns commented Aug 25, 2021

Fixes a number of packages which were broken on musl (where PIE hardening is currently enabled). For example:

  • pkgsMusl.python3
  • pkgsMusl.bulletml
  • pkgsMusl.proot
  • pkgsMusl.libfsm
  • pkgsMusl.libiscsi
  • pkgsMusl.nsjail
  • pkgsMusl.pv
Motivation for this change

Fixes #124476

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@r-burns r-burns changed the title {cc,binutils}-wrapper: fixes for PIE hardening [staging] {cc,binutils}-wrapper: fixes for PIE hardening Aug 25, 2021
@veprbl veprbl added this to WIP in Staging via automation Aug 25, 2021
@veprbl veprbl moved this from WIP to Needs review in Staging Aug 25, 2021
nomeata added a commit to dfinity/motoko that referenced this pull request Aug 25, 2021
in #2532 we added a patch related to static building of ocaml packages,
submitted to nixpkgs as NixOS/nixpkgs#124498,
but it was never merged upstream.

Supposedly a patch from NixOS/nixpkgs#135619
fixes it as well (and maybe more properly). So let’s try that!
@r-burns
Copy link
Contributor Author

r-burns commented Sep 4, 2021

cc @TredwellGit since it looks like you're running into some of these issues in #104091

fixes:
pkgsMusl.bulletml
pkgsMusl.proot
pkgsMusl.python3

Debian explains this issue well in the dpkg-buildflags manpage:

-fPIE
    Can be linked into any program, but not a shared library (recommended).
-fPIC
    Can be linked into any program and shared library.

On projects that build both programs and shared libraries you might need to
make sure that when building the shared libraries -fPIC is always passed last
(so that it overrides any previous -PIE) to compilation flags such as CFLAGS.

(from https://manpages.debian.org/bullseye/dpkg-dev/dpkg-buildflags.1.en.html#hardening)
fixes e.g.:
pkgsMusl.libfsm
pkgsMusl.libiscsi
pkgsMusl.nsjail
pkgsMusl.pv

match strings have whitespace on either side, which wasn't
matching leading/trailing arguments previously
This is no longer needed with the previous PIE hardening fixes.

This reverts commit 78d20f2.
This is no longer needed with the previous PIE hardening fixes.

This reverts commit 74e0aaa.
This is no longer needed with the previous PIE hardening fixes.

This reverts commit 2784f1b.
Staging automation moved this from Needs review to Ready Sep 21, 2021
@r-burns r-burns merged commit 1672828 into NixOS:staging Sep 24, 2021
Staging automation moved this from Ready to Done Sep 24, 2021
@r-burns r-burns deleted the fpie-musl-fixes branch September 24, 2021 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Staging
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants