Skip to content

Commit d18c6ec

Browse files
author
Kemal Rasim Sh
committed
selinux: Enhance Docker SEPolicy rules
Introduce a new tunable, dockerd_connect_user_services (default: off), to control whether the Docker daemon (dockerd_t) may connect to user session services. When enabled, the policy allows dockerd to use: pulseaudio_stream_connect(dockerd_t) wayland_stream_connect(dockerd_t) These permissions enable container workloads to access host audio and graphical services via PulseAudio and Wayland sockets located under /run/user/$UID. The docker-related permissions are gated using tunable_policy() and wrapped in optional_policy() blocks to ensure they are only applied when the corresponding policy modules are available. Together, these changes improve compatibility with CDI-enabled containers and containerized desktop workloads while maintaining secure-by-default behavior and modular policy design. Signed-off-by: Kemal Rasim Sh <kshakir@qti.qualcomm.com>
1 parent 2802e4b commit d18c6ec

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
From fa9fde3e037f395cd2ecc10cc86aa5f413c4528c Mon Sep 17 00:00:00 2001
2+
From: Kemal Rasim Sh <kshakir@qti.qualcomm.com>
3+
Date: Fri, 19 Jun 2026 13:43:44 +0300
4+
Subject: [PATCH 4/4] docker: Add tunable-gated optional policy for dockerd
5+
access to user session services
6+
7+
Introduce a new tunable to control whether the Docker daemon (dockerd_t)
8+
may connect to user session services over UNIX stream sockets.
9+
10+
This change adds the following interfaces:
11+
12+
pulseaudio_stream_connect(dockerd_t)
13+
wayland_stream_connect(dockerd_t)
14+
15+
These permissions allow dockerd to communicate with PulseAudio and Wayland compositor
16+
sockets typically located under /run/user/$UID, which is required for certain container
17+
workloads that need access to the host audio or graphical display.
18+
19+
The access is gated behind a new tunable:
20+
21+
dockerd_connect_user_services (default: off)
22+
23+
When enabled, the rules are applied via tunable_policy(), providing
24+
administrators explicit control using setsebool.
25+
26+
Both interfaces remain wrapped in optional_policy blocks to ensure the
27+
policy compiles and applies cleanly only when the corresponding PulseAudio
28+
and Wayland policy modules are present.
29+
30+
This approach improves compatibility with containerized desktop workloads
31+
while maintaining secure-by-default behavior and modular SELinux policy design.
32+
33+
Upstream-Status: Backport [https://github.com/SELinuxProject/refpolicy/pull/1167]
34+
35+
Signed-off-by: Kemal Rasim Sh <kshakir@qti.qualcomm.com>
36+
---
37+
policy/modules/services/docker.te | 21 +++++++++++++++++++++
38+
1 file changed, 21 insertions(+)
39+
40+
diff --git a/policy/modules/services/docker.te b/policy/modules/services/docker.te
41+
index f40713d12..cf45fc188 100644
42+
--- a/policy/modules/services/docker.te
43+
+++ b/policy/modules/services/docker.te
44+
@@ -5,6 +5,15 @@ policy_module(docker)
45+
# Declarations
46+
#
47+
48+
+## <desc>
49+
+## <p>
50+
+## Determine whether the Docker daemon can connect to user
51+
+## session services such as PulseAudio and Wayland over
52+
+## UNIX stream sockets.
53+
+## </p>
54+
+## </desc>
55+
+gen_tunable(dockerd_connect_user_services, false)
56+
+
57+
container_engine_domain_template(dockerd)
58+
container_system_engine(dockerd_t)
59+
optional_policy(`
60+
@@ -77,6 +86,18 @@ ifdef(`init_systemd',`
61+
init_stop_generic_units(dockerd_t)
62+
')
63+
64+
+optional_policy(`
65+
+ tunable_policy(`dockerd_connect_user_services',`
66+
+ pulseaudio_stream_connect(dockerd_t)
67+
+ ')
68+
+')
69+
+
70+
+optional_policy(`
71+
+ tunable_policy(`dockerd_connect_user_services',`
72+
+ wayland_stream_connect(dockerd_t)
73+
+ ')
74+
+')
75+
+
76+
########################################
77+
#
78+
# Docker CLI local policy
79+
--
80+
2.43.0
81+

dynamic-layers/selinux/recipes-security/refpolicy/refpolicy-targeted_git.bbappend

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ SRC_URI:append:qcom = " \
44
file://0001-container-Allow-access-to-etc-cdi-for-CDI-configurat.patch \
55
file://0002-wayland-Add-wayland_stream_connect-interface.patch \
66
file://0003-wayland-Label-sockets-under-run-with-wayland_runtime.patch \
7+
file://0004-docker-Add-tunable-gated-optional-policy-for-dockerd.patch \
78
"

0 commit comments

Comments
 (0)