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

[20.03] systemd: apply patch for CVE-2020-13776 #91048

Merged

Conversation

flokli
Copy link
Contributor

@flokli flokli commented Jun 18, 2020

Fixes #90982.

Motivation for this change

https://nvd.nist.gov/vuln/detail/CVE-2020-13776

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs 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/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@flokli
Copy link
Contributor Author

flokli commented Jun 18, 2020

@GrahamcOfBorg test systemd

@picnoir
Copy link
Member

picnoir commented Jun 18, 2020

Let's add the passthru tests:

diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix
index 3235fb3b95c..3cf62261bd9 100644
--- a/pkgs/os-specific/linux/systemd/default.nix
+++ b/pkgs/os-specific/linux/systemd/default.nix
@@ -7,6 +7,7 @@
 , gettext, docbook_xsl, docbook_xml_dtd_42, docbook_xml_dtd_45
 , ninja, meson, python3Packages, glibcLocales
 , patchelf
+, nixosTests
 , substituteAll
 , getent
 , buildPackages
@@ -295,7 +296,12 @@ in stdenv.mkDerivation {
   # in a backwards-incompatible way.  If the interface version of two
   # systemd builds is the same, then we can switch between them at
   # runtime; otherwise we can't and we need to reboot.
-  passthru.interfaceVersion = 2;
+  passthru = {
+    interfaceVersion = 2;
+    tests = {
+      main = nixosTests.systemd;
+    };
+  };
 
   meta = with stdenv.lib; {
     homepage = "https://www.freedesktop.org/wiki/Software/systemd/";

[Edit]: my bad, this is on 20.03 ><

@flokli
Copy link
Contributor Author

flokli commented Jun 18, 2020

Let's do this for master, but if systemd breaks to build in stable, we should notice :-)

@ckauhaus
Copy link
Contributor

LGTM

@picnoir
Copy link
Member

picnoir commented Jun 18, 2020

Don't we want to include systemd/systemd#16033 as well? (see this thread for context)

@flokli
Copy link
Contributor Author

flokli commented Jun 18, 2020

While I agree this is probably desirable, it's 9 patches, and some don't apply cleanly on our 243.7 (which is unfortunately what we have in stable, and they don't see to be backported to systemd-stable/v243-stable branch, as it's too old). Would you be up to creating such a patchset?

I'd need to further dig if the patch inside this PR is enough to fix CVE-2020-13776, or if we need to backport more fixes.

On the other hand, I'm wondering how other stable distros with older systemd versions handle this. Do they just always bump to the most recent major version, or do they maintain a patchset?

@picnoir
Copy link
Member

picnoir commented Jun 22, 2020

I digged into this patchset.

CVE-2020-13776 is fixed by 156a5fd297b61bce31630d7a52c15614bf784843. See the https://github.com/systemd/systemd/pull/15991/files#diff-15f67a613ddd6933b407b80c01f2ae5eR53 test. In that regard, this PR should be good.

The systemd second PR I linked in my previous post is refactoring the various integer parsers. While it's not mitigating any CVE, it's mitigating some potential bugs with +-prefixed uids (which are not supposed to be valid as per the posix specification). f5979b63cc305ba217dfd174b1bf0583bcf75a73 might be particularly interesting to backport. That being said, it'll depend on 5 commits coming from this patchset. Provided the original 6.7 score, I wouldn't bother to backport that. Note: I may be wrong, I'd like a second opinion on that.

On the other hand, I'm wondering how other stable distros with older systemd versions handle this. Do they just always bump to the most recent major version, or do they maintain a patchset?

That's a good question, I have no idea, let's have a look.

Debian, Fedora and Archlinux are targeting github/systemd/systemd-stable.

Debian:

Arch:

Fedora:

This repo is supposed to contain the necessary backports for 245.x.

This particular CVE hasn't been backported to systemd-stable though. Debian, Fedora and Arch are still subject to CVE-2020-13776.

That being said, systemd-stable is maintained by the systemd team, which can probably make some better decisions about what to backport than we can do. These backports are also painfree on our side since upstream is also in charge of cherry-picking the backports dependencies ;)

Overall, I think we should start following systemd-stable in place of systemd, at least for NixOS stable.

Let's merge this PR first though.

@flokli
Copy link
Contributor Author

flokli commented Jun 22, 2020

Debian, Fedora and Archlinux are targeting github/systemd/systemd-stable.

This repo is supposed to contain the necessary backports for 245.x.

This particular CVE hasn't been backported to systemd-stable though. Debian, Fedora and Arch are still subject to CVE-2020-13776.

Thanks for the digging! I'll poke upstream to do a new point release.

Edit: done at systemd/systemd-stable#70

@flokli
Copy link
Contributor Author

flokli commented Jun 22, 2020

CVE-2020-13776 is fixed by 156a5fd297b61bce31630d7a52c15614bf784843. See the https://github.com/systemd/systemd/pull/15991/files#diff-15f67a613ddd6933b407b80c01f2ae5eR53 test. In that regard, this PR should be good.

Agreed, let's merge this into staging-20.03.

@flokli flokli merged commit c43d66f into NixOS:staging-20.03 Jun 22, 2020
@flokli flokli deleted the 20.03-systemd-243.7-CVE-2020-13776 branch June 22, 2020 10:53
@flokli
Copy link
Contributor Author

flokli commented Jun 22, 2020

@NixOS/nixos-release-managers, @vcunat, can you take care of piping this through the staging process?

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

Successfully merging this pull request may close these issues.

None yet

3 participants