fix(hardening-basic): reclaim the dirty-page ratio twins that zero the bytes keys #9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/hardening-sysctl-dirty-twins"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
7aaae88added fixed dirty-page ceilings (vm.dirty_bytes,vm.dirty_background_bytes) to99-hardening.conf. The kernel treatseach
*_bytes/*_ratiopair as one limit and zeroes one when the other iswritten. So a
vm.dirty_ratioorvm.dirty_background_ratioline in/etc/sysctl.conf, which is read after every drop-in, leaves the*_byteskeys at 0. The read-back assert then failed with advice thatcouldn't work: it said to grep for a
*_bytesline that doesn't exist,and
hardening_sysctl_edit_sysctl_confhad nothing to comment out,because no line names the lost key.
What changed
--checkreport, name the*_ratiokey to look for. Withhardening_sysctl_edit_sysctl_confon, the reclaim comments out thatline as well.
with
\s*, which in multiline mode let^anchor on a blank line abovethe key: the marker was written onto the blank line and the key stayed
live. The pattern now matches spaces and tabs only.
--checkwith the flag on, the report no longer says the reclaimfailed, since check mode never attempts it. It points at the diff
instead.
Non-goal: the
net.ipv4.ip_forwardalias still refuses and says why.Reclaiming it can cut routing on a gateway, and the README keeps that
choice.
Verification
make check: exit 0, ansible-lint atproductionwith 0 warnings.does. Cases 18–19 cover the message and the reclaim. The blank-line
assertion fails when the old pattern is restored.
--check --diffshowed only the drop-in values and thetwo
*_ratiolines being commented out. The real run ended with"52 sysctl keys hold the values this role set",
failed=0.make test/make verify(no podman where this was built;molecule doesn't exercise this block anyway) and a second live run to
confirm idempotence (gate case 19 covers it).