Skip to content

ceph: Fix build by fully vendoring old cryptography version nix files. - #334286

Merged
nh2 merged 2 commits into
NixOS:masterfrom
nh2:ceph-18.2.4-staging-next-fix
Aug 18, 2024
Merged

nh2 merged 2 commits into
NixOS:masterfrom
nh2:ceph-18.2.4-staging-next-fix

Conversation

@nh2

@nh2 nh2 commented Aug 13, 2024

Copy link
Copy Markdown
Contributor

Fixes ceph build failure on staging-next: https://hydra.nixos.org/build/269104111


With cryptography 42 we can no longer just override the src, because the derivation for 42 can no longer build version 40.

So revive the old version based on:

git show d74195bc77c03b6b7aa7c3433205dd518f245ef2~:pkgs/development/python-modules/cryptography/default.nix > pkgs/development/python-modules/cryptography/40.nix
git show d74195bc77c03b6b7aa7c3433205dd518f245ef2~:pkgs/development/python-modules/cryptography/vectors.nix > pkgs/development/python-modules/cryptography/vectors-40.nix           │

Description of changes

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.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.

Add a 👍 reaction to pull requests you find important.

@nh2 nh2 self-assigned this Aug 13, 2024
@github-actions github-actions Bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Aug 13, 2024
@nh2

nh2 commented Aug 13, 2024

Copy link
Copy Markdown
Contributor Author

No clue yet if it builds, still building.

@nh2

nh2 commented Aug 13, 2024

Copy link
Copy Markdown
Contributor Author

We'll have to check in the VM tests for these errors -- they should be absent:

#281858 (comment)

@nh2

nh2 commented Aug 13, 2024

Copy link
Copy Markdown
Contributor Author

We'll have to check in the VM tests for these errors -- they should be absent:

Tests are passing without the ImportErrors, so this looks good to go.

@nh2
nh2 marked this pull request as ready for review August 13, 2024 04:04
@nh2
nh2 requested a review from natsukium as a code owner August 13, 2024 04:04
@ofborg ofborg Bot added the 8.has: package (new) This PR adds a new package label Aug 13, 2024
@ofborg ofborg Bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Aug 13, 2024
@nh2

nh2 commented Aug 13, 2024

Copy link
Copy Markdown
Contributor Author

I'm not planning to implemented this nixfmt change suggested by the CI:

https://github.com/NixOS/nixpkgs/actions/runs/10363164012/job/28686308371?pr=334286

pkgs/development/python-modules/cryptography/40.nix: not formatted
pkgs/development/python-modules/cryptography/vectors-40.nix: not formatted
Ignoring file pkgs/tools/filesystems/ceph/default.nix because it's not formatted in the base commit
Ignoring file pkgs/top-level/python-packages.nix because it's not formatted in the base commit
Some new/changed Nix files are not properly formatted
Please run the following in `nix-shell`:
nixfmt 'pkgs/development/python-modules/cryptography/40.nix' 'pkgs/development/python-modules/cryptography/vectors-40.nix'
Error: Process completed with exit code 1.

It's formatting it like this, which looks like the most diff-unfriendly way of doing things, and I'm not planning to take on that maintenance burden that will make backports and other cherry-picks left and right:

-{ lib
-, stdenv
-, callPackage
-, buildPythonPackage
-, fetchPypi
-, rustPlatform
-, cargo
-, rustc
-, setuptoolsRustBuildHook
-, openssl
-, Security
-, isPyPy
-, cffi
-, pkg-config
-, pytestCheckHook
-, pytest-subtests
-, pythonOlder
-, pretend
-, libiconv
-, libxcrypt
-, iso8601
-, py
-, pytz
-, hypothesis
-}:
+{ lib, stdenv, callPackage, buildPythonPackage, fetchPypi, rustPlatform, cargo
+, rustc, setuptoolsRustBuildHook, openssl, Security, isPyPy, cffi, pkg-config
+, pytestCheckHook, pytest-subtests, pythonOlder, pretend, libiconv, libxcrypt
+, iso8601, py, pytz, hypothesis }:

This seems more wrong than makes sense to me -- does staging-next have an incorrect version of nixfmt somehow?

@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/satisfaction-survey-from-the-new-rfc-166-formatting/49758/30

@infinisil

Copy link
Copy Markdown
Member

@nh2 It looks like you're using nixfmt classic, not the RFC styled one. If you enter the nix-shell (which the error does mention btw :P), you'll have the right pinned version available.

@mweinelt

Copy link
Copy Markdown
Member

FYI: This version has at least two known security vulnerabilities around creating PKCS#12 bundles (CVE-2024-26130) and when loading PKCS#7 bundles (CVE-2023-49083).

@emilazy

emilazy commented Aug 13, 2024

Copy link
Copy Markdown
Member

Maybe we should slap knownVulnerabilities on it until we can get Ceph working with a version that isn’t known‐insecure. (Though I guess if Ceph doesn’t exercise any of that functionality it should probably be fine if we move it so that it’s internal to the Ceph package and not exposed as an attribute.)

@mweinelt

Copy link
Copy Markdown
Member

Or migrate to Ceph 19.1.x (19.2.0 would be the final release), as Ubuntu and Fedora have done it.

@emilazy

emilazy commented Aug 13, 2024

Copy link
Copy Markdown
Member

If Ubuntu and Fedora are fine with a pre‐release that seems better than bringing back an outdated version of a security library.

@nh2

nh2 commented Aug 13, 2024 •

Copy link
Copy Markdown
Contributor Author

It looks like you're using nixfmt classic, not the RFC styled one. If you enter the nix-shell (which the error does mention btw :P), you'll have the right pinned version available.

@infinisil Ah indeed, that fixed it. The new formatting is good!

I had run

NIX_PATH=nixpkgs=. nix-shell -p nixfmt

which brought me nixfmt-0.6.0 while to get nixfmt-unstable-2024-07-12 one needs to run just

NIX_PATH=nixpkgs=. nix-shell

in the top-level of nixpkgs.

I didn't get that

Please run the following in `nix-shell`:

means to literally run nix-shell -- I had thought it meant to use nix-shell to obtain nixfmt (that is, via -p).

It might make sense to make that message even clearer to avoid the confusion.

@nh2
nh2 force-pushed the ceph-18.2.4-staging-next-fix branch from 3edeb6d to 892dd6b Compare August 13, 2024 12:33
@nixos-discourse

Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/satisfaction-survey-from-the-new-rfc-166-formatting/49758/32

@nh2
nh2 force-pushed the ceph-18.2.4-staging-next-fix branch from 892dd6b to 2373da6 Compare August 13, 2024 12:39
@nh2

nh2 commented Aug 13, 2024

Copy link
Copy Markdown
Contributor Author

This version has at least two known security vulnerabilities around creating PKCS#12 bundles (CVE-2024-26130) and when loading PKCS#7 bundles (CVE-2023-49083).

The commit I pushed (and the code in nixpkgs before this PR) already has a backported fix for one of them:

  patches = [
    # Fix https://nvd.nist.gov/vuln/detail/CVE-2023-49083 which has no upstream backport.
    # See https://github.com/pyca/cryptography/commit/f09c261ca10a31fe41b1262306db7f8f1da0e48a#diff-f5134bf8f3cf0a5cc8601df55e50697acc866c603a38caff98802bd8e17976c5R1893
    ./python-cryptography-Cherry-pick-fix-for-CVE-2023-49083-on-cryptography-40.patch
  ];

I will try to patch the other one also.

Maybe we should slap knownVulnerabilities on it until we can get Ceph working with a version that isn’t known‐insecure. (Though I guess if Ceph doesn’t exercise any of that functionality it should probably be fine if we move it so that it’s internal to the Ceph package and not exposed as an attribute.)

These sounds like good alternative options in case the fix can't be backported.

Or migrate to Ceph 19.1.x (19.2.0 would be the final release), as Ubuntu and Fedora have done it.

That would be way above my (and my org's) risk tolerance -- I imagine it is the same for many other industrial Ceph users (as loss of data in our Ceph storage cluster would be devastating).

I would only upgrade to a new Ceph version when it's fully released and the release and upgrade notes are certain to contain all important points.

@nh2
nh2 force-pushed the ceph-18.2.4-staging-next-fix branch from 2373da6 to acd6f8d Compare August 13, 2024 20:12
@nh2

nh2 commented Aug 13, 2024

Copy link
Copy Markdown
Contributor Author

I will try to patch the other one also.

Done, that was easy the patch applied cleanly.

Ready for another round of review now.

@emilazy

emilazy commented Aug 13, 2024

Copy link
Copy Markdown
Member

Would you be comfortable with vendoring the Python libraries under the Ceph directory and importing them in a let rather than an exposed attribute? That way nobody is likely to stumble into using a version they really ought not to by just using cryptography_40 the first time they get a dependency error with some other outdated software.

@nh2
nh2 force-pushed the ceph-18.2.4-staging-next-fix branch 2 times, most recently from 8dbaf0b to 6a42d58 Compare August 17, 2024 16:01
@alyssais alyssais added the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 17, 2024
Comment thread pkgs/tools/filesystems/ceph/default.nix Outdated
Comment on lines 227 to 232

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it’d be better to do this in the actual fastapi if we want to do it, rather than hacking around it for a specific downstream package?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know whether it's flaky in general or only in this overridden package set. I've added a comment for that now.

I only observed it in this package set, not sure whether that justifies disabling tests also for normal fastapi.

@nh2
nh2 force-pushed the ceph-18.2.4-staging-next-fix branch from 6a42d58 to b0b9078 Compare August 17, 2024 19:11
@github-actions github-actions Bot removed the 6.topic: python Python is a high-level, general-purpose programming language. label Aug 17, 2024
@nh2
nh2 force-pushed the ceph-18.2.4-staging-next-fix branch 2 times, most recently from aac007d to cc6a7b1 Compare August 17, 2024 19:16

@emilazy emilazy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me; I think the old cryptography version is sufficiently hidden away and we should be able to get rid of it on the next major Ceph release. I’m going to merge to unblock qemu-full and if we have further nitpicks about the Python packaging we can always adjust later. Thanks for this!

@ofborg ofborg Bot added 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 2.status: merge conflict This PR has merge conflicts with the target branch 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels Aug 17, 2024
Comment thread pkgs/tools/filesystems/ceph/default.nix Resolved
@nh2
nh2 force-pushed the ceph-18.2.4-staging-next-fix branch from cc6a7b1 to 16e1c4b Compare August 18, 2024 20:56
@emilazy

emilazy commented Aug 18, 2024

Copy link
Copy Markdown
Member

Oops, I forgot to check on the build and merge…

Will do so after @dotlambda’s review comments are addressed and I double‐check the build.

With cryptography 42 we can no longer just override the `src`,
because the derivation for 42 can no longer build version 40.

So revive the old version based on:

    git show d74195b~:pkgs/development/python-modules/cryptography/default.nix > pkgs/development/python-modules/cryptography/40.nix
    git show d74195b~:pkgs/development/python-modules/cryptography/vectors.nix > pkgs/development/python-modules/cryptography/vectors-40.nix           │

Also:

* Include a patch for CVE-2024-26130
* Run `nixfmt` on them.
* `Securiy` -> `Security ? null` because in the local override
  it doesn't seem to pass that Darwin-specific package on Linux;
  avoids error:
      Function called without required argument "Security"
@nh2
nh2 force-pushed the ceph-18.2.4-staging-next-fix branch from 16e1c4b to 36459ca Compare August 18, 2024 21:35
@nh2

nh2 commented Aug 18, 2024

Copy link
Copy Markdown
Contributor Author

Fixed the comments, and I checked the build again with the rebase. Merging.

@nh2
nh2 merged commit b42b780 into NixOS:master Aug 18, 2024
@nh2

nh2 commented Aug 18, 2024

Copy link
Copy Markdown
Contributor Author

Next Ceph PR is at: #335684

@nh2

nh2 commented Sep 1, 2024

Copy link
Copy Markdown
Contributor Author

Follow-up to #334286 (comment):

Or migrate to Ceph 19.1.x, as Ubuntu and Fedora have done it.

Looks like Ubuntu's Upgrade to Ceph 19 screwed multiple users, see https://old.reddit.com/r/ceph/comments/1f2osic/whats_going_on_with_ceph_v19_squid/:

Ubuntu really did help this mess by putting squid dev releases into 24.04 repos

and

Well that explains why everything has been failing...

Installed cephadm on ubuntu and bootstrapped but it's on 19.0 it's asked/trying to upgrade to 19.1 and having failures left and right.

How fucked am I? How the hell do I get the right thing installed if the one in the repo is a fake version not meant for use the fuck?

So I'm happy to be conservative here and backport fixes to dependencies of less essential components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

8.has: package (new) This PR adds a new package 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build failure: ceph 18.2.4 (via python3.11-cryptography 40.0.1)

8 participants