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
|
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.
Set ProtectControlGroups=true in mariadb.service and mariadb@.service to make /sys/fs/cgroup read-only for the service. Improves systemd-analyze security while keeping auth_pam (PAMv2) working.
84abbd1 to
2044572
Compare
|
Thanks @grooverdan. I was able to reproduce locally on a Debian 12 VM (MariaDB
With those hardening directives enabled, PAMv2 fails the same way as in buildbot: What stood out is that I also bisected the directives with a drop-in override. I just updated the PR to keep only Would it make sense to look at the other knobs separately later, maybe as an opt-in profile for setups that do not use |
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