git.iko.soy/typeable/nixpkgs
on master help sign in
tree-wide: prune some dead grsec leaves

The beginning of pruning grsecurity/PaX from the tree.

commitab4fa1cce4c3c536811d8d7ddfcad1a8310cfb90 authorJoachim Fasting <joachifm@fastmail.fm> dateSun 30 Apr 2017, 07:16 (10 years ago) parent8c98e8c
7 files changed+1−216
nixos/tests/grsecurity.nix−46 pkgs/build-support/grsecurity/default.nix−37 pkgs/os-specific/linux/kernel/grsecurity-nixos-config.nix−63 pkgs/os-specific/linux/kernel/grsecurity-nixos-kmod.patch−14 pkgs/os-specific/linux/kernel/linux-grsecurity.nix−18 pkgs/os-specific/linux/kernel/patches.nix−28 pkgs/top-level/all-packages.nix+1−10
nixos/tests/grsecurity.nixdeleted−46
@@ -1,46 +0,0 @@
1−# Basic test to make sure grsecurity works
2−
3−import ./make-test.nix ({ pkgs, ...} : {
4− name = "grsecurity";
5− meta = with pkgs.stdenv.lib.maintainers; {
6− maintainers = [ copumpkin joachifm ];
7− };
8−
9− machine = { config, pkgs, ... }:
10− { security.grsecurity.enable = true;
11− boot.kernel.sysctl."kernel.grsecurity.audit_mount" = 0;
12− boot.kernel.sysctl."kernel.grsecurity.deter_bruteforce" = 0;
13− networking.useDHCP = false;
14− };
15−
16− testScript = ''
17− subtest "grsec-lock", sub {
18− $machine->succeed("systemctl is-active grsec-lock");
19− $machine->succeed("grep -Fq 1 /proc/sys/kernel/grsecurity/grsec_lock");
20− $machine->fail("echo -n 0 >/proc/sys/kernel/grsecurity/grsec_lock");
21− };
22−
23− subtest "paxtest", sub {
24− # TODO: running paxtest blackhat hangs the vm
25− my @pax_mustkill = (
26− "anonmap", "execbss", "execdata", "execheap", "execstack",
27− "mprotanon", "mprotbss", "mprotdata", "mprotheap", "mprotstack",
28− );
29− foreach my $name (@pax_mustkill) {
30− my $paxtest = "${pkgs.paxtest}/lib/paxtest/" . $name;
31− $machine->succeed($paxtest) =~ /Killed/ or die
32− }
33− };
34−
35− # tcc -run executes run-time generated code and so allows us to test whether
36− # paxmark actually works (otherwise, the process should be terminated)
37− subtest "tcc", sub {
38− $machine->execute("echo -e '#include <stdio.h>\nint main(void) { puts(\"hello\"); return 0; }' >main.c");
39− $machine->succeed("${pkgs.tinycc}/bin/tcc -run main.c");
40− };
41−
42− subtest "RBAC", sub {
43− $machine->succeed("[ -c /dev/grsec ]");
44− };
45− '';
46−})
pkgs/build-support/grsecurity/default.nixdeleted−37
@@ -1,37 +0,0 @@
1−{ stdenv
2−, lib
3−, overrideDerivation
4−
5−# required for gcc plugins
6−, gmp, libmpc, mpfr
7−
8−# the base kernel
9−, kernel
10−
11−, grsecPatch
12−, kernelPatches ? []
13−
14−, localver ? "-grsec"
15−, modDirVersion ? "${kernel.version}${localver}"
16−, extraConfig ? ""
17−, ...
18−} @ args:
19−
20−assert (kernel.version == grsecPatch.kver);
21−
22−overrideDerivation (kernel.override {
23− inherit modDirVersion;
24− kernelPatches = lib.unique ([ grsecPatch ] ++ kernelPatches ++ (kernel.kernelPatches or []));
25− extraConfig = ''
26− GRKERNSEC y
27− PAX y
28− ${extraConfig}
29− '';
30− ignoreConfigErrors = true;
31−}) (attrs: {
32− nativeBuildInputs = (lib.chooseDevOutputs [ gmp libmpc mpfr ]) ++ (attrs.nativeBuildInputs or []);
33− preConfigure = ''
34− echo ${localver} >localversion-grsec
35− ${attrs.preConfigure or ""}
36− '';
37−})
pkgs/os-specific/linux/kernel/grsecurity-nixos-config.nixdeleted−63
@@ -1,63 +0,0 @@
1−{ stdenv }:
2−
3−with stdenv.lib;
4−
5−''
6−# Auto configuration with these constraints will enable most of the
7−# important features (RAP, UDEREF, ASLR, memory sanitization).
8−GRKERNSEC_CONFIG_AUTO y
9−GRKERNSEC_CONFIG_DESKTOP y
10−GRKERNSEC_CONFIG_PRIORITY_SECURITY y
11−
12−# We specify virt guest rather than host here, the latter deselects e.g.,
13−# paravirtualization.
14−GRKERNSEC_CONFIG_VIRT_GUEST y
15−# Note: assumes platform supports CPU-level virtualization (so no pentium 4)
16−GRKERNSEC_CONFIG_VIRT_EPT y
17−GRKERNSEC_CONFIG_VIRT_KVM y
18−
19−# PaX control
20−PAX_SOFTMODE y
21−PAX_PT_PAX_FLAGS y
22−PAX_XATTR_PAX_FLAGS y
23−PAX_EI_PAX n
24−
25−PAX_INITIFY y
26−
27−# The bts instrumentation method is compatible with binary only modules.
28−#
29−# Note: if platform supports SMEP, we could do without this
30−PAX_KERNEXEC_PLUGIN_METHOD_BTS y
31−
32−# Additional grsec hardening not implied by auto constraints
33−GRKERNSEC_IO y
34−GRKERNSEC_SYSFS_RESTRICT y
35−GRKERNSEC_ROFS y
36−
37−GRKERNSEC_MODHARDEN y
38−
39−# Disable protections rendered useless by redistribution
40−GRKERNSEC_HIDESYM n
41−GRKERNSEC_RANDSTRUCT n
42−
43−# Disable protections covered by vanilla mechanisms
44−GRKERNSEC_DMESG n
45−GRKERNSEC_KMEM n
46−GRKERNSEC_PROC n
47−
48−# Disable protections that are inappropriate for a general-purpose kernel
49−GRKERNSEC_NO_SIMULT_CONNECT n
50−
51−# Enable additional audititing
52−GRKERNSEC_AUDIT_MOUNT y
53−GRKERNSEC_AUDIT_PTRACE y
54−GRKERNSEC_FORKFAIL y
55−
56−# Wishlist: support trusted path execution
57−GRKERNSEC_TPE n
58−
59−GRKERNSEC_SYSCTL y
60−GRKERNSEC_SYSCTL_DISTRO y
61−# Assume that appropriate sysctls are toggled once the system is up
62−GRKERNSEC_SYSCTL_ON n
63−''
pkgs/os-specific/linux/kernel/grsecurity-nixos-kmod.patchdeleted−14
@@ -1,14 +0,0 @@
1−diff -ru a/kernel/kmod.c b/kernel/kmod.c
2−--- a/kernel/kmod.c 2016-04-21 17:06:09.882281660 +0200
3−+++ b/kernel/kmod.c 2016-04-21 17:08:17.458949309 +0200
4−@@ -294,7 +294,9 @@
5− strncmp(sub_info->path, "/lib/", 5) && strncmp(sub_info->path, "/lib64/", 7) &&
6− strncmp(sub_info->path, "/usr/libexec/", 13) && strncmp(sub_info->path, "/usr/bin/", 9) &&
7− strncmp(sub_info->path, "/usr/sbin/", 10) && strcmp(sub_info->path, "/bin/false") &&
8−- strcmp(sub_info->path, "/usr/share/apport/apport")) || strstr(sub_info->path, "..")) {
9−+ strcmp(sub_info->path, "/usr/share/apport/apport") &&
10−+ strncmp(sub_info->path, "/nix/store/", 11) &&
11−+ strncmp(sub_info->path, "/run/current-system/systemd/lib/", 32)) || strstr(sub_info->path, "..")) {
12− printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of permitted system paths\n", sub_info->path);
13− retval = -EPERM;
14− goto out;
pkgs/os-specific/linux/kernel/linux-grsecurity.nixdeleted−18
@@ -1,18 +0,0 @@
1−{ stdenv, fetchurl, perl, buildLinux, ... } @ args:
2−
3−import ./generic.nix (args // rec {
4− version = "4.9.24";
5− extraMeta.branch = "4.9";
6−
7− src = fetchurl {
8− url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";
9− sha512 = "3031ldw2f6dwkm3z1cn7rw8y4diq57rs3na64nzkw7xw4q74cfpzzp5866vf58y0fsyl8l2vgvwza7cdhxywmmxp7q0q5385jn8nnvd";
10− };
11−
12− kernelPatches = args.kernelPatches;
13−
14− features.iwlwifi = true;
15− features.efiBootStub = true;
16− features.needsCifsUtils = true;
17− features.netfilterRPFilter = true;
18−} // (args.argsOverride or {}))
pkgs/os-specific/linux/kernel/patches.nix−28
@@ -17,26 +17,6 @@ let
1717 '';
1818 };
1919 };
20−
21− grsecPatch = { grbranch ? "test", grver ? "3.1", kver, grrev, sha512 }: 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− urls = [
29− "https://grsecurity.net/${grbranch}/${name}.patch"
30− # When updating versions/hashes, ALWAYS use the official
31− # version; we use this mirror only because upstream removes
32− # source files immediately upon releasing a new version ...
33− "https://raw.githubusercontent.com/slashbeast/grsecurity-scrape/master/${grbranch}/${kver}/${name}.patch"
34− ];
35− inherit sha512;
36− };
37−
38− features.grsecurity = true;
39− };
4020in
4121
4222rec {
@@ -107,14 +87,6 @@ rec {
10787 for more information.
10888 '';
10989
110− # This patch relaxes grsec constraints on the location of usermode helpers,
111− # e.g., modprobe, to allow calling into the Nix store.
112− grsecurity_nixos_kmod =
113− {
114− name = "grsecurity-nixos-kmod";
115− patch = ./grsecurity-nixos-kmod.patch;
116− };
117−
11890 crc_regression =
11991 { name = "crc-backport-regression";
12092 patch = ./crc-regression.patch;
pkgs/top-level/all-packages.nix+1−10
@@ -11922,16 +11922,7 @@ with pkgs;
1192211922 linuxPackages_grsec_nixos =
1192311923 recurseIntoAttrs (linuxPackagesFor linux_grsec_nixos);
1192411924
11925− # An unsupported grsec xen guest kernel
11926− linux_grsec_server_xen = linux_grsec_nixos.override {
11927− extraConfig = ''
11928− GRKERNSEC_CONFIG_AUTO y
11929− GRKERNSEC_CONFIG_PRIORITY_SECURITY y
11930− GRKERNSEC_CONFIG_SERVER y
11931− GRKERNSEC_CONFIG_VIRT_GUEST y
11932− GRKERNSEC_CONFIG_VIRT_XEN y
11933− '';
11934− };
11925+ linux_grsec_server_xen = linux_grsec_nixos;
1193511926
1193611927 # ChromiumOS kernels
1193711928 linuxPackages_chromiumos_3_18 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_chromiumos_3_18);