sepolicy: Allow bluetooth to send D-Bus messages to systemd
PATCH 1/1 sepolicy: Allow bluetooth to send D-Bus messages to systemd
Add init_dbus_chat() for bluetooth_t to allow bluetoothd to send D-Bus method_return messages back to systemd (init_t) over the system bus.
Below avc denial is fixed with this patch:
avc: denied { send_msg } for msgtype=method_return dest=:1.11 scontext=system_u:system_r:bluetooth_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=dbus permissive=0
--- policy/modules/services/bluetooth.te | 1 + 1 file changed, 1 insertion(+)
policy/modules/services/bluetooth.te +1 -0
@@ -136,6 +136,7 @@ userdom_dontaudit_search_user_home_dirs(bluetooth_t) optional_policy(` dbus_system_bus_client(bluetooth_t) dbus_connect_system_bus(bluetooth_t) + init_dbus_chat(bluetooth_t) init_dbus_send_script(bluetooth_t) optional_policy(`
Signature · 1 line
2.34.1
Quoted 20 lines · Wei Deng
Add
init_dbus_chat()forbluetooth_tto allow bluetoothd to send D-Busmethod_returnmessages back to systemd (init_t) over the system bus.Below avc denial is fixed with this patch:
avc: denied {
send_msg} for msgtype=method_return dest=:1.11 scontext=system_u:system_r:bluetooth_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=dbus permissive=0Signed-off-by Wei Deng <[email protected]>--- policy/modules/services/bluetooth.te | 1 + 1 file changed, 1 insertion(+)policy/modules/services/bluetooth.te +0
-0
policy/modules/services/bluetooth.te userdom_dontaudit_search_user_home_dirs(bluetooth_t) · line 142
Quoted 7 lines
policy/modules/services/bluetooth.te +1
-0@@ -136,6 +136,7 @@ userdom_dontaudit_search_user_home_dirs(bluetooth_t) optional_policy(` dbus_system_bus_client(bluetooth_t) dbus_connect_system_bus(bluetooth_t) + init_dbus_chat(bluetooth_t) init_dbus_send_script(bluetooth_t) optional_policy(`
Can you confirm this response is going to systemd/pid1? Is there a fuller set of log messages corresponding to this denial? The init_dbus_send_script() makes me wonder.
Signature · 1 line
Chris PeBenito
Hi Chris,
Thanks for the review.
Quoted 16 lines · Christopher J. PeBenito
Quoted 15 lines · Wei Deng
Add
init_dbus_chat()forbluetooth_tto allow bluetoothd to send D-Busmethod_returnmessages back to systemd (init_t) over the system bus.Below avc denial is fixed with this patch:
avc: denied {
send_msg} for msgtype=method_return dest=:1.11 scontext=system_u:system_r:bluetooth_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=dbus permissive=0Signed-off-by Wei Deng <[email protected]>---
policy/modules/services/bluetooth.te | 1 +1 file changed, 1 insertion(+)
Quoted 13 lines
Quoted 11 lines
policy/modules/services/bluetooth.te +0
-0@@ -136,6 +136,7 @@ userdom_dontaudit_search_user_home_dirs(bluetooth_t)optional_policy(`
dbus_system_bus_client(bluetooth_t)
dbus_connect_system_bus(bluetooth_t)
+init_dbus_chat(bluetooth_t)
init_dbus_send_script(bluetooth_t)
optional_policy(`Can you confirm this response is going to systemd/pid1? Is there a fuller set of log messages corresponding to this denial? The
init_dbus_send_script()makes me wonder.
The two log entries list here:
type=SERVICE_START msg=audit(19.419:292): pid=1 uid=0
subj=system_u:system_r:init_t:s0
msg='unit=bluetooth comm="systemd"
exe="/usr/lib/systemd/systemd" ... res=success'type=USER_AVC msg=audit(19.547:319):
subj=system_u:system_r:system_dbusd_t:s0
msg='avc: denied { send_msg } for msgtype=method_return
dest=:1.11 spid=684 tpid=843
scontext=system_u:system_r:bluetooth_t:s0
tcontext=system_u:system_r:init_t:s0
tclass=dbus permissive=0
exe="/usr/bin/dbus-daemon"'Quoted 2 lines
Can you confirm this response is going to systemd/pid1? Is there a fuller set of log messages corresponding to this denial?
Yes. The SERVICE_START entry shows pid=1 with exe="/usr/lib/systemd/systemd" running under init_t, confirming that init_t is systemd's SELinux domain.
Quoted 1 line
The
init_dbus_send_script()makes me wonder.
They target different domains:
init_dbus_send_script(): bluetooth_t -> initrc_t (SysV init scripts)
init_dbus_chat(): bluetooth_t <-> init_t (systemd itself)
Both are needed for cross-platform compatibility.
Quoted 1 line
Signature · 2 lines
Best Regards, Wei Deng
Quoted 49 lines · Wei Deng
Hi Chris,
Thanks for the review.
Quoted 16 lines · Christopher J. PeBenito
Quoted 15 lines · Wei Deng
Add
init_dbus_chat()forbluetooth_tto allow bluetoothd to send D-Busmethod_returnmessages back to systemd (init_t) over the system bus.Below avc denial is fixed with this patch:
avc: denied {
send_msg} for msgtype=method_return dest=:1.11 scontext=system_u:system_r:bluetooth_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=dbus permissive=0Signed-off-by Wei Deng <[email protected]>--- policy/modules/services/bluetooth.te | 1 + 1 file changed, 1 insertion(+)Quoted 12 lines
policy/modules/services/bluetooth.te userdom_dontaudit_search_user_home_dirs(bluetooth_t) · line 141
Quoted 11 lines
policy/modules/services/bluetooth.te +1
-0@@ -136,6 +136,7 @@ userdom_dontaudit_search_user_home_dirs(bluetooth_t) optional_policy(` dbus_system_bus_client(bluetooth_t) dbus_connect_system_bus(bluetooth_t) + init_dbus_chat(bluetooth_t) init_dbus_send_script(bluetooth_t) optional_policy(`Can you confirm this response is going to systemd/pid1? Is there a fuller set of log messages corresponding to this denial? The
init_dbus_send_script()makes me wonder.The two log entries list here:
type=SERVICE_START msg=audit(19.419:292): pid=1 uid=0 subj=system_u:system_r:init_t:s0 msg='unit=bluetooth comm="systemd" exe="/usr/lib/systemd/systemd" ... res=success' type=USER_AVC msg=audit(19.547:319): subj=system_u:system_r:system_dbusd_t:s0 msg='avc: denied { send_msg } for msgtype=method_return dest=:1.11 spid=684 tpid=843 scontext=system_u:system_r:bluetooth_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=dbus permissive=0 exe="/usr/bin/dbus-daemon"'
Quoted 5 lines
Quoted 2 lines
Can you confirm this response is going to systemd/pid1? Is there a fuller set of log messages corresponding to this denial?
Yes. The
SERVICE_STARTentry shows pid=1 with exe="/usr/lib/systemd/systemd" running underinit_t, confirming thatinit_tis systemd's SELinux domain.
These two audit messages are not related, as they have different event IDs (292 vs 319). Additionally, SERVICE_START messages are expected to come from pid=1.
Quoted 7 lines
Quoted 1 line
The
init_dbus_send_script()makes me wonder.They target different domains:
init_dbus_send_script(): bluetooth_t -> initrc_t (SysV init scripts) init_dbus_chat(): bluetooth_t <-> init_t (systemd itself)Both are needed for cross-platform compatibility.
initrc_t also exists on systemd systems for generic commands run from systemd units. However, if these rules are needed for sysvinit vs systemd, then these two rules should be put in an if/else of an init_systemd block.
Signature · 1 line
Chris PeBenito
Hi Chris,
Quoted 56 lines · Christopher J. PeBenito
Quoted 49 lines · Wei Deng
Hi Chris,
Thanks for the review.
Quoted 16 lines · Christopher J. PeBenito
Quoted 15 lines · Wei Deng
Add
init_dbus_chat()forbluetooth_tto allow bluetoothd to send D-Busmethod_returnmessages back to systemd (init_t) over the system bus.Below avc denial is fixed with this patch:
avc: denied {
send_msg} for msgtype=method_return dest=:1.11 scontext=system_u:system_r:bluetooth_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=dbus permissive=0Signed-off-by Wei Deng <[email protected]>---
policy/modules/services/bluetooth.te | 1 +1 file changed, 1 insertion(+)Quoted 12 lines
Quoted 11 lines
policy/modules/services/bluetooth.te +0
-0@@ -136,6 +136,7 @@ userdom_dontaudit_search_user_home_dirs(bluetooth_t)optional_policy(`
dbus_system_bus_client(bluetooth_t)
dbus_connect_system_bus(bluetooth_t)
+init_dbus_chat(bluetooth_t)
init_dbus_send_script(bluetooth_t)
optional_policy(`Can you confirm this response is going to systemd/pid1? Is there a fuller set of log messages corresponding to this denial? The
init_dbus_send_script()makes me wonder.The two log entries list here:
type=SERVICE_START msg=audit(19.419:292): pid=1 uid=0 subj=system_u:system_r:init_t:s0 msg='unit=bluetooth comm="systemd" exe="/usr/lib/systemd/systemd" ... res=success'
type=USER_AVC msg=audit(19.547:319):
subj=system_u:system_r:system_dbusd_t:s0 msg='avc: denied {send_msg} for msgtype=method_return dest=:1.11 spid=684 tpid=843 scontext=system_u:system_r:bluetooth_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=dbus permissive=0 exe="/usr/bin/dbus-daemon"'Quoted 5 lines
Quoted 2 lines
Can you confirm this response is going to systemd/pid1? Is there a fuller set of log messages corresponding to this denial?
Yes. The
SERVICE_STARTentry shows pid=1 with exe="/usr/lib/systemd/systemd" running underinit_t, confirming thatinit_tis systemd's SELinux domain.
Quoted 6 lines
These two audit messages are not related, as they have different event IDs (292 vs 319). Additionally,
SERVICE_STARTmessages are expected to come from pid=1.Can you confirm this response is going to systemd/pid1? Is there a fuller set of log messages corresponding to this denial?
You are right. I apologize for the confusion. The two audit messages are unrelated, as they have different event IDs.
Here is the full AVC denial:
type=USER_AVC msg=audit(1773416627.807:455):
pid=801 uid=997 auid=4294967295 ses=4294967295
subj=system_u:system_r:system_dbusd_t:s0
msg='avc: denied { send_msg } for
msgtype=method_return dest=:1.27
spid=1942 tpid=1944
scontext=system_u:system_r:bluetooth_t:s0
tcontext=system_u:system_r:init_t:s0
tclass=dbus permissive=0
exe="/usr/bin/dbus-daemon"'The tpid=1944 is obexd, not systemd/pid1, as confirmed by:
ps -p 1944 -o pid,ppid,comm,exe,label
PID PPID COMMAND EXE LABEL
1944 1 obexd /usr/libexec/bluetooth/obexd system_u:system_r:init_t:s0So the real issue is not bluetooth_t -> init_t (systemd), but bluetooth_t -> init_t (obexd running in the wrong domain).
The root cause is that obex.te currently uses userdom_user_application_domain(), which does not create a domain transition from init_t. obexd therefore inherits systemd's domain instead of transitioning to obex_t.
The fix is to replace userdom_user_application_domain() with init_daemon_domain() in obex.te:
-attribute_role obex_roles;
-
type obex_t;
type obex_exec_t;
-userdom_user_application_domain(obex_t, obex_exec_t) -role obex_roles types obex_t; +init_daemon_domain(obex_t, obex_exec_t)
With this change, obexd correctly transitions to obex_t:
ps -eZ | grep obexd system_u:system_r:obex_t:s0 986 ? 00:00:00 obexd
This shifts the denial from bluetooth_t -> init_t to bluetooth_t -> obex_t, which is the correct relationship to address in policy.
If this approach is acceptable, I will submit a follow-up patch to update the obex policy accordingly, including fixing the resulting AVC denials for obex_t.
Would you have any concerns or suggestions?
Quoted 12 lines
Quoted 8 lines
Quoted 2 lines
The
init_dbus_send_script()makes me wonder.They target different domains:
init_dbus_send_script():bluetooth_t->initrc_t(SysV init scripts) init_dbus_chat():bluetooth_t<-> init_t (systemd itself)Both are needed for cross-platform compatibility.
initrc_talso exists on systemd systems for generic commands run from systemd units. However, if these rules are needed for sysvinit vs systemd, then these two rules should be put in an if/else of aninit_systemdblock.
Signature · 2 lines
Best Regards, Wei Deng
Quoted 79 lines · Wei Deng
Quoted 48 lines · Christopher J. PeBenito
Quoted 47 lines · Wei Deng
Quoted 16 lines · Christopher J. PeBenito
Quoted 15 lines · Wei Deng
Add
init_dbus_chat()forbluetooth_tto allow bluetoothd to send D-Busmethod_returnmessages back to systemd (init_t) over the system bus.Below avc denial is fixed with this patch:
avc: denied {
send_msg} for msgtype=method_return dest=:1.11 scontext=system_u:system_r:bluetooth_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=dbus permissive=0Signed-off-by Wei Deng <[email protected]>--- policy/modules/services/bluetooth.te | 1 + 1 file changed, 1 insertion(+)Quoted 12 lines
policy/modules/services/bluetooth.te userdom_dontaudit_search_user_home_dirs(bluetooth_t) · line 141
Quoted 11 lines
policy/modules/services/bluetooth.te +1
-0@@ -136,6 +136,7 @@ userdom_dontaudit_search_user_home_dirs(bluetooth_t) optional_policy(` dbus_system_bus_client(bluetooth_t) dbus_connect_system_bus(bluetooth_t) + init_dbus_chat(bluetooth_t) init_dbus_send_script(bluetooth_t) optional_policy(`Can you confirm this response is going to systemd/pid1? Is there a fuller set of log messages corresponding to this denial? The
init_dbus_send_script()makes me wonder.The two log entries list here:
type=SERVICE_START msg=audit(19.419:292): pid=1 uid=0 subj=system_u:system_r:init_t:s0 msg='unit=bluetooth comm="systemd" exe="/usr/lib/systemd/systemd" ... res=success'
type=USER_AVC msg=audit(19.547:319):
subj=system_u:system_r:system_dbusd_t:s0 msg='avc: denied {send_msg} for msgtype=method_return dest=:1.11 spid=684 tpid=843 scontext=system_u:system_r:bluetooth_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=dbus permissive=0 exe="/usr/bin/dbus-daemon"'Quoted 2 lines
Can you confirm this response is going to systemd/pid1? Is there a fuller set of log messages corresponding to this denial?
Quoted 8 lines
Quoted 3 lines
Yes. The
SERVICE_STARTentry shows pid=1 with exe="/usr/lib/systemd/systemd" running underinit_t, confirming thatinit_tis systemd's SELinux domain.These two audit messages are not related, as they have different event IDs (292 vs 319). Additionally,
SERVICE_STARTmessages are expected to come from pid=1.Can you confirm this response is going to systemd/pid1? Is there a fuller set of log messages corresponding to this denial?
You are right. I apologize for the confusion. The two audit messages are unrelated, as they have different event IDs.
Here is the full AVC denial:
type=USER_AVC msg=audit(1773416627.807:455): pid=801 uid=997 auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t:s0 msg='avc: denied { send_msg } for msgtype=method_return dest=:1.27 spid=1942 tpid=1944 scontext=system_u:system_r:bluetooth_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=dbus permissive=0 exe="/usr/bin/dbus-daemon"'The tpid=1944 is obexd, not systemd/pid1, as confirmed by:
ps -p 1944 -o pid,ppid,comm,exe,label
PID PPID COMMAND EXE LABEL 1944 1 obexd /usr/libexec/bluetooth/obexd system_u:system_r:init_t:s0
Quoted 7 lines
So the real issue is not
bluetooth_t->init_t(systemd), butbluetooth_t->init_t(obexd running in the wrong domain).The root cause is that obex.te currently uses
userdom_user_application_domain(), which does not create a domain transition frominit_t. obexd therefore inherits systemd's domain instead of transitioning toobex_t.
Thanks for working that out. It would be acceptable to add this in refpolicy, but I think it should be tunable. It's not a common case configuration.
Signature · 1 line
Chris PeBenito
Hi Chris,
Quoted 83 lines · Christopher J. PeBenito
Quoted 82 lines · Wei Deng
Quoted 48 lines · Christopher J. PeBenito
Quoted 47 lines · Wei Deng
Quoted 16 lines · Christopher J. PeBenito
Quoted 15 lines · Wei Deng
Add
init_dbus_chat()forbluetooth_tto allow bluetoothd to send D-Busmethod_returnmessages back to systemd (init_t) over the system bus.Below avc denial is fixed with this patch:
avc: denied {
send_msg} for msgtype=method_return dest=:1.11 scontext=system_u:system_r:bluetooth_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=dbus permissive=0Signed-off-by Wei Deng <[email protected]>---
policy/modules/services/bluetooth.te | 1 +1 file changed, 1 insertion(+)Quoted 12 lines
Quoted 11 lines
policy/modules/services/bluetooth.te +0
-0@@ -136,6 +136,7 @@ userdom_dontaudit_search_user_home_dirs(bluetooth_t)optional_policy(`
dbus_system_bus_client(bluetooth_t)
dbus_connect_system_bus(bluetooth_t)
+init_dbus_chat(bluetooth_t)
init_dbus_send_script(bluetooth_t)
optional_policy(`Can you confirm this response is going to systemd/pid1? Is there a fuller set of log messages corresponding to this denial? The
init_dbus_send_script()makes me wonder.The two log entries list here:
type=SERVICE_START msg=audit(19.419:292): pid=1 uid=0 subj=system_u:system_r:init_t:s0 msg='unit=bluetooth comm="systemd" exe="/usr/lib/systemd/systemd" ... res=success'
type=USER_AVC msg=audit(19.547:319):
subj=system_u:system_r:system_dbusd_t:s0 msg='avc: denied {send_msg} for msgtype=method_return dest=:1.11 spid=684 tpid=843 scontext=system_u:system_r:bluetooth_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=dbus permissive=0 exe="/usr/bin/dbus-daemon"'Quoted 2 lines
Can you confirm this response is going to systemd/pid1? Is there a fuller set of log messages corresponding to this denial?
Quoted 8 lines
Quoted 3 lines
Yes. The
SERVICE_STARTentry shows pid=1 with exe="/usr/lib/systemd/systemd" running underinit_t, confirming thatinit_tis systemd's SELinux domain.These two audit messages are not related, as they have different event IDs (292 vs 319). Additionally,
SERVICE_STARTmessages are expected to come from pid=1.Can you confirm this response is going to systemd/pid1? Is there a fuller set of log messages corresponding to this denial?
You are right. I apologize for the confusion. The two audit messages are unrelated, as they have different event IDs.
Here is the full AVC denial:
type=USER_AVC msg=audit(1773416627.807:455):
pid=801 uid=997 auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t:s0 msg='avc: denied {send_msg} for msgtype=method_return dest=:1.27 spid=1942 tpid=1944 scontext=system_u:system_r:bluetooth_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=dbus permissive=0 exe="/usr/bin/dbus-daemon"'The tpid=1944 is obexd, not systemd/pid1, as confirmed by:
ps -p 1944 -o pid,ppid,comm,exe,label
PID PPID COMMAND EXE LABEL
1944 1 obexd /usr/libexec/bluetooth/obexd system_u:system_r:init_t:s0So the real issue is not
bluetooth_t->init_t(systemd), butbluetooth_t->init_t(obexd running in the wrong domain).
Quoted 7 lines
Quoted 4 lines
The root cause is that obex.te currently uses
userdom_user_application_domain(), which does not create a domain transition frominit_t. obexd therefore inherits systemd's domain instead of transitioning toobex_t.Thanks for working that out. It would be acceptable to add this in refpolicy, but I think it should be tunable. It's not a common case configuration.
Thanks for the feedback. I will consider your suggestion and send a v2 patch series shortly.
Quoted 1 line
Signature · 2 lines
Best Regards, Wei Deng
PATCH v2 1/1 obex: transfer obexd to obex_t
In reply to Wei Dengobexd was running under init_t instead of obex_t because obex.te only declared userdom_user_application_domain(), which does not set up a domain transition from init_t. Add init_daemon_domain() so that obexd exec'd by init/systemd correctly transitions to obex_t.
Also add the permissions observed to be required when obexd runs as obex_t: read sysfs nodes (dev_read_sysfs), register on the D-Bus system bus (dbus_connect_system_bus), and get attributes of bluetooth var-lib directories via the new bluetooth_getattr_var_lib_dirs() interface.
Fixes:
avc: denied { read } for pid=1751 comm="obexd" name="enabled" dev="sysfs" ino=21530 scontext=system_u:system_r:obex_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=file permissive=0
avc: denied { acquire_svc } for service=org.bluez.obex spid=1755 scontext=system_u:system_r:obex_t:s0 tcontext=system_u:system_r:system_dbusd_t:s0 tclass=dbus permissive=0 exe="/usr/bin/dbus-daemon" sauid=998 hostname=? addr=? terminal=?
avc: denied { getattr } for pid=1826 comm="obexd" path="/var/lib/bluetooth" dev="sda2" ino=1038914 scontext=system_u:system_r:obex_t:s0 tcontext=system_u:object_r:bluetooth_var_lib_t:s0 tclass=dir permissive=0
---
Changes in v2:
- Complete rework: investigation showed the AVC denial was not bluetooth_t -> init_t (systemd), but bluetooth_t -> init_t (obexd running in the wrong domain because obex.te lacked a domain transition from init_t). The v1 fix of adding init_dbus_chat() to bluetooth.te was therefore incorrect.
- Fix the root cause by adding init_daemon_domain() to obex.te so obexd correctly transitions to obex_t when started by init/systemd.
- Add permissions needed by obexd once it runs as obex_t: dev_read_sysfs, dbus_connect_system_bus, and bluetooth_getattr_var_lib_dirs (new interface in bluetooth.if).
policy/modules/services/bluetooth.if | 19 +++++++++++++++++++ policy/modules/services/obex.te | 5 +++++ 2 files changed, 24 insertions(+)
policy/modules/services/bluetooth.if +19 -0
@@ -255,6 +255,25 @@ interface(`bluetooth_admin',` admin_pattern($1, bluetooth_runtime_t) ') +######################################## +## <summary> +## Get the attributes of bluetooth lib directories. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`bluetooth_getattr_var_lib_dirs',` + gen_require(` + type bluetooth_var_lib_t; + ') + + allow $1 bluetooth_var_lib_t:dir getattr_dir_perms; + files_search_var_lib($1) +') + ######################################## ## <summary> ## Get status of bluetooth_unit_t service
policy/modules/services/obex.te +5 -0
@@ -9,6 +9,7 @@ attribute_role obex_roles; type obex_t; type obex_exec_t; +init_daemon_domain(obex_t, obex_exec_t) userdom_user_application_domain(obex_t, obex_exec_t) role obex_roles types obex_t;
@@ -20,6 +21,8 @@ role obex_roles types obex_t; allow obex_t self:fifo_file rw_fifo_file_perms; allow obex_t self:socket create_stream_socket_perms; +dev_read_sysfs(obex_t) + dev_read_urand(obex_t) files_read_etc_files(obex_t)
@@ -32,10 +35,12 @@ userdom_search_user_home_content(obex_t) optional_policy(` bluetooth_use(obex_t) + bluetooth_getattr_var_lib_dirs(obex_t) ') optional_policy(` dbus_system_bus_client(obex_t) + dbus_connect_system_bus(obex_t) optional_policy(` bluetooth_dbus_chat(obex_t)
Signature · 1 line
2.34.1
Re: [PATCH v2] obex: transfer obexd to obex_t
Hi Chris,
Friendly ping on v2. In your earlier feedback you suggested making the obexd daemon transition tunable. In v2 I kept userdom_user_application_domain() alongside init_daemon_domain(), so the existing user-space path remains intact and the daemon domain transition is purely additive. Would this approach be acceptable?
Thank you for your time.
Quoted 102 lines
obexd was running under
init_tinstead ofobex_tbecause obex.te only declareduserdom_user_application_domain(), which does not set up a domain transition frominit_t. Addinit_daemon_domain()so that obexd exec'd by init/systemd correctly transitions toobex_t.Also add the permissions observed to be required when obexd runs as
obex_t: read sysfs nodes (dev_read_sysfs), register on the D-Bus system bus (dbus_connect_system_bus), and get attributes of bluetooth var-lib directories via the newbluetooth_getattr_var_lib_dirs()interface.Fixes:
avc: denied { read } for pid=1751 comm="obexd" name="enabled" dev="sysfs" ino=21530 scontext=system_u:system_r:obex_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=file permissive=0avc: denied {
acquire_svc} for service=org.bluez.obex spid=1755 scontext=system_u:system_r:obex_t:s0 tcontext=system_u:system_r:system_dbusd_t:s0 tclass=dbus permissive=0 exe="/usr/bin/dbus-daemon" sauid=998 hostname=? addr=? terminal=?avc: denied { getattr } for pid=1826 comm="obexd" path="/var/lib/bluetooth" dev="sda2" ino=1038914 scontext=system_u:system_r:obex_t:s0 tcontext=system_u:object_r:bluetooth_var_lib_t:s0 tclass=dir permissive=0
Signed-off-by Wei Deng <[email protected]>---
Changes in v2:
- Complete rework: investigation showed the AVC denial was notbluetooth_t->init_t(systemd), butbluetooth_t->init_t(obexd running in the wrong domain because obex.te lacked a domain transition frominit_t). The v1 fix of addinginit_dbus_chat()to bluetooth.te was therefore incorrect.
- Fix the root cause by addinginit_daemon_domain()to obex.te so obexd correctly transitions toobex_twhen started by init/systemd.
- Add permissions needed by obexd once it runs asobex_t:dev_read_sysfs,dbus_connect_system_bus, andbluetooth_getattr_var_lib_dirs(new interface in bluetooth.if).policy/modules/services/bluetooth.if | 19 +++++++++++++++++++ policy/modules/services/obex.te | 5 +++++ 2 files changed, 24 insertions(+)policy/modules/services/bluetooth.if +19
-0@@ -255,6 +255,25 @@ interface(`bluetooth_admin',` admin_pattern($1, bluetooth_runtime_t) ') +######################################## +## <summary> +## Get the attributes of bluetooth lib directories. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`bluetooth_getattr_var_lib_dirs',` + gen_require(` + type bluetooth_var_lib_t; + ') + + allow $1 bluetooth_var_lib_t:dir getattr_dir_perms; + files_search_var_lib($1) +') + ######################################## ## <summary> ## Get status of bluetooth_unit_t servicepolicy/modules/services/obex.te +5
-0@@ -9,6 +9,7 @@ attribute_role obex_roles; type obex_t; type obex_exec_t; +init_daemon_domain(obex_t, obex_exec_t) userdom_user_application_domain(obex_t, obex_exec_t) role obex_roles types obex_t;@@ -20,6 +21,8 @@ role obex_roles types obex_t; allow obex_t self:fifo_file rw_fifo_file_perms; allow obex_t self:socket create_stream_socket_perms; +dev_read_sysfs(obex_t) + dev_read_urand(obex_t) files_read_etc_files(obex_t)@@ -32,10 +35,12 @@ userdom_search_user_home_content(obex_t) optional_policy(` bluetooth_use(obex_t) + bluetooth_getattr_var_lib_dirs(obex_t) ') optional_policy(` dbus_system_bus_client(obex_t) + dbus_connect_system_bus(obex_t) optional_policy(` bluetooth_dbus_chat(obex_t)Signature · 1 line
2.34.1
Signature · 2 lines
Best Regards, Wei Deng
Re: [PATCH v2] obex: transfer obexd to obex_t
In reply to Wei DengQuoted 71 lines · Wei Deng
obexd was running under
init_tinstead ofobex_tbecause obex.te only declareduserdom_user_application_domain(), which does not set up a domain transition frominit_t. Addinit_daemon_domain()so that obexd exec'd by init/systemd correctly transitions toobex_t.Also add the permissions observed to be required when obexd runs as
obex_t: read sysfs nodes (dev_read_sysfs), register on the D-Bus system bus (dbus_connect_system_bus), and get attributes of bluetooth var-lib directories via the newbluetooth_getattr_var_lib_dirs()interface.Fixes:
avc: denied { read } for pid=1751 comm="obexd" name="enabled" dev="sysfs" ino=21530 scontext=system_u:system_r:obex_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=file permissive=0avc: denied {
acquire_svc} for service=org.bluez.obex spid=1755 scontext=system_u:system_r:obex_t:s0 tcontext=system_u:system_r:system_dbusd_t:s0 tclass=dbus permissive=0 exe="/usr/bin/dbus-daemon" sauid=998 hostname=? addr=? terminal=?avc: denied { getattr } for pid=1826 comm="obexd" path="/var/lib/bluetooth" dev="sda2" ino=1038914 scontext=system_u:system_r:obex_t:s0 tcontext=system_u:object_r:bluetooth_var_lib_t:s0 tclass=dir permissive=0
Signed-off-by Wei Deng <[email protected]>---
Changes in v2:
- Complete rework: investigation showed the AVC denial was notbluetooth_t->init_t(systemd), butbluetooth_t->init_t(obexd running in the wrong domain because obex.te lacked a domain transition frominit_t). The v1 fix of addinginit_dbus_chat()to bluetooth.te was therefore incorrect.
- Fix the root cause by addinginit_daemon_domain()to obex.te so obexd correctly transitions toobex_twhen started by init/systemd.
- Add permissions needed by obexd once it runs asobex_t:dev_read_sysfs,dbus_connect_system_bus, andbluetooth_getattr_var_lib_dirs(new interface in bluetooth.if).policy/modules/services/bluetooth.if | 19 +++++++++++++++++++ policy/modules/services/obex.te | 5 +++++ 2 files changed, 24 insertions(+)policy/modules/services/bluetooth.if +19
-0@@ -255,6 +255,25 @@ interface(`bluetooth_admin',` admin_pattern($1, bluetooth_runtime_t) ') +######################################## +## <summary> +## Get the attributes of bluetooth lib directories. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`bluetooth_getattr_var_lib_dirs',` + gen_require(` + type bluetooth_var_lib_t; + ') + + allow $1 bluetooth_var_lib_t:dir getattr_dir_perms; + files_search_var_lib($1) +') + ######################################## ## <summary> ## Get status of bluetooth_unit_t servicepolicy/modules/services/obex.te +0
-0
policy/modules/services/obex.te attribute_role obex_roles; · line 12
Quoted 4 lines
policy/modules/services/obex.te +1
-0@@ -9,6 +9,7 @@ attribute_role obex_roles; type obex_t; type obex_exec_t; +init_daemon_domain(obex_t, obex_exec_t)
Please make this tunable, since it is not the common case.
policy/modules/services/obex.te role obex_roles types obex_t; · line 25
Quoted 9 lines
policy/modules/services/obex.te +2
-0userdom_user_application_domain(obex_t, obex_exec_t) role obex_roles types obex_t;@@ -20,6 +21,8 @@ role obex_roles types obex_t; allow obex_t self:fifo_file rw_fifo_file_perms; allow obex_t self:socket create_stream_socket_perms; +dev_read_sysfs(obex_t) +
Please remove the extra blank line.
Quoted 16 lines
policy/modules/services/obex.te +2
-0dev_read_urand(obex_t) files_read_etc_files(obex_t)@@ -32,10 +35,12 @@ userdom_search_user_home_content(obex_t) optional_policy(` bluetooth_use(obex_t) + bluetooth_getattr_var_lib_dirs(obex_t) ') optional_policy(` dbus_system_bus_client(obex_t) + dbus_connect_system_bus(obex_t) optional_policy(` bluetooth_dbus_chat(obex_t)
Signature · 1 line
Chris PeBenito
Re: [PATCH v2] obex: transfer obexd to obex_t
Hi Chris,
Quoted 73 lines · Christopher J. PeBenito
Quoted 72 lines · Wei Deng
obexd was running under
init_tinstead ofobex_tbecause obex.te only declareduserdom_user_application_domain(), which does not set up a domain transition frominit_t. Addinit_daemon_domain()so that obexd exec'd by init/systemd correctly transitions toobex_t.Also add the permissions observed to be required when obexd runs as
obex_t: read sysfs nodes (dev_read_sysfs), register on the D-Bus system bus (dbus_connect_system_bus), and get attributes of bluetooth var-lib directories via the newbluetooth_getattr_var_lib_dirs()interface.Fixes:
avc: denied { read } for pid=1751 comm="obexd" name="enabled" dev="sysfs" ino=21530 scontext=system_u:system_r:obex_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=file permissive=0avc: denied {
acquire_svc} for service=org.bluez.obex spid=1755 scontext=system_u:system_r:obex_t:s0 tcontext=system_u:system_r:system_dbusd_t:s0 tclass=dbus permissive=0 exe="/usr/bin/dbus-daemon" sauid=998 hostname=? addr=? terminal=?avc: denied { getattr } for pid=1826 comm="obexd" path="/var/lib/bluetooth" dev="sda2" ino=1038914 scontext=system_u:system_r:obex_t:s0 tcontext=system_u:object_r:bluetooth_var_lib_t:s0 tclass=dir permissive=0
Signed-off-by Wei Deng <[email protected]>---
Changes in v2:
- Complete rework: investigation showed the AVC denial was notbluetooth_t->init_t(systemd), butbluetooth_t->init_t(obexd running in the wrong domain because obex.te lacked a domain transition frominit_t). The v1 fix of addinginit_dbus_chat()to bluetooth.te was therefore incorrect.
- Fix the root cause by addinginit_daemon_domain()to obex.te so obexd correctly transitions toobex_twhen started by init/systemd.
- Add permissions needed by obexd once it runs asobex_t:dev_read_sysfs,dbus_connect_system_bus, andbluetooth_getattr_var_lib_dirs(new interface in bluetooth.if).policy/modules/services/bluetooth.if | 19 +++++++++++++++++++ policy/modules/services/obex.te | 5 +++++ 2 files changed, 24 insertions(+)policy/modules/services/bluetooth.if +19
-0@@ -255,6 +255,25 @@ interface(`bluetooth_admin',` admin_pattern($1, bluetooth_runtime_t) ') +######################################## +## <summary> +## Get the attributes of bluetooth lib directories. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`bluetooth_getattr_var_lib_dirs',` + gen_require(` + type bluetooth_var_lib_t; + ') + + allow $1 bluetooth_var_lib_t:dir getattr_dir_perms; + files_search_var_lib($1) +') + ######################################## ## <summary> ## Get status of bluetooth_unit_t servicepolicy/modules/services/obex.te +0
-0@@ -9,6 +9,7 @@ attribute_role obex_roles;
Quoted 5 lines
policy/modules/services/obex.te attribute_role obex_roles; · line 12
Quoted 3 lines
policy/modules/services/obex.te +1
-0type obex_t; type obex_exec_t; +init_daemon_domain(obex_t, obex_exec_t)Please make this tunable, since it is not the common case.
Thank you for the review. I have a question about the tunable approach before sending v3.
init_daemon_domain() expands to typeattribute and role statements, which are not legal inside a tunable_policy block — so wrapping it directly would cause a compile error.
Do you have a recommended pattern for this case? Happy to follow whatever approach you think fits best.
Quoted 4 lines
Quoted 4 lines
policy/modules/services/obex.te +0
-0userdom_user_application_domain(obex_t, obex_exec_t) role obex_roles types obex_t;
Quoted 8 lines
policy/modules/services/obex.te role obex_roles types obex_t; · line 25
Quoted 6 lines
policy/modules/services/obex.te +2
-0@@ -20,6 +21,8 @@ role obex_roles types obex_t; allow obex_t self:fifo_file rw_fifo_file_perms; allow obex_t self:socket create_stream_socket_perms; +dev_read_sysfs(obex_t) +Please remove the extra blank line.
Noted, will fix in v3.
Quoted 19 lines
Quoted 16 lines
policy/modules/services/obex.te +2
-0dev_read_urand(obex_t) files_read_etc_files(obex_t)@@ -32,10 +35,12 @@ userdom_search_user_home_content(obex_t) optional_policy(` bluetooth_use(obex_t) + bluetooth_getattr_var_lib_dirs(obex_t) ') optional_policy(` dbus_system_bus_client(obex_t) + dbus_connect_system_bus(obex_t) optional_policy(` bluetooth_dbus_chat(obex_t)Signature · 1 line
Chris PeBenito
Signature · 2 lines
Best Regards, Wei Deng