rustPlatform.buildRustPackage: build auditable binaries#204686
rustPlatform.buildRustPackage: build auditable binaries#204686figsoda merged 13 commits intoNixOS:stagingfrom
Conversation
|
Any other distros doing this? Besides void? |
|
just void right now as far as I'm aware |
TBH I think making it the default is a bit premature. Keep it opt-in for testing and revisit making it the default has been in master for a few weeks? |
|
IMO not making it the default (in the long run) defeats the purpose since it is not in cache, and you would have to build the package first to be able to audit it maybe we can opt in for a small set of packages and make it the default when it's observed to be stable? |
|
Given that the changes to the hook will cause every package to be rebuilt anyway I don't think there's necessarily much harm in enabling it by default now, but I'm also not familiar enough with the Rust ecosystem to know whether or not just doing this is likely to be harmful in some edgecase. |
^ This is what I meant when I said this:
Don't see how this makes any difference as packages will be rebuilt in the following staging cycles anyway?
Reverting it after it is in master would mean another staging cycle so I think a change that affects every use of |
|
I think my main complaint is that "a bit of testing" does not a testing plan make :) (I'm not saying you should single-handedly produce a testing plan, this is more of a comment that it's not clear what sort of rollout plan you'd like to see) I agree that it is probably a good idea to do some form of testing, but also... this is nixos-unstable. The purest form of smoke testing here would be "running all the NixOS tests that exist and seeing if they pass", which is a good bet to happen in staging-next, and if there are any obvious problems there it's easy to back out. I agree if it escapes into master then it's a bit more annoying to revert but at least we'll have evidence of real problems at that point. What sort of shape of testing would you be interested in to help build confidence in this change? |
This sounds good:
|
|
changed |
|
I suggest also trying it with |
|
It's currently not possible with |
|
Maybe |
pkgs/tools/video/rav1e/default.nix
Outdated
|
|
||
| postBuild = '' | ||
| cargo cbuild --release --frozen --prefix=${placeholder "out"} --target ${rustTargetPlatformSpec} | ||
| $cargoCommand cbuild --release --frozen --prefix=${placeholder "out"} --target ${rustTargetPlatformSpec} |
There was a problem hiding this comment.
Doesn't need to happen in this PR but any way we could avoid needing to do this? i.e wrap cargo-auditable as cargo or something like that?
There was a problem hiding this comment.
How do we stop the wrapper from recursively calling itself? Looks like cargo-auditable just calls cargo directly
There was a problem hiding this comment.
Maybe we can look at CARGO_AUDITABLE_ORIG_ARGS, but I'm not sure if we should rely on that since it is internal and undocumented
There was a problem hiding this comment.
Another way to do it is just to add something like a cargoAuditableHook that sets RUSTC_WORKSPACE_WRAPPER
There was a problem hiding this comment.
How do we stop the wrapper from recursively calling itself? Looks like cargo-auditable just calls
cargodirectly
Make cargo into cargo-unwrapped, substitute cargo for cargo-unwrapped in cargo-auditable and then wrap it?
There was a problem hiding this comment.
Make
cargointocargo-unwrapped
Sounds like the most future-proof way of doing it, but it would complicate the bootstrap process a bit.
Due to the complexity of this, I think it is worth a separate issue once this is merged
There was a problem hiding this comment.
Due to the complexity of this, I think it is worth a separate issue once this is merged
That's fine but I do think it's something that should be resolved before auditable is made the default.
$cargoCommand in an "extra" step like it is here isn't too bad but much easier for everyone if people don't need to know about it.
Should also mean that it works without changes for packages that have cmake, make, meson, etc build systems calling cargo.
There was a problem hiding this comment.
Hey! cargo auditable author here 👋
I'll see what I can do about providing a robust way of using cargo auditable as a drop-in replacement for cargo.
Here's the upstream issue so you can track the progress: rust-secure-code/cargo-auditable#89
There was a problem hiding this comment.
Using cargo auditable as a drop-in replacement for cargo is now possible on latest git, see here: rust-secure-code/cargo-auditable#89 (comment)
Let me know if it works for you. If so, I'll document it in more detail and ship a release.
There was a problem hiding this comment.
@Shnatsel thanks for all the work on cargo-auditable!
It works. I wasn't able to use an alias since cargoBuildHook uses env, which doesn't pick up aliases, but a shell script wrapper does the job
Also not aware of other distros, but we've been building any update to Rust packages that use the cargo build style with auditable, and we have not run into problems with it. Are there any other distros where adopting this would be easy to implement? I've looked at both Arch and Alpine, and they don't abstract away the build commands into a build style or hook it something like that, meaning that adopting that for all packages is a way bigger change than it would be for Void or NixOS. |
|
I've seen some interest from Debian. They have shared build configurations, so it is feasible. But that effort is not very far along yet. See rust-secure-code/cargo-auditable#82 for more info. |
|
I added Made It should be simple to add auditable support for |
|
I've released |
|
To clarify the potential failure modes: If something goes wrong, the build should fail. It is highly unlikely that a build would produce a non-functional binary, since the data injection mechanism is lifted directly from the Rust compiler, so it's well-tested. And it simply emits an additional object file for the linker to process, so it simply reuses through all the usual, well-trodden codepaths. |
|
@zowoq is this good to merge? |
|
When auditable is set to true, this causes a regression when cross-compiling rust packages where a cross-compiled rustc and cargo end up in the closure (causing failures since that doesn't work yet): Setting auditable to false will prevent this issue, but since you want to make it default it would be great if you could ensure that this regression is solved before defaulting to it. |
Description of changes
closes #200563
bootstraps
cargo-auditableand makes all packages built bybuildRustPackageauditable unless overridden withauditable = falsebuilt
fdon master and ranrust-audit-infoon it, it should have no sizable impact on binary sizeThings done
sandbox = trueset 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/)nixos/doc/manual/md-to-db.shto update generated release notes