Skip to content

Commit a432668

Browse files
committed
dhcpcd: disable privsep by default
The priviledge separation mode has several downsides: - it's incompatible with alternative memory allocators, including graphene-hardened; - it needs an unreleased patch to fix a crash; - it results in none less than 6 subprocesses running at any time, increasing the memory usage; - the privileged process (albeit not doing any networking related tasks) is still running as root, so it has complete access to the system. Let's disable this by default and instead run dhcpcd as an unpriviledge user with only the necessary capabilities.
1 parent 19a4941 commit a432668

4 files changed

Lines changed: 4 additions & 38 deletions

File tree

nixos/modules/services/networking/dhcpcd.nix

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -206,22 +206,6 @@ in
206206

207207
config = lib.mkIf enableDHCP {
208208

209-
assertions = [ {
210-
# dhcpcd doesn't start properly with malloc ∉ [ libc scudo ]
211-
# see https://github.com/NixOS/nixpkgs/issues/151696
212-
assertion =
213-
dhcpcd.enablePrivSep
214-
-> lib.elem config.environment.memoryAllocator.provider [ "libc" "scudo" ];
215-
message = ''
216-
dhcpcd with privilege separation is incompatible with chosen system malloc.
217-
Currently only the `libc` and `scudo` allocators are known to work.
218-
To disable dhcpcd's privilege separation, overlay Nixpkgs and override dhcpcd
219-
to set `enablePrivSep = false`.
220-
'';
221-
} ];
222-
223-
environment.etc."dhcpcd.conf".source = dhcpcdConf;
224-
225209
systemd.services.dhcpcd = let
226210
cfgN = config.networking;
227211
hasDefaultGatewaySet = (cfgN.defaultGateway != null && cfgN.defaultGateway.address != "")

nixos/tests/chrony.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import ./make-test-python.nix ({ lib, ... }:
1313
specialisation.hardened.configuration = {
1414
services.chrony.enableMemoryLocking = true;
1515
environment.memoryAllocator.provider = "graphene-hardened";
16-
# dhcpcd privsep is incompatible with graphene-hardened
17-
networking.useNetworkd = true;
1816
};
1917
};
2018
};

nixos/tests/hardened.nix

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ import ./make-test-python.nix ({ pkgs, ... } : {
1111
imports = [ ../modules/profiles/hardened.nix ];
1212
environment.memoryAllocator.provider = "graphene-hardened";
1313
nix.settings.sandbox = false;
14-
nixpkgs.overlays = [
15-
(final: super: {
16-
dhcpcd = super.dhcpcd.override { enablePrivSep = false; };
17-
})
18-
];
1914
virtualisation.emptyDiskImages = [ 4096 ];
2015
boot.initrd.postDeviceCommands = ''
2116
${pkgs.dosfstools}/bin/mkfs.vfat -n EFISYS /dev/vdb

pkgs/tools/networking/dhcpcd/default.nix

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
, runtimeShellPackage
88
, runtimeShell
99
, nixosTests
10-
, enablePrivSep ? true
1110
}:
1211

1312
stdenv.mkDerivation rec {
@@ -38,17 +37,8 @@ stdenv.mkDerivation rec {
3837
configureFlags = [
3938
"--sysconfdir=/etc"
4039
"--localstatedir=/var"
41-
]
42-
++ (
43-
if ! enablePrivSep
44-
then [ "--disable-privsep" ]
45-
else [
46-
"--enable-privsep"
47-
# dhcpcd disables privsep if it can't find the default user,
48-
# so we explicitly specify a user.
49-
"--privsepuser=dhcpcd"
50-
]
51-
);
40+
"--disable-privsep"
41+
];
5242

5343
makeFlags = [ "PREFIX=${placeholder "out"}" ];
5444

@@ -59,9 +49,8 @@ stdenv.mkDerivation rec {
5949
# Check that the udev plugin got built.
6050
postInstall = lib.optionalString (udev != null && stdenv.isLinux) "[ -e ${placeholder "out"}/lib/dhcpcd/dev/udev.so ]";
6151

62-
passthru = {
63-
inherit enablePrivSep;
64-
tests = { inherit (nixosTests.networking.scripted) macvlan dhcpSimple dhcpOneIf; };
52+
passthru.tests = {
53+
inherit (nixosTests.networking.scripted) macvlan dhcpSimple dhcpOneIf;
6554
};
6655

6756
meta = with lib; {

0 commit comments

Comments
 (0)