Skip to contentSkip to conversation

containers: add commands to correct SELinux context

PATCH In review Andrei Kvapil 2 participants 2 messages May 25, 2023 – May 26, 2023 DRBD driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 containers: add commands to correct SELinux context

When running the entry.sh script with RAM-based module loading method, the generated modules acquire the 'var_lib_t' context by default on certain systems.

This patch adds commands to correct the context to 'modules_object_t' to allow seamless module loading on SELinux-enabled systems.

---
 docker/entry.sh | 4 ++++
 1 file changed, 4 insertions(+)
docker/entry.sh +4 -0
index 2c91734e6..978df6431 100644
@@ -217,6 +217,10 @@ load_from_ram() {
 		find . -name "*.ko" -print0 | xargs -0 -n1 "/lib/modules/$(uname -r)/build/scripts/sign-file" "$CONFIG_MODULE_SIG_HASH" "${LB_SIGN}/signing_key.pem" "${LB_SIGN}/signing_key.x509" 
 	fi
 
+ 	chcon -t modules_object_t ./drbd.ko || true
+ 	chcon -t modules_object_t ./drbd_transport_tcp.ko || true
+ 	chcon -t modules_object_t ./drbd_transport_rdma.ko || true
+
 	insmod ./drbd.ko usermode_helper=disabled
 	insmod ./drbd_transport_tcp.ko
 	insmod ./drbd_transport_rdma.ko 2>/dev/null || true
Signature · 1 line
2.32.0 (Apple Git-132)
#1 lore raw
Quoted 28 lines · Andrei Kvapil

When running the entry.sh script with RAM-based module loading method, the generated modules acquire the 'var_lib_t' context by default on certain systems.

This patch adds commands to correct the context to 'modules_object_t' to allow seamless module loading on SELinux-enabled systems.

---
 docker/entry.sh | 4 ++++
 1 file changed, 4 insertions(+)
docker/entry.sh +4 -0
index 2c91734e6..978df6431 100644
@@ -217,6 +217,10 @@ load_from_ram() {
 		find . -name "*.ko" -print0 | xargs -0 -n1 "/lib/modules/$(uname -r)/build/scripts/sign-file" "$CONFIG_MODULE_SIG_HASH" "${LB_SIGN}/signing_key.pem" "${LB_SIGN}/signing_key.x509" 
 	fi
 
+ 	chcon -t modules_object_t ./drbd.ko || true
+ 	chcon -t modules_object_t ./drbd_transport_tcp.ko || true
+ 	chcon -t modules_object_t ./drbd_transport_rdma.ko || true
+
 	insmod ./drbd.ko usermode_helper=disabled
 	insmod ./drbd_transport_tcp.ko
 	insmod ./drbd_transport_rdma.ko 2>/dev/null || true
Signature · 1 line
2.32.0 (Apple Git-132)

Thanks, I will queue that up for out of tree DRBD9.

Regards, rck