sec-policy/flatcar-selinux-patches: add Calico fix - #4249
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the Flatcar downstream sec-policy patchset to address a new SELinux denial seen with Calico ≥ 3.32.2 by adding an additional allow-rule in the patched policy sources.
Changes:
- Refreshes the patch header/summary metadata (commit SHA + insertion counts) for
0001-Flatcar-modifications.patch. - Adds an SELinux policy allow-rule granting
kernel_ttheprocess execmempermission to avoid the reported Calico denial.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| +# | ||
| +# This one happens in kubeadm.*.calico*. | ||
| +# | ||
| +# avc: denied { execmem } for pid=2873 comm="calico-node" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=process permissive=0 |
| +# This one happens in kubeadm.*.calico*. | ||
| +# | ||
| +# avc: denied { execmem } for pid=2873 comm="calico-node" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=process permissive=0 | ||
| +allow kernel_t self:process { execmem }; |
There was a problem hiding this comment.
Yeah, that was my thinking even before I saw Copilot's message.
d11bfd4 to
71317de
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
sdk_container/src/third_party/coreos-overlay/coreos/user-patches/sec-policy/flatcar-selinux-patches/0001-Flatcar-modifications.patch:310
allow kernel_t self:process { execmem };is a high-impact permission (W+X mappings) granted to all processes inkernel_t. Since this is being added to address a Calico-specific denial, it would help to (a) reference the upstream issue and (b) explicitly note whykernel_tis the right domain here (vs fixing the labeling/transition), so future policy tightening doesn’t accidentally depend on this broad allowance.
+#
+# This one happens in kubeadm.*.calico*.
+#
+# avc: denied { execmem } for pid=2873 comm="calico-node" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=process permissive=0
+allow kernel_t self:process { execmem };
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 3 changed files in this pull request and generated 2 comments.
Suppressed comments (1)
sdk_container/src/third_party/coreos-overlay/coreos/user-patches/sec-policy/flatcar-selinux-patches/0001-Flatcar-modifications.patch:310
- Granting execmem to kernel_t is a very broad relaxation (it effectively disables W^X-style protection for any process running in kernel_t). If this is truly needed for Calico, it would help to reference the upstream issue/version and ideally constrain the permission (e.g., via a tunable/conditional or by fixing the labeling so calico-node isn’t running in kernel_t).
+# FLATCAR:
+#
+# This one happens in kubeadm.*.calico*.
+#
+# avc: denied { execmem } for pid=2873 comm="calico-node" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=process permissive=0
+allow kernel_t self:process { execmem };
| From de5bb7b5770c60ae3df9b9ee276fde22f62b18fd Mon Sep 17 00:00:00 2001 | ||
| From: Krzesimir Nowak <knowak@microsoft.com> | ||
| Date: Mon, 4 Dec 2023 12:17:25 +0100 | ||
| Subject: [PATCH] Flatcar modifications |
| policy/modules/admin/netutils.te | 20 +++ | ||
| policy/modules/kernel/corenetwork.if.in | 26 ++++ | ||
| policy/modules/kernel/corenetwork.te.in | 12 +- | ||
| policy/modules/kernel/files.if | 45 ++++++ | ||
| policy/modules/kernel/kernel.te | 125 +++++++++++++++++ | ||
| policy/modules/kernel/kernel.te | 133 ++++++++++++++++++ |
This fixes a denial starting from Calico 3.32.2. Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
this rebuild the packages to use the new downstream patch Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
This seems to not be needed anymore Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
be766ca to
d15b382
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
sdk_container/src/third_party/coreos-overlay/coreos/user-patches/sec-policy/flatcar-selinux-patches/README.md:14
- The README’s “Generate the patch” step was truncated; it no longer explains how to produce a correctly prefixed patch (the
--src-prefix/--dst-prefixdetail matters for these refpolicy patches). This makes the workflow hard to reproduce for future updates.
- Generate the patch
sdk_container/src/third_party/coreos-overlay/coreos/user-patches/sec-policy/flatcar-selinux-patches/0001-Flatcar-modifications.patch:310
- Granting
execmemtokernel_tis a very broad permission (it weakens W^X for a highly privileged domain). If this is strictly needed for Calico 3.32.2’scalico-nodeon Flatcar, consider whether the process can be transitioned into a more specific domain (or a dedicated policy type) and allowexecmemthere instead. At minimum, it would be good to document whycalico-nodeis running askernel_tand link the upstream report for future audits.
+#
+# This one happens in kubeadm.*.calico*.
+#
+# avc: denied { execmem } for pid=2873 comm="calico-node" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=process permissive=0
+allow kernel_t self:process { execmem };
This fixes a denial starting from Calico 3.32.2. (See: projectcalico/calico#13685 as well)
Testing done
To be tested with: flatcar/mantle#943
Changelog entries added in the respectivechangelog/directory (user-facing change, bug fix, security fix, update)/bootand/usrsize, packages, list files for any missing binaries, kernel modules, config files, kernel modules, etc.I'll do best effort to backport this on other channels.