Skip to contentSkip to conversation

rng-tools: Restrict rngd.service

PATCH In review Alex Kiernan 2 participants 2 messages Apr 23, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rng-tools: Restrict rngd.service

Whilst rngd has to run as root, we can significantly constrain its permissions (network is only required if nistbeacon is enabled).

---

Changes in v2:
- fix network access

 .../rng-tools/rng-tools/rngd.service          | 19 +++++++++++++++++++
 .../rng-tools/rng-tools_6.9.bb                |  7 +++++++
 2 files changed, 26 insertions(+)
meta/recipes-support/rng-tools/rng-tools/rngd.service +19 -0
index 084322ac40aa..0559b9799154 100644
@@ -8,6 +8,25 @@ Conflicts=shutdown.target
 [Service]
 EnvironmentFile=-@SYSCONFDIR@/default/rng-tools
 ExecStart=@SBINDIR@/rngd -f $EXTRA_ARGS
+CapabilityBoundingSet=CAP_SYS_ADMIN
+IPAddressDeny=any
+LockPersonality=yes
+MemoryDenyWriteExecute=yes
+NoNewPrivileges=yes
+PrivateTmp=yes
+ProtectControlGroups=yes
+ProtectHome=yes
+ProtectHostname=yes
+ProtectKernelModules=yes
+ProtectKernelLogs=yes
+ProtectSystem=strict
+RestrictAddressFamilies=AF_UNIX
+RestrictNamespaces=yes
+RestrictRealtime=yes
+RestrictSUIDSGID=yes
+SystemCallArchitectures=native
+SystemCallErrorNumber=EPERM
+SystemCallFilter=@system-service
 
 [Install]
 WantedBy=sysinit.target
meta/recipes-support/rng-tools/rng-tools_6.9.bb +7 -0
index 913342c315de..8c98a9aa3ae2 100644
@@ -49,4 +49,11 @@ do_install_append() {
         -e 's,@SBINDIR@,${sbindir},g' \
         ${D}${sysconfdir}/init.d/rng-tools \
         ${D}${systemd_system_unitdir}/rngd.service
+
+    if [ "${@bb.utils.contains('PACKAGECONFIG', 'nistbeacon', 'yes', 'no', d)}" = "yes" ]; then
+        sed -i \
+            -e '/^IPAddressDeny=any/d' \
+            -e '/^RestrictAddressFamilies=/ s/$/ AF_INET AF_INET6/' \
+            ${D}${systemd_system_unitdir}/rngd.service
+    fi
 }
Signature · 1 line
2.17.1
#1 lore raw

✗ patchtest: failure for rng-tools: Restrict rngd.service

== Series Details ==

Series: rng-tools: Restrict rngd.service
Revision: 1
URL : https://patchwork.openembedded.org/series/23860/
State : failure

== Summary ==

Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:

* Issue Series does not apply on top of target branch [test_series_merge_on_head]
Suggested fix Rebase your series on top of targeted branch
Targeted branch master (currently at 1795f30d8a)

If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).

---

Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe