modules/security: hardened kernel; protect kernel & modules

This commit is contained in:
NotAShelf 2024-08-18 16:51:14 +03:00
parent 3d9b446c98
commit ca724b08b3
No known key found for this signature in database
GPG key ID: AF26552424E53993

19
modules/security.nix Normal file
View file

@ -0,0 +1,19 @@
{
pkgs,
lib,
...
}: let
inherit (lib.modules) mkForce;
in {
boot.kernelPackages = pkgs.linuxPackages_hardened;
security = {
# Do not allow loading additional kernel modules imperatively.
lockKernelModules = false;
# Disallow replacing the running kernel. This breaks hibernation
# which is practically useless on a server.
protectKernelImage = true;
allowSimultaneousMultithreading = mkForce false;
};
}