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

Harden the loading of new modules to the kernel after install #148

Merged
merged 6 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/systemd/system/harden-module-loading.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Disable the loading of modules to the kernel after startup. This could be malicious.
After=systemd-modules-load.service
adrelanos marked this conversation as resolved.
Show resolved Hide resolved
Before=sysinit.target
# This functionality is implemented with this and not directly in the sysctl config is
# to allow systemd-modules-load.service to load the modules with no problem but
# to disallow anyone else do the same after the system boots up.

[Service]
Type=oneshot
ExecStart=/usr/libexec/security-misc/disable-kernel-module-loading

[Install]
WantedBy=sysinit.target
5 changes: 5 additions & 0 deletions usr/libexec/security-misc/disable-kernel-module-loading
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

adrelanos marked this conversation as resolved.
Show resolved Hide resolved
sysctl -w kernel.modules_disabled=1

echo "The loading of new modules to the kernel has been disabled by security-misc"