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

libcrypt.so.1: support newer hash types via libxcrypt #112371

Closed
2 of 10 tasks
dottedmag opened this issue Feb 8, 2021 · 14 comments
Closed
2 of 10 tasks

libcrypt.so.1: support newer hash types via libxcrypt #112371

dottedmag opened this issue Feb 8, 2021 · 14 comments
Labels
0.kind: bug Something is broken

Comments

@dottedmag
Copy link
Contributor

dottedmag commented Feb 8, 2021

This is more "intent to implement" rather than a bug report.

Describe the bug

glibc's libcrypt implementation supports a narrow range of hashes, and none of modern RAM-heavy ones.

glibc maintaines would like to spin this library off into a separate project and drop libcrypt from the glibc altogether.

Some distributions have already switched to API- and ABI-compatible libxcrypt:

Expected behaviour

All packages that use libcrypt.so.1 can use strong hash types.

Action plan

  • Package libxcrypt.
  • Add a flag withLibcrypt (defaults to true) to glibc package that disables building and installing libcrypt.so.1 and crypt.h if set to false.
  • One-by-one update packages that expect libcrypt.so.1 in glibc by giving them a flag useGlibcLibcrypt (defaults to true).
  • Add a global setting useGlibcLibcrypt (defaults to true), and disable withLibgcrypt in glibc and useGlibcLibgcrypt in other packages it is set to false.
  • Wait until the dust settles.
  • Switch useGibcLibcrypt to default to false.
  • Wait until the dust settles.
  • Remove withLibcrypt, useGlibcLibcrypt from packages, make useGlibcLibcrypt no-op.

Known issues

I have stumbled upon the following problems while doing a PoC on the packages I regularly use (not the whole archive):

  • I have no idea how to make the global flag be respected
  • ppp expects and checks libcrypt in glibc

Affected packages

Normally it would be easy to do a reverse-dependency search to see what relies on a particular library. However with a library bundled in glibc the tree of reverse dependencies is not particularly useful.

I have greped the whole nixos-unstable and manually processed the results. Attached is the list of

  • Packages with files that link to libcrypt.so.1 and actually use symbols from them (+++)
  • Packages with files that link to libcrypt.so.1, but don't actually use any symbols (???)
  • Packages with files that mention libcrypt.so.1, but don't link to it (mostly text) (XXX).

This is a very rough list, the only way to get a definite list is by rebuilding the archive, however it should suffice as a starting point.

libcrypt-users.txt

Notify maintainers
@edolstra

@Izorkin
Copy link
Contributor

Izorkin commented Jun 10, 2021

It is possible to add tcb support? - #109457

@dottedmag
Copy link
Contributor Author

libxcrypt is already packaged in nixpkgs, so I don't see why it wouldn't be possible. See the linked linux-pam package change as a guide.

@Izorkin
Copy link
Contributor

Izorkin commented Jun 10, 2021

I failed to configure linux-pam and patch passwd.

@lukegb
Copy link
Contributor

lukegb commented Aug 14, 2021

@dottedmag Are you still working on this?

I propose that we get a new Hydra jobset so we can smoke out these deps (i.e. we push a jobset with glibc's libcrypt disabled and see what breaks)

@dottedmag
Copy link
Contributor Author

I took a hiatus from working on NixOS at the moment, but still intend to do it some time in the future.

@lukegb
Copy link
Contributor

lukegb commented Aug 14, 2021

No worries - do you mind if I pick it up for the moment?

@dottedmag
Copy link
Contributor Author

Sure, feel free to.

@mweinelt
Copy link
Member

mweinelt commented Aug 17, 2021

ppp expects and checks libcrypt in glibc

ppp does not depend on libcrypt from glibc anymore since 2.4.8 (ppp-project/ppp@3c7b862), so that should not be a blocker anymore.

@bbjubjub2494
Copy link
Member

openssh appears to currently be incompatible with pamWithLibxcrypt. Unclear to me exactly why.

source

Nov 27 08:14:45 nixos systemd[860]: PAM unable to dlopen(/nix/store/jjdm85j98ih9d28hkcs8px5k218mcrpr-linux-pam-1.5.1/lib/security/pam_unix.so): /nix/store/z56jcx3j1gfyk4sv7g8iaan0ssbdkhz1-glibc-2.33-56/lib/libcrypt.so.1: version `XCRYPT_2.0' not found (required by /nix/store/jjdm85j98ih9d28hkcs8px5k218mcrpr-linux-pam-1.5.1/lib/security/pam_unix.so)
Nov 27 08:14:45 nixos systemd[860]: PAM adding faulty module: /nix/store/jjdm85j98ih9d28hkcs8px5k218mcrpr-linux-pam-1.5.1/lib/security/pam_unix.so
Nov 27 08:14:45 nixos systemd[860]: PAM failed: Module is unknown
Nov 27 08:14:45 nixos systemd[860]: user@0.service: Failed to set up PAM session: Operation not permitted
Nov 27 08:14:45 nixos systemd[860]: user@0.service: Failed at step PAM spawning /nix/store/az8yvxswppdwn9zpm377rzfjk5gwak3b-systemd-249.5/lib/systemd/systemd: Operation not permitted

@mweinelt
Copy link
Member

mweinelt commented Feb 22, 2022

@lukegb @lourkeur Anyone still working on this? Does everyone agree with the steps mentioned in the action plan?

Add a flag withLibcrypt (defaults to true) to glibc package that disables building and installing libcrypt.so.1 and crypt.h if set to false.

This is probably just --disable-crypt in configureFlags within glibc's common.nix.

@bbjubjub2494
Copy link
Member

@mweinelt I use a quick and dirty overlay on the daily but I am not working on a proper solution. I think broadly the action plan is correct.

@mweinelt
Copy link
Member

mweinelt commented Jul 16, 2022

This is probably just --disable-crypt in configureFlags within glibc's common.nix.

diff --git a/pkgs/development/libraries/glibc/common.nix b/pkgs/development/libraries/glibc/common.nix
index 2fc89a968f8..2ea58072014 100644
--- a/pkgs/development/libraries/glibc/common.nix
+++ b/pkgs/development/libraries/glibc/common.nix
@@ -36,6 +36,7 @@
 , withLinuxHeaders ? false
 , profilingLibraries ? false
 , withGd ? false
+, withLibcrypt ? true
 , meta
 , extraBuildInputs ? []
 , extraNativeBuildInputs ? []
@@ -201,7 +202,9 @@ stdenv.mkDerivation ({
       # To avoid linking with -lgcc_s (dynamic link)
       # so the glibc does not depend on its compiler store path
       "libc_cv_as_needed=no"
-    ] ++ lib.optional withGd "--with-gd";
+    ]
+    ++ lib.optional withGd "--with-gd"
+    ++ lib.optional (!withLibcrypt) "--disable-crypt";
 
   makeFlags = [
     "OBJCOPY=${stdenv.cc.targetPrefix}objcopy"
diff --git a/pkgs/development/libraries/glibc/default.nix b/pkgs/development/libraries/glibc/default.nix
index ba782321559..d34bbdccf25 100644
--- a/pkgs/development/libraries/glibc/default.nix
+++ b/pkgs/development/libraries/glibc/default.nix
@@ -2,6 +2,7 @@
 , withLinuxHeaders ? true
 , profilingLibraries ? false
 , withGd ? false
+, withLibcrypt? false
 , buildPackages
 }:
 
@@ -16,7 +17,7 @@ in
 callPackage ./common.nix { inherit stdenv; } {
     pname = "glibc" + lib.optionalString withGd "-gd";
 
-    inherit withLinuxHeaders profilingLibraries withGd;
+    inherit withLinuxHeaders profilingLibraries withGd withLibcrypt;
 
     # Note:
     # Things you write here override, and do not add to,

@mweinelt
Copy link
Member

mweinelt commented Oct 10, 2022

We are now in staging and everything is scheduled for this going live in 22.11. https://nixpk.gs/pr-tracker.html?pr=181764

There are some additional changes (docs, release notes, deprecations) that I'm currently working over in #195271. Reviews welcome.

@mweinelt
Copy link
Member

Fixed in #195271.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

5 participants