Blame SOURCES/0002-fix-firewalld-keep-linux-capability-CAP_SYS_MODULE.patch

d06f9c
From 09cdc166ddfe53b6e8ce3a2920f798320c170b7f Mon Sep 17 00:00:00 2001
d06f9c
From: Eric Garver <eric@garver.life>
d06f9c
Date: Wed, 11 Aug 2021 14:47:59 -0400
d06f9c
Subject: [PATCH 2/3] fix(firewalld): keep linux capability CAP_SYS_MODULE
d06f9c
d06f9c
When firewalld calls ip6tables it may implicitly load the ip6_tables, et
d06f9c
al kernel modules. As such we need to retain CAP_SYS_MODULE so that
d06f9c
implicit module is allowed. Otherwise we get EPERM from the kernel.
d06f9c
d06f9c
This only affects the -legacy variants and the top level table/chain
d06f9c
modules. The userspace binaries will modprobe the kernel modules.
d06f9c
Extensions, e.g. xt_conntrack, are implicitly loaded by the kernel based
d06f9c
on the rules being added and thus not subject to linux capabilities
d06f9c
checks.
d06f9c
d06f9c
The -nft variants are unaffected because they use the nftables
d06f9c
infrastructure which has implicit module loading in the kernel similar
d06f9c
to the iptables extensions (xt_* modules).
d06f9c
d06f9c
Fixes: rhbz 1990271
d06f9c
Fixes: fb0532e8a200 ("feat(firewalld): drop linux capabilities")
d06f9c
(cherry picked from commit 13801962073f478c68d818b314091badcf8b5614)
d06f9c
(cherry picked from commit d3cd7e088f946c75593b0569bd658266b2e9329d)
d06f9c
---
d06f9c
 src/firewalld.in | 5 ++++-
d06f9c
 1 file changed, 4 insertions(+), 1 deletion(-)
d06f9c
d06f9c
diff --git a/src/firewalld.in b/src/firewalld.in
d06f9c
index abcbe3508f86..b1c886c6f02f 100755
d06f9c
--- a/src/firewalld.in
d06f9c
+++ b/src/firewalld.in
d06f9c
@@ -136,6 +136,7 @@ def startup(args):
d06f9c
         # attempt to drop Linux capabilities to a minimal set:
d06f9c
         #   - CAP_NET_ADMIN
d06f9c
         #   - CAP_NET_RAW
d06f9c
+        #   - CAP_SYS_MODULE
d06f9c
         try:
d06f9c
             import capng
d06f9c
             capng.capng_clear(capng.CAPNG_SELECT_BOTH)
d06f9c
@@ -143,8 +144,10 @@ def startup(args):
d06f9c
                                capng.CAP_NET_ADMIN)
d06f9c
             capng.capng_update(capng.CAPNG_ADD, capng.CAPNG_EFFECTIVE | capng.CAPNG_PERMITTED | capng.CAPNG_BOUNDING_SET,
d06f9c
                                capng.CAP_NET_RAW)
d06f9c
+            capng.capng_update(capng.CAPNG_ADD, capng.CAPNG_EFFECTIVE | capng.CAPNG_PERMITTED | capng.CAPNG_BOUNDING_SET,
d06f9c
+                               capng.CAP_SYS_MODULE)
d06f9c
             capng.capng_apply(capng.CAPNG_SELECT_BOTH)
d06f9c
-            log.info(log.INFO1, "Dropped Linux capabilities to NET_ADMIN, NET_RAW.")
d06f9c
+            log.info(log.INFO1, "Dropped Linux capabilities to NET_ADMIN, NET_RAW, SYS_MODULE.")
d06f9c
         except ImportError:
d06f9c
             pass
d06f9c
 
d06f9c
-- 
d06f9c
2.31.1
d06f9c