···1-{ config, lib, pkgs, ... }:
23with lib;
45let
6 cfg = config.security.grsecurity;
078- customGrsecPkg =
9- (import ../../../pkgs/build-support/grsecurity {
10- grsecOptions = cfg;
11- inherit pkgs lib;
12- }).grsecPackage;
0013in
014{
15- options = {
16- security.grsecurity = {
17- enable = mkOption {
18- type = types.bool;
19- default = false;
20- description = ''
21- Enable grsecurity support. This enables advanced exploit
22- hardening for the Linux kernel, and adds support for
23- administrative Role-Based Acess Control (RBAC) via
24- <literal>gradm</literal>. It also includes traditional
25- utilities for PaX.
26- '';
27- };
2829- kernelPatch = mkOption {
30- type = types.attrs;
31- example = lib.literalExample "pkgs.kernelPatches.grsecurity_4_1";
32- description = ''
33- Grsecurity patch to use.
34- '';
35- };
3637- config = {
38- mode = mkOption {
39- type = types.enum [ "auto" "custom" ];
40- default = "auto";
41- description = ''
42- grsecurity configuration mode. This specifies whether
43- grsecurity is auto-configured or otherwise completely
44- manually configured.
45- '';
46- };
004748- priority = mkOption {
49- type = types.enum [ "security" "performance" ];
50- default = "security";
51- description = ''
52- grsecurity configuration priority. This specifies whether
53- the kernel configuration should emphasize speed or
54- security.
55- '';
56- };
5758- system = mkOption {
59- type = types.enum [ "desktop" "server" ];
60- default = "desktop";
61- description = ''
62- grsecurity system configuration.
63- '';
64- };
6566- virtualisationConfig = mkOption {
67- type = types.nullOr (types.enum [ "host" "guest" ]);
68- default = null;
69- description = ''
70- grsecurity virtualisation configuration. This specifies
71- the virtualisation role of the machine - that is, whether
72- it will be a virtual machine guest, a virtual machine
73- host, or neither.
74- '';
75- };
7677- hardwareVirtualisation = mkOption {
78- type = types.nullOr types.bool;
79- default = null;
80- example = true;
81- description = ''
82- grsecurity hardware virtualisation configuration. Set to
83- <literal>true</literal> if your machine supports hardware
84- accelerated virtualisation.
85- '';
86- };
87-88- virtualisationSoftware = mkOption {
89- type = types.nullOr (types.enum [ "kvm" "xen" "vmware" "virtualbox" ]);
90- default = null;
91- description = ''
92- Configure grsecurity for use with this virtualisation software.
93- '';
94- };
95-96- sysctl = mkOption {
97- type = types.bool;
98- default = false;
99- description = ''
100- If true, then set <literal>GRKERN_SYSCTL y</literal>. If
101- enabled then grsecurity can be controlled using sysctl
102- (and turned off). You are advised to *never* enable this,
103- but if you do, make sure to always set the sysctl
104- <literal>kernel.grsecurity.grsec_lock</literal> to
105- non-zero as soon as all sysctl options are set. *THIS IS
106- EXTREMELY IMPORTANT*!
107- '';
108- };
109-110- denyChrootChmod = mkOption {
111- type = types.bool;
112- default = false;
113- description = ''
114- If true, then set <literal>GRKERN_CHROOT_CHMOD
115- y</literal>. If enabled, this denies processes inside a
116- chroot from setting the suid or sgid bits using
117- <literal>chmod</literal> or <literal>fchmod</literal>.
118-119- By default this protection is disabled - it makes it
120- impossible to use Nix to build software on your system,
121- which is what most users want.
122-123- If you are using NixOps to deploy your software to a
124- remote machine, you're encouraged to enable this as you
125- won't need to compile code.
126- '';
127- };
128-129- denyChrootCaps = mkOption {
130- type = types.bool;
131- default = false;
132- description = ''
133- Whether to lower capabilities of all processes within a chroot,
134- preventing commands that require <literal>CAP_SYS_ADMIN</literal>.
135-136- This protection is disabled by default because it breaks
137- <literal>nixos-rebuild</literal>. Whenever possible, it is
138- highly recommended to enable this protection.
139- '';
140- };
141-142- denyUSB = mkOption {
143- type = types.bool;
144- default = false;
145- description = ''
146- If true, then set <literal>GRKERNSEC_DENYUSB y</literal>.
147148- This enables a sysctl with name
149- <literal>kernel.grsecurity.deny_new_usb</literal>. Setting
150- its value to <literal>1</literal> will prevent any new USB
151- devices from being recognized by the OS. Any attempted
152- USB device insertion will be logged.
153154- This option is intended to be used against custom USB
155- devices designed to exploit vulnerabilities in various USB
156- device drivers.
157- '';
158- };
159160- restrictProc = mkOption {
161- type = types.bool;
162- default = false;
163- description = ''
164- If true, then set <literal>GRKERN_PROC_USER
165- y</literal>. This restricts non-root users to only viewing
166- their own processes and restricts network-related
167- information, kernel symbols, and module information.
168- '';
169- };
170171- restrictProcWithGroup = mkOption {
172- type = types.bool;
173- default = true;
174- description = ''
175- If true, then set <literal>GRKERN_PROC_USERGROUP
176- y</literal>. This is similar to
177- <literal>restrictProc</literal> except it allows a special
178- group (specified by <literal>unrestrictProcGid</literal>)
179- to still access otherwise classified information in
180- <literal>/proc</literal>.
181- '';
182- };
183184- unrestrictProcGid = mkOption {
185- type = types.int;
186- default = config.ids.gids.grsecurity;
187- description = ''
188- If set, specifies a GID which is exempt from
189- <literal>/proc</literal> restrictions (set by
190- <literal>GRKERN_PROC_USERGROUP</literal>). By default,
191- this is set to the GID for <literal>grsecurity</literal>,
192- a predefined NixOS group, which the
193- <literal>root</literal> account is a member of. You may
194- conveniently add other users to this group if you need
195- access to <literal>/proc</literal>
196- '';
197- };
198199- disableRBAC = mkOption {
200- type = types.bool;
201- default = false;
202- description = ''
203- If true, then set <literal>GRKERN_NO_RBAC
204- y</literal>. This disables the
205- <literal>/dev/grsec</literal> device, which in turn
206- disables the RBAC system (and <literal>gradm</literal>).
207- '';
208- };
209210- disableSimultConnect = mkOption {
211- type = types.bool;
212- default = false;
213- description = ''
214- Disable TCP simultaneous connect. The TCP simultaneous connect
215- feature allows two clients to connect without either of them
216- entering the listening state. This feature of the TCP specification
217- is claimed to enable an attacker to deny the target access to a given
218- server by guessing the source port the target would use to make the
219- connection.
220221- This option is OFF by default because TCP simultaneous connect has
222- some legitimate uses. Enable this option if you know what this TCP
223- feature is for and know that you do not need it.
224- '';
225- };
226227- verboseVersion = mkOption {
228- type = types.bool;
229- default = false;
230- description = "Use verbose version in kernel localversion.";
231- };
0232233- kernelExtraConfig = mkOption {
234- type = types.str;
235- default = "";
236- description = "Extra kernel configuration parameters.";
237- };
238 };
239 };
240- };
241242- config = mkIf cfg.enable {
243- assertions =
244- [
245- { assertion = (cfg.config.restrictProc -> !cfg.config.restrictProcWithGroup) ||
246- (cfg.config.restrictProcWithGroup -> !cfg.config.restrictProc);
247- message = "You cannot enable both restrictProc and restrictProcWithGroup";
248- }
249- { assertion = config.boot.kernelPackages.kernel.features ? grsecurity
250- && config.boot.kernelPackages.kernel.features.grsecurity;
251- message = "grsecurity enabled, but kernel doesn't have grsec support";
252- }
253- { assertion = (cfg.config.mode == "auto" && (cfg.config.virtualisationConfig != null)) ->
254- cfg.config.hardwareVirtualisation != null;
255- message = "when using auto grsec mode with virtualisation, you must specify if your hardware has virtualisation extensions";
256- }
257- { assertion = (cfg.config.mode == "auto" && (cfg.config.virtualisationConfig != null)) ->
258- cfg.config.virtualisationSoftware != null;
259- message = "grsecurity configured for virtualisation but no virtualisation software specified";
260- }
261- ];
262-263- security.grsecurity.kernelPatch = lib.mkDefault pkgs.kernelPatches.grsecurity_latest;
264-265- systemd.services.grsec-lock = mkIf cfg.config.sysctl {
266- description = "grsecurity sysctl-lock Service";
267- wants = [ "systemd-sysctl.service" ];
268- after = [ "systemd-sysctl.service" ];
269- wantedBy = [ "multi-user.target" ];
270- serviceConfig.Type = "oneshot";
271- serviceConfig.RemainAfterExit = "yes";
272- unitConfig.ConditionPathIsReadWrite = "/proc/sys/kernel/grsecurity/grsec_lock";
273- script = ''
274- locked=`cat /proc/sys/kernel/grsecurity/grsec_lock`
275- if [ "$locked" == "0" ]; then
276- echo 1 > /proc/sys/kernel/grsecurity/grsec_lock
277- echo grsecurity sysctl lock - enabled
278- else
279- echo grsecurity sysctl lock already enabled - doing nothing
280- fi
281- '';
282 };
283284-# systemd.services.grsec-learn = {
285-# description = "grsecurity learning Service";
286-# wantedBy = [ "local-fs.target" ];
287-# serviceConfig = {
288-# Type = "oneshot";
289-# RemainAfterExit = "yes";
290-# ExecStart = "${pkgs.gradm}/sbin/gradm -VFL /etc/grsec/learning.logs";
291-# ExecStop = "${pkgs.gradm}/sbin/gradm -D";
292-# };
293-# };
294295- system.activationScripts = lib.optionalAttrs (!cfg.config.disableRBAC) { grsec = ''
296- mkdir -p /etc/grsec
297- if [ ! -f /etc/grsec/learn_config ]; then
298- cp ${pkgs.gradm}/etc/grsec/learn_config /etc/grsec
299- fi
300- if [ ! -f /etc/grsec/policy ]; then
301- cp ${pkgs.gradm}/etc/grsec/policy /etc/grsec
302- fi
303- chmod -R 0600 /etc/grsec
304- ''; };
305-306- # Enable AppArmor, gradm udev rules, and utilities
307- security.apparmor.enable = true;
308- boot.kernelPackages = customGrsecPkg;
309- services.udev.packages = lib.optional (!cfg.config.disableRBAC) pkgs.gradm;
310- environment.systemPackages = [ pkgs.paxctl pkgs.pax-utils ] ++ lib.optional (!cfg.config.disableRBAC) pkgs.gradm;
311 };
312}
···1+{ config, pkgs, lib, ... }:
23with lib;
45let
6 cfg = config.security.grsecurity;
7+ grsecLockPath = "/proc/sys/kernel/grsecurity/grsec_lock";
89+ # Ascertain whether ZFS is required for booting the system; grsecurity is
10+ # currently incompatible with ZFS, rendering the system unbootable.
11+ zfsNeededForBoot = filter
12+ (fs: (fs.neededForBoot
13+ || elem fs.mountPoint [ "/" "/nix" "/nix/store" "/var" "/var/log" "/var/lib" "/etc" ])
14+ && fs.fsType == "zfs")
15+ (attrValues config.fileSystems) != [];
16in
17+18{
19+ options.security.grsecurity = {
0000000000002021+ enable = mkEnableOption "Grsecurity/PaX";
0000002223+ lockTunables = mkOption {
24+ type = types.bool;
25+ example = false;
26+ default = true;
27+ description = ''
28+ Whether to automatically lock grsecurity tunables
29+ (<option>boot.kernel.sysctl."kernel.grsecurity.*"</option>). Disable
30+ this to allow configuration of grsecurity features while the system is
31+ running. The lock can be manually engaged by activating the
32+ <literal>grsec-lock</literal> service unit.
33+ '';
34+ };
3536+ };
000000003738+ config = mkIf cfg.enable {
0000003940+ # Allow the user to select a different package set, subject to the stated
41+ # required kernel config
42+ boot.kernelPackages = mkDefault pkgs.linuxPackages_grsec_nixos;
00000004344+ system.requiredKernelConfig = with config.lib.kernelConfig;
45+ [ (isEnabled "GRKERNSEC")
46+ (isEnabled "PAX")
47+ (isYES "GRKERNSEC_SYSCTL")
48+ (isYES "GRKERNSEC_SYSCTL_DISTRO")
49+ ];
00000000000000000000000000000000000000000000000000000000000000005051+ # Crashing on an overflow in kernel land is user unfriendly and may prevent
52+ # the system from booting, which is too severe for our use case.
53+ boot.kernelParams = [ "pax_size_overflow_report_only" ];
005455+ # Install PaX related utillities into the system profile. Eventually, we
56+ # also want to include gradm here.
57+ environment.systemPackages = with pkgs; [ paxctl pax-utils ];
005859+ # Install rules for the grsec device node
60+ services.udev.packages = [ pkgs.gradm ];
000000006162+ # This service unit is responsible for locking the Grsecurity tunables. The
63+ # unit is always defined, but only activated on bootup if lockTunables is
64+ # toggled. When lockTunables is toggled, failure to activate the unit will
65+ # enter emergency mode. The intent is to make it difficult to silently
66+ # enter multi-user mode without having locked the tunables. Some effort is
67+ # made to ensure that starting the unit is an idempotent operation.
68+ systemd.services.grsec-lock = {
69+ description = "Lock grsecurity tunables";
00007071+ wantedBy = optional cfg.lockTunables "multi-user.target";
00000000000007273+ wants = [ "local-fs.target" "systemd-sysctl.service" ];
74+ after = [ "local-fs.target" "systemd-sysctl.service" ];
75+ conflicts = [ "shutdown.target" ];
00000007677+ restartIfChanged = false;
0000000007879+ script = ''
80+ if ${pkgs.gnugrep}/bin/grep -Fq 0 ${grsecLockPath} ; then
81+ echo -n 1 > ${grsecLockPath}
82+ fi
83+ '';
8485+ unitConfig = {
86+ ConditionPathIsReadWrite = grsecLockPath;
87+ DefaultDependencies = false;
88+ } // optionalAttrs cfg.lockTunables {
89+ OnFailure = "emergency.target";
90+ };
9192+ serviceConfig = {
93+ Type = "oneshot";
94+ RemainAfterExit = true;
0095 };
96 };
09798+ # Configure system tunables
99+ boot.kernel.sysctl = {
100+ # Removed under grsecurity
101+ "kernel.kptr_restrict" = mkForce null;
102+ } // optionalAttrs config.nix.useSandbox {
103+ # chroot(2) restrictions that conflict with sandboxed Nix builds
104+ "kernel.grsecurity.chroot_caps" = mkForce 0;
105+ "kernel.grsecurity.chroot_deny_chroot" = mkForce 0;
106+ "kernel.grsecurity.chroot_deny_mount" = mkForce 0;
107+ "kernel.grsecurity.chroot_deny_pivot" = mkForce 0;
108+ } // optionalAttrs config.boot.enableContainers {
109+ # chroot(2) restrictions that conflict with NixOS lightweight containers
110+ "kernel.grsecurity.chroot_deny_chmod" = mkForce 0;
111+ "kernel.grsecurity.chroot_deny_mount" = mkForce 0;
112+ "kernel.grsecurity.chroot_restrict_nice" = mkForce 0;
0000000000000000000000000113 };
114115+ assertions = [
116+ { assertion = !zfsNeededForBoot;
117+ message = "grsecurity is currently incompatible with ZFS";
118+ }
119+ ];
000001200000000000000000121 };
122}
+31-9
nixos/tests/grsecurity.nix
···3import ./make-test.nix ({ pkgs, ...} : {
4 name = "grsecurity";
5 meta = with pkgs.stdenv.lib.maintainers; {
6- maintainers = [ copumpkin ];
7 };
89 machine = { config, pkgs, ... }:
10- { boot.kernelPackages = pkgs.linuxPackages_grsec_testing_server; };
0001112- testScript =
13- ''
14- $machine->succeed("uname -a") =~ /grsec/;
15- # FIXME: this seems to hang the whole test. Unclear why, but let's fix it
16- # $machine->succeed("${pkgs.paxtest}/bin/paxtest blackhat");
17- '';
18-})
1900000000000000000000
···3import ./make-test.nix ({ pkgs, ...} : {
4 name = "grsecurity";
5 meta = with pkgs.stdenv.lib.maintainers; {
6+ maintainers = [ copumpkin joachifm ];
7 };
89 machine = { config, pkgs, ... }:
10+ { security.grsecurity.enable = true;
11+ boot.kernel.sysctl."kernel.grsecurity.deter_bruteforce" = 0;
12+ security.apparmor.enable = true;
13+ };
1415+ testScript = ''
16+ subtest "grsec-lock", sub {
17+ $machine->succeed("systemctl is-active grsec-lock");
18+ $machine->succeed("grep -Fq 1 /proc/sys/kernel/grsecurity/grsec_lock");
19+ $machine->fail("echo -n 0 >/proc/sys/kernel/grsecurity/grsec_lock");
20+ };
02122+ subtest "paxtest", sub {
23+ # TODO: running paxtest blackhat hangs the vm
24+ $machine->succeed("${pkgs.paxtest}/lib/paxtest/anonmap") =~ /Killed/ or die;
25+ $machine->succeed("${pkgs.paxtest}/lib/paxtest/execbss") =~ /Killed/ or die;
26+ $machine->succeed("${pkgs.paxtest}/lib/paxtest/execdata") =~ /Killed/ or die;
27+ $machine->succeed("${pkgs.paxtest}/lib/paxtest/execheap") =~ /Killed/ or die;
28+ $machine->succeed("${pkgs.paxtest}/lib/paxtest/execstack") =~ /Killed/ or die;
29+ $machine->succeed("${pkgs.paxtest}/lib/paxtest/mprotanon") =~ /Killed/ or die;
30+ $machine->succeed("${pkgs.paxtest}/lib/paxtest/mprotbss") =~ /Killed/ or die;
31+ $machine->succeed("${pkgs.paxtest}/lib/paxtest/mprotdata") =~ /Killed/ or die;
32+ $machine->succeed("${pkgs.paxtest}/lib/paxtest/mprotheap") =~ /Killed/ or die;
33+ $machine->succeed("${pkgs.paxtest}/lib/paxtest/mprotstack") =~ /Killed/ or die;
34+ };
35+36+ subtest "tcc", sub {
37+ $machine->execute("echo -e '#include <stdio.h>\nint main(void) { puts(\"hello\"); return 0; }' >main.c");
38+ $machine->succeed("${pkgs.tinycc.bin}/bin/tcc -run main.c");
39+ };
40+ '';
41+})
···261 # Security related features.
262 STRICT_DEVMEM y # Filter access to /dev/mem
263 SECURITY_SELINUX_BOOTPARAM_VALUE 0 # Disable SELinux by default
264- ${optionalString (!(features.grsecurity or false)) ''
265- DEVKMEM n # Disable /dev/kmem
266- ''}
267 ${if versionOlder version "3.14" then ''
268 CC_STACKPROTECTOR? y # Detect buffer overflows on the stack
269 '' else ''
···422423 # Virtualisation.
424 PARAVIRT? y
425- ${optionalString (!(features.grsecurity or false))
426- (if versionAtLeast version "3.10" then ''
427- HYPERVISOR_GUEST y
428- '' else ''
429- PARAVIRT_GUEST? y
430- '')
431- }
432 KVM_APIC_ARCHITECTURE y
433 KVM_ASYNC_PF y
434 ${optionalString (versionOlder version "3.7") ''
···443 ${optionalString (versionAtLeast version "4.0") ''
444 KVM_GENERIC_DIRTYLOG_READ_PROTECT y
445 ''}
446- ${optionalString (!features.grsecurity or true) ''
447- KVM_GUEST y
448- ''}
449 KVM_MMIO y
450 ${optionalString (versionAtLeast version "3.13") ''
451 KVM_VFIO y
···261 # Security related features.
262 STRICT_DEVMEM y # Filter access to /dev/mem
263 SECURITY_SELINUX_BOOTPARAM_VALUE 0 # Disable SELinux by default
264+ DEVKMEM n # Disable /dev/kmem
00265 ${if versionOlder version "3.14" then ''
266 CC_STACKPROTECTOR? y # Detect buffer overflows on the stack
267 '' else ''
···420421 # Virtualisation.
422 PARAVIRT? y
423+ ${if versionAtLeast version "3.10" then ''
424+ HYPERVISOR_GUEST y
425+ '' else ''
426+ PARAVIRT_GUEST? y
427+ ''}
00428 KVM_APIC_ARCHITECTURE y
429 KVM_ASYNC_PF y
430 ${optionalString (versionOlder version "3.7") ''
···439 ${optionalString (versionAtLeast version "4.0") ''
440 KVM_GENERIC_DIRTYLOG_READ_PROTECT y
441 ''}
442+ KVM_GUEST y
00443 KVM_MMIO y
444 ${optionalString (versionAtLeast version "3.13") ''
445 KVM_VFIO y
···1+{ stdenv }:
2+3+with stdenv.lib;
4+5+''
6+GRKERNSEC y
7+PAX y
8+9+GRKERNSEC_CONFIG_AUTO y
10+GRKERNSEC_CONFIG_DESKTOP y
11+GRKERNSEC_CONFIG_VIRT_HOST y
12+GRKERNSEC_CONFIG_VIRT_EPT y
13+GRKERNSEC_CONFIG_VIRT_KVM y
14+GRKERNSEC_CONFIG_PRIORITY_SECURITY y
15+16+PAX_PT_PAX_FLAGS y
17+PAX_XATTR_PAX_FLAGS n
18+PAX_EI_PAX n
19+20+GRKERNSEC_PROC_GID 0
21+22+PAX_LATENT_ENTROPY n
23+PAX_SIZE_OVERFLOW n
24+GRKERNSEC_HIDESYM n
25+GRKERNSEC_RANDSTRUCT n
26+GRKERNSEC_PROC n
27+GRKERNSEC_SYSFS_RESTRICT n
28+GRKERNSEC_KMEM n
29+GRKERNSEC_MODHARDEN n
30+GRKERNSEC_NO_SIMULT_CONNECT n
31+32+PAX_KERNEXEC_PLUGIN_METHOD_BTS y
33+34+GRKERNSEC_ACL_HIDEKERN y
35+GRKERNSEC_IO y
36+37+GRKERNSEC_AUDIT_PTRACE y
38+GRKERNSEC_FORKFAIL y
39+40+GRKERNSEC_SYSCTL y
41+GRKERNSEC_SYSCTL_DISTRO y
42+GRKERNSEC_SYSCTL_ON y
43+''
···18 };
19 };
2021- grsecPatch = { grversion ? "3.1", kernel, patches, kversion, revision, branch ? "test", sha256 }:
22- assert kversion == kernel.version;
23- { name = "grsecurity-${grversion}-${kversion}";
24- inherit grversion kernel patches kversion revision;
00025 # When updating versions/hashes, ALWAYS use the official version; we use
26 # this mirror only because upstream removes sources files immediately upon
27 # releasing a new version ...
28- patch = fetchurl {
29- url = "https://raw.githubusercontent.com/slashbeast/grsecurity-scrape/master/test/grsecurity-${grversion}-${kversion}-${revision}.patch";
30- inherit sha256;
31- };
32- features.grsecurity = true;
33 };
34-35in
3637rec {
···9293 grsecurity_4_4 = throw "grsecurity stable is no longer supported";
9495- grsecurity_4_5 = grsecPatch
96- { kernel = pkgs.grsecurity_base_linux_4_5;
97- patches = [ grsecurity_fix_path_4_5 ];
98- kversion = "4.5.7";
99- revision = "201606080852";
100- sha256 = "1vgc314nh6bd7zw9r927lnbjq29z32g0s02jgvf635y9zz550nsh";
101 };
102103- grsecurity_latest = grsecurity_4_5;
104-105- grsecurity_fix_path_4_5 =
106- { name = "grsecurity-fix-path-4.5";
107- patch = ./grsecurity-path-4.5.patch;
0108 };
109110 crc_regression =
···18 };
19 };
2021+ grsecPatch = { grbranch ? "test", grver ? "3.1", kver, grrev, sha256 }: rec {
22+ name = "grsecurity-${grver}-${kver}-${grrev}";
23+24+ # Pass these along to allow the caller to determine compatibility
25+ inherit grver kver grrev;
26+27+ patch = fetchurl {
28 # When updating versions/hashes, ALWAYS use the official version; we use
29 # this mirror only because upstream removes sources files immediately upon
30 # releasing a new version ...
31+ url = "https://raw.githubusercontent.com/slashbeast/grsecurity-scrape/master/${grbranch}/${name}.patch";
32+ inherit sha256;
00033 };
34+ };
35in
3637rec {
···9293 grsecurity_4_4 = throw "grsecurity stable is no longer supported";
9495+ grsecurity_testing = grsecPatch
96+ { kver = "4.5.7";
97+ grrev = "201606080852";
98+ sha256 = "1vgc314nh6bd7zw9r927lnbjq29z32g0s02jgvf635y9zz550nsh";
0099 };
100101+ # This patch relaxes grsec constraints on the location of usermode helpers,
102+ # e.g., modprobe, to allow calling into the Nix store.
103+ grsecurity_nixos_kmod =
104+ {
105+ name = "grsecurity-nixos-kmod";
106+ patch = ./grsecurity-nixos-kmod.patch;
107 };
108109 crc_regression =
+54-54
pkgs/top-level/all-packages.nix
···1082210823 linux_chromiumos_latest = self.linux_chromiumos_3_18;
1082410825- # grsecurity configuration
10826-10827- grsecurity_base_linux_4_5 = callPackage ../os-specific/linux/kernel/linux-grsecurity-4.5.nix {
10828- inherit (linux_4_5) kernelPatches;
10829- };
10830-10831- grFlavors = import ../build-support/grsecurity/flavors.nix;
10832-10833- mkGrsecurity = patch: opts:
10834- (callPackage ../build-support/grsecurity {
10835- grsecOptions = { kernelPatch = patch; } // opts;
10836- });
10837-10838- grKernel = patch: opts: (self.mkGrsecurity patch opts).grsecKernel;
10839- grPackage = patch: opts: recurseIntoAttrs (self.mkGrsecurity patch opts).grsecPackage;
10840-10841- # grsecurity kernels (see also linuxPackages_grsec_*)
10842-10843- linux_grsec_desktop_4_5 = self.grKernel kernelPatches.grsecurity_4_5 self.grFlavors.desktop;
10844- linux_grsec_server_4_5 = self.grKernel kernelPatches.grsecurity_4_5 self.grFlavors.server;
10845- linux_grsec_server_xen_4_5 = self.grKernel kernelPatches.grsecurity_4_5 self.grFlavors.server_xen;
10846-10847- linux_grsec_desktop_latest = self.grKernel kernelPatches.grsecurity_latest self.grFlavors.desktop;
10848- linux_grsec_server_latest = self.grKernel kernelPatches.grsecurity_latest self.grFlavors.server;
10849- linux_grsec_server_xen_latest = self.grKernel kernelPatches.grsecurity_latest self.grFlavors.server_xen;
10850-10851 /* Linux kernel modules are inherently tied to a specific kernel. So
10852 rather than provide specific instances of those packages for a
10853 specific kernel, we have a function that builds those packages
···10997 # Build a kernel for Xen dom0
10998 linuxPackages_latest_xen_dom0 = recurseIntoAttrs (self.linuxPackagesFor (self.linux_latest.override { features.xen_dom0=true; }) linuxPackages_latest);
1099911000- # grsecurity packages
00000000001100111002- linuxPackages_grsec_desktop_4_5 = self.grPackage kernelPatches.grsecurity_4_5 self.grFlavors.desktop;
11003- linuxPackages_grsec_server_4_5 = self.grPackage kernelPatches.grsecurity_4_5 self.grFlavors.server;
11004- linuxPackages_grsec_server_xen_4_5 = self.grPackage kernelPatches.grsecurity_4_5 self.grFlavors.server_xen;
1100511006- linuxPackages_grsec_desktop_latest = self.grPackage kernelPatches.grsecurity_latest self.grFlavors.desktop;
11007- linuxPackages_grsec_server_latest = self.grPackage kernelPatches.grsecurity_latest self.grFlavors.server;
11008- linuxPackages_grsec_server_xen_latest = self.grPackage kernelPatches.grsecurity_latest self.grFlavors.server_xen;
0000000001100911010 # grsecurity: legacy
1101111012 grsecurity_base_linux_3_14 = throw "grsecurity stable is no longer supported";
11013 grsecurity_base_linux_4_4 = throw "grsecurity stable is no longer supported";
1101411015- linux_grsec_desktop_3_14 = throw "grsecurity stable is no longer supported";
11016- linux_grsec_server_3_14 = throw "grsecurity stable is no longer supported";
11017- linux_grsec_server_xen_3_14 = throw "grsecurity stable is no longer supported";
0110180000000000011019 linux_grsec_desktop_4_4 = throw "grsecurity stable is no longer supported";
000011020 linux_grsec_server_4_4 = throw "grsecurity stable is no longer supported";
000011021 linux_grsec_server_xen_4_4 = throw "grsecurity stable is no longer supported";
11022-11023- linux_grsec_testing_desktop = self.linux_grsec_desktop_latest;
11024- linux_grsec_testing_server = self.linux_grsec_server_latest;
11025- linux_grsec_testing_server_xen = self.linux_grsec_server_xen_latest;
1102611027 linux_grsec_stable_desktop = self.linux_grsec_desktop_3_14;
11028 linux_grsec_stable_server = self.linux_grsec_server_3_14;
11029 linux_grsec_stable_server_xen = self.linux_grsec_server_xen_3_14;
1103011031- linuxPackages_grsec_desktop_3_14 = self.grPackage kernelPatches.grsecurity_3_14 self.grFlavors.desktop;
11032- linuxPackages_grsec_server_3_14 = self.grPackage kernelPatches.grsecurity_3_14 self.grFlavors.server;
11033- linuxPackages_grsec_server_xen_3_14 = self.grPackage kernelPatches.grsecurity_3_14 self.grFlavors.server_xen;
11034-11035- linuxPackages_grsec_desktop_4_4 = self.grPackage kernelPatches.grsecurity_4_4 self.grFlavors.desktop;
11036- linuxPackages_grsec_server_4_4 = self.grPackage kernelPatches.grsecurity_4_4 self.grFlavors.server;
11037- linuxPackages_grsec_server_xen_4_4 = self.grPackage kernelPatches.grsecurity_4_4 self.grFlavors.server_xen;
11038-11039- linuxPackages_grsec_testing_desktop = self.linuxPackages_grsec_desktop_latest;
11040- linuxPackages_grsec_testing_server = self.linuxPackages_grsec_server_latest;
11041- linuxPackages_grsec_testing_server_xen = self.linuxPackages_grsec_server_xen_latest;
1104211043- linuxPackages_grsec_stable_desktop = self.linuxPackages_grsec_desktop_3_14;
11044- linuxPackages_grsec_stable_server = self.linuxPackages_grsec_server_3_14;
11045- linuxPackages_grsec_stable_server_xen = self.linuxPackages_grsec_server_xen_3_14;
1104611047 # ChromiumOS kernels
11048 linuxPackages_chromiumos_3_14 = recurseIntoAttrs (self.linuxPackagesFor self.linux_chromiumos_3_14 linuxPackages_chromiumos_3_14);
···1082210823 linux_chromiumos_latest = self.linux_chromiumos_3_18;
108240000000000000000000000000010825 /* Linux kernel modules are inherently tied to a specific kernel. So
10826 rather than provide specific instances of those packages for a
10827 specific kernel, we have a function that builds those packages
···10971 # Build a kernel for Xen dom0
10972 linuxPackages_latest_xen_dom0 = recurseIntoAttrs (self.linuxPackagesFor (self.linux_latest.override { features.xen_dom0=true; }) linuxPackages_latest);
1097310974+ # Grsecurity packages
10975+10976+ linux_grsec_nixos = callPackage ../build-support/grsecurity {
10977+ inherit (lib) overrideDerivation;
10978+ kernel = callPackage ../os-specific/linux/kernel/linux-grsecurity.nix {
10979+ inherit (self.linux_4_5) kernelPatches;
10980+ };
10981+ grsecPatch = self.kernelPatches.grsecurity_testing;
10982+ kernelPatches = [ self.kernelPatches.grsecurity_nixos_kmod ];
10983+ extraConfig = callPackage ../os-specific/linux/kernel/grsecurity-nixos-config.nix { };
10984+ };
1098510986+ linuxPackages_grsec_nixos =
10987+ let self = linuxPackagesFor linux_grsec_nixos self;
10988+ in recurseIntoAttrs self;
1098910990+ # An unsupported grsec xen guest kernel
10991+ linux_grsec_server_xen = linux_grsec_nixos.override {
10992+ extraConfig = ''
10993+ GRKERNSEC y
10994+ PAX y
10995+ GRKERNSEC_CONFIG_AUTO y
10996+ GRKERNSEC_CONFIG_PRIORITY_SECURITY y
10997+ GRKERNSEC_CONFIG_SERVER y
10998+ GRKERNSEC_CONFIG_VIRT_GUEST y
10999+ GRKERNSEC_CONFIG_VIRT_XEN y
11000+ '';
11001+ };
1100211003 # grsecurity: legacy
1100411005 grsecurity_base_linux_3_14 = throw "grsecurity stable is no longer supported";
11006 grsecurity_base_linux_4_4 = throw "grsecurity stable is no longer supported";
1100711008+ linuxPackages_grsec_desktop_3_14 = throw "linuxPackages_grsec_desktop has been removed";
11009+ linuxPackages_grsec_desktop_4_4 = throw "linuxPackages_grsec_desktop has been removed";
11010+ linuxPackages_grsec_desktop_4_5 = throw "linuxPackages_grsec_desktop has been removed";
11011+ linuxPackages_grsec_desktop_latest = throw "linuxPackages_grsec_desktop has been removed";
1101211013+ linuxPackages_grsec_server_3_14 = throw "linuxPackages_grsec_server has been removed";
11014+ linuxPackages_grsec_server_4_4 = throw "linuxPackages_grsec_server has been removed";
11015+ linuxPackages_grsec_server_4_5 = throw "linuxPackages_grsec_server has been removed";
11016+ linuxPackages_grsec_server_latest = throw "linuxPackages_grsec_server has been removed";
11017+11018+ linuxPackages_grsec_server_xen_3_14 = throw "linuxPackages_grsec_server_xen has been removed";
11019+ linuxPackages_grsec_server_xen_4_4 = throw "linuxPackages_grsec_server_xen has been removed";
11020+ linuxPackages_grsec_server_xen_4_5 = throw "linuxPackages_grsec_server_xen has been removed";
11021+ linuxPackages_grsec_server_xen_latest = throw "linuxPackages_grsec_server_xen has been removed";
11022+11023+ linux_grsec_desktop_3_14 = throw "grsecurity stable is no longer supported";
11024 linux_grsec_desktop_4_4 = throw "grsecurity stable is no longer supported";
11025+ linux_grsec_desktop_4_5 = throw "linux_grsec_desktop has been removed";
11026+ linux_grsec_desktop_latest = throw "linux_grsec_desktop has been removed";
11027+11028+ linux_grsec_server_3_14 = throw "grsecurity stable is no longer supported";
11029 linux_grsec_server_4_4 = throw "grsecurity stable is no longer supported";
11030+ linux_grsec_server_4_5 = throw "linux_grsec_server has been removed";
11031+ linux_grsec_server_latest = throw "linux_grsec_server_latest has been removed";
11032+11033+ linux_grsec_server_xen_3_14 = throw "grsecurity stable is no longer supported";
11034 linux_grsec_server_xen_4_4 = throw "grsecurity stable is no longer supported";
11035+ linux_grsec_server_xen_4_5 = throw "linux_grsec_server_xen has been removed";
11036+ linux_grsec_server_xen_latest = throw "linux_grsec_server_xen has been removed";
001103711038 linux_grsec_stable_desktop = self.linux_grsec_desktop_3_14;
11039 linux_grsec_stable_server = self.linux_grsec_server_3_14;
11040 linux_grsec_stable_server_xen = self.linux_grsec_server_xen_3_14;
1104111042+ linux_grsec_testing_desktop = self.linux_grsec_desktop_latest;
11043+ linux_grsec_testing_server = self.linux_grsec_server_latest;
11044+ linux_grsec_testing_server_xen = self.linux_grsec_server_xen_latest;
00000000110450001104611047 # ChromiumOS kernels
11048 linuxPackages_chromiumos_3_14 = recurseIntoAttrs (self.linuxPackagesFor self.linux_chromiumos_3_14 linuxPackages_chromiumos_3_14);