MDEV-39057: systemd: Add low risk hardening to unit templates#4787
MDEV-39057: systemd: Add low risk hardening to unit templates#4787aquilamacedo wants to merge 1 commit intoMariaDB:10.11from
Conversation
Harden mariadb.service and mariadb@.service with low regression systemd sandboxing defaults (kernel/cgroup protections, restrict namespaces, disable realtime, lock personality, overrideable via drop-in). Avoid historically problematic knobs (NoNewPrivileges, capability bounding, PrivateDevices). Refs: MDEV-10404, MDEV-19878, MDEV-36591, MDEV-36681
|
Thanks @aquilamacedo. Due to a limitation of PR, they don't run the full package tests. So https://buildbot.mariadb.org/#/grid?branch=bb-10.11-pr4787-systemd-hardening-safe-defaults-pkgtest is the same thing there where we'll see in the autopkg-install tests how things go on native kernels. I added a removal of NNP which I was pretty confident about. Capabilities where cleaned up in c461188. PrivateDevices=false remove MDEV-36721 680b0cd |
|
So much for my NNP confidence. It was in dealing with selinux, however caused the PAMv2 test to fai. Attempt 2 - https://buildbot.mariadb.org/#/grid?branch=bb-10.11-pr4787-systemd-hardening-safe-defaults-pkgtest2 - which is exactly this PR. Seems its something in this basic hardening preventing the PAMv2 failures. Are you able to replicate https://buildbot.mariadb.org/#/builders/599/builds/4510/steps/5/logs/stdio in a local instance:
Adjust low risk hardening until there's a |
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for your contribution! This is a preliminary review.
LGTM. Please stand by for the final review.
Adds a handful of conservative systemd hardening defaults to the upstream unit templates (
support-files/mariadb.service.inandsupport-files/mariadb@.service.in). The goal is to improvesystemd-analyze securitywithout changing normal MariaDB behavior.Enabled in this change:
ProtectKernelTunables=true,ProtectKernelModules=true,ProtectControlGroups=trueRestrictRealtime=trueLockPersonality=trueRestrictNamespaces=true(easy to override via a systemd drop-in if someone really needs it)Intentionally not enabled:
I'm intentionally not touching the knobs that have historically caused regressions across distros / SELinux / PAM setups:
NoNewPrivileges=(SELinux transition history, refs MDEV-10404)PrivateDevices=(PAM/SUID helper history, ref MDEV-19878)Happy to follow up with a separate PR for
NoNewPrivileges=true(and anything else stronger) once this lands and we get broader feedback.Downstream note (Debian)
This exact set of directives has been carried in Debian for ~1 month with no regressions reported so far. Context: https://salsa.debian.org/mariadb-team/mariadb-server/-/merge_requests/152.
Tested
systemctl restart mariadb/mariadb@.servicejournalctl -u 'mariadb*'for new errors/denialssystemd-analyze security mariadb.servicebefore/after