selinux-refpolicy.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Introduce allow_bluetooth boolean
@ 2019-04-30 17:53 Lukas Vrabec
  2019-04-30 23:37 ` Chris PeBenito
  0 siblings, 1 reply; 7+ messages in thread
From: Lukas Vrabec @ 2019-04-30 17:53 UTC (permalink / raw)
  To: selinux-refpolicy; +Cc: Lukas Vrabec

Because of new bluetooth_socket which is part of extended_socket_class
policy capability, it's possible to control which SELinux domains can
use bluetooth wireless technology. Default value of the boolean is
turned off.

Signed-off-by: Lukas Vrabec <lvrabec@redhat.com>
---
 policy/global_tunables               | 7 +++++++
 policy/modules/admin/netutils.te     | 4 ++++
 policy/modules/services/arpwatch.te  | 4 ++++
 policy/modules/services/bluetooth.if | 4 ++++
 policy/modules/services/bluetooth.te | 4 ++++
 policy/modules/services/ntop.te      | 4 ++++
 policy/modules/system/userdomain.if  | 8 ++++++++
 7 files changed, 35 insertions(+)

diff --git a/policy/global_tunables b/policy/global_tunables
index affc020f..69b356e2 100644
--- a/policy/global_tunables
+++ b/policy/global_tunables
@@ -4,6 +4,13 @@
 # file should be used.
 #
 
+## <desc>
+## <p>
+## Allow all system processes and Linux users to use bluetooth wireless technology.
+## </p>
+## </desc>
+gen_tunable(allow_bluetooth,false)
+
 ## <desc>
 ## <p>
 ## Allow unconfined executables to make their heap memory executable.  Doing this is a really bad idea. Probably indicates a badly coded executable, but could indicate an attack. This executable should be reported in bugzilla
diff --git a/policy/modules/admin/netutils.te b/policy/modules/admin/netutils.te
index 46560a09..8821b108 100644
--- a/policy/modules/admin/netutils.te
+++ b/policy/modules/admin/netutils.te
@@ -99,6 +99,10 @@ optional_policy(`
 	xen_append_log(netutils_t)
 ')
 
+tunable_policy(`allow_bluetooth',`
+		allow netutils_t self:bluetooth_socket create_stream_socket_perms;
+')
+
 ########################################
 #
 # Ping local policy
diff --git a/policy/modules/services/arpwatch.te b/policy/modules/services/arpwatch.te
index 87aed96f..6f05441a 100644
--- a/policy/modules/services/arpwatch.te
+++ b/policy/modules/services/arpwatch.te
@@ -77,6 +77,10 @@ miscfiles_read_localization(arpwatch_t)
 userdom_dontaudit_search_user_home_dirs(arpwatch_t)
 userdom_dontaudit_use_unpriv_user_fds(arpwatch_t)
 
+tunable_policy(`allow_bluetooth',`
+	allow arpwatch_t self:bluetooth_socket create_socket_perms;
+')
+
 optional_policy(`
 	mta_send_mail(arpwatch_t)
 ')
diff --git a/policy/modules/services/bluetooth.if b/policy/modules/services/bluetooth.if
index dc61988c..9097803f 100644
--- a/policy/modules/services/bluetooth.if
+++ b/policy/modules/services/bluetooth.if
@@ -68,6 +68,10 @@ interface(`bluetooth_stream_connect',`
 	files_search_pids($1)
 	allow $1 bluetooth_t:socket rw_socket_perms;
 	stream_connect_pattern($1, bluetooth_var_run_t, bluetooth_var_run_t, bluetooth_t)
+
+	tunable_policy(`deny_bluetooth',`',`
+		allow $1 bluetooth_t:bluetooth_socket rw_socket_perms;
+	')
 ')
 
 ########################################
diff --git a/policy/modules/services/bluetooth.te b/policy/modules/services/bluetooth.te
index 45e5a361..39af72d5 100644
--- a/policy/modules/services/bluetooth.te
+++ b/policy/modules/services/bluetooth.te
@@ -133,6 +133,10 @@ userdom_dontaudit_use_unpriv_user_fds(bluetooth_t)
 userdom_dontaudit_use_user_terminals(bluetooth_t)
 userdom_dontaudit_search_user_home_dirs(bluetooth_t)
 
+tunable_policy(`allow_bluetooth',`
+	allow bluetooth_t self:bluetooth_socket create_stream_socket_perms;
+')
+
 optional_policy(`
 	dbus_system_bus_client(bluetooth_t)
 	dbus_connect_system_bus(bluetooth_t)
diff --git a/policy/modules/services/ntop.te b/policy/modules/services/ntop.te
index 178bbb1d..537d9323 100644
--- a/policy/modules/services/ntop.te
+++ b/policy/modules/services/ntop.te
@@ -96,6 +96,10 @@ miscfiles_read_localization(ntop_t)
 userdom_dontaudit_use_unpriv_user_fds(ntop_t)
 userdom_dontaudit_search_user_home_dirs(ntop_t)
 
+tunable_policy(`allow_bluetooth',`
+	allow ntop_t self:bluetooth_socket create_socket_perms;
+')
+
 optional_policy(`
 	apache_read_sys_content(ntop_t)
 ')
diff --git a/policy/modules/system/userdomain.if b/policy/modules/system/userdomain.if
index 5221bd13..5654de6e 100644
--- a/policy/modules/system/userdomain.if
+++ b/policy/modules/system/userdomain.if
@@ -1189,6 +1189,10 @@ template(`userdom_unpriv_user_template', `
 		corenet_udp_bind_generic_port($1_t)
 	')
 
+	tunable_policy(`allow_bluetooth',`
+		allow $1_t self:bluetooth_socket create_socket_perms;
+	')
+
 	optional_policy(`
 		netutils_run_ping_cond($1_t, $1_r)
 		netutils_run_traceroute_cond($1_t, $1_r)
@@ -1362,6 +1366,10 @@ template(`userdom_admin_user_template',`
 	userdom_manage_user_home_content_sockets($1_t)
 	userdom_user_home_dir_filetrans_user_home_content($1_t, { dir file lnk_file fifo_file sock_file })
 
+	tunable_policy(`allow_bluetooth',`
+		allow $1_t self:bluetooth_socket create_stream_socket_perms;
+	')
+
 	optional_policy(`
 		postgresql_unconfined($1_t)
 	')
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] Introduce allow_bluetooth boolean
  2019-04-30 17:53 [PATCH] Introduce allow_bluetooth boolean Lukas Vrabec
@ 2019-04-30 23:37 ` Chris PeBenito
  2019-05-04 10:26   ` Lukas Vrabec
  0 siblings, 1 reply; 7+ messages in thread
From: Chris PeBenito @ 2019-04-30 23:37 UTC (permalink / raw)
  To: Lukas Vrabec, selinux-refpolicy

On 4/30/19 1:53 PM, Lukas Vrabec wrote:
> Because of new bluetooth_socket which is part of extended_socket_class
> policy capability, it's possible to control which SELinux domains can
> use bluetooth wireless technology. Default value of the boolean is
> turned off.
> 
> Signed-off-by: Lukas Vrabec <lvrabec@redhat.com>
> ---
>   policy/global_tunables               | 7 +++++++
>   policy/modules/admin/netutils.te     | 4 ++++
>   policy/modules/services/arpwatch.te  | 4 ++++
>   policy/modules/services/bluetooth.if | 4 ++++
>   policy/modules/services/bluetooth.te | 4 ++++
>   policy/modules/services/ntop.te      | 4 ++++
>   policy/modules/system/userdomain.if  | 8 ++++++++
>   7 files changed, 35 insertions(+)
> 
> diff --git a/policy/global_tunables b/policy/global_tunables
> index affc020f..69b356e2 100644
> --- a/policy/global_tunables
> +++ b/policy/global_tunables
> @@ -4,6 +4,13 @@
>   # file should be used.
>   #
>   
> +## <desc>
> +## <p>
> +## Allow all system processes and Linux users to use bluetooth wireless technology.
> +## </p>
> +## </desc>
> +gen_tunable(allow_bluetooth,false)
> +
>   ## <desc>
>   ## <p>
>   ## Allow unconfined executables to make their heap memory executable.  Doing this is a really bad idea. Probably indicates a badly coded executable, but could indicate an attack. This executable should be reported in bugzilla
> diff --git a/policy/modules/admin/netutils.te b/policy/modules/admin/netutils.te
> index 46560a09..8821b108 100644
> --- a/policy/modules/admin/netutils.te
> +++ b/policy/modules/admin/netutils.te
> @@ -99,6 +99,10 @@ optional_policy(`
>   	xen_append_log(netutils_t)
>   ')
>   
> +tunable_policy(`allow_bluetooth',`
> +		allow netutils_t self:bluetooth_socket create_stream_socket_perms;
> +')
> +
>   ########################################
>   #
>   # Ping local policy
> diff --git a/policy/modules/services/arpwatch.te b/policy/modules/services/arpwatch.te
> index 87aed96f..6f05441a 100644
> --- a/policy/modules/services/arpwatch.te
> +++ b/policy/modules/services/arpwatch.te
> @@ -77,6 +77,10 @@ miscfiles_read_localization(arpwatch_t)
>   userdom_dontaudit_search_user_home_dirs(arpwatch_t)
>   userdom_dontaudit_use_unpriv_user_fds(arpwatch_t)
>   
> +tunable_policy(`allow_bluetooth',`
> +	allow arpwatch_t self:bluetooth_socket create_socket_perms;
> +')
> +
>   optional_policy(`
>   	mta_send_mail(arpwatch_t)
>   ')
> diff --git a/policy/modules/services/bluetooth.if b/policy/modules/services/bluetooth.if
> index dc61988c..9097803f 100644
> --- a/policy/modules/services/bluetooth.if
> +++ b/policy/modules/services/bluetooth.if
> @@ -68,6 +68,10 @@ interface(`bluetooth_stream_connect',`
>   	files_search_pids($1)
>   	allow $1 bluetooth_t:socket rw_socket_perms;
>   	stream_connect_pattern($1, bluetooth_var_run_t, bluetooth_var_run_t, bluetooth_t)
> +
> +	tunable_policy(`deny_bluetooth',`',`

Missed a deny_bluetooth.

I'm also a little uneasy with adding this access here, as this would 
seem to be a side effect to a simple stream socket connection.  Perhaps 
there should be a new interface like bluetooth_client().  It might also 
make sense in bluetooth_role(), as there is a generic socket class rule 
in there too.



> +		allow $1 bluetooth_t:bluetooth_socket rw_socket_perms;
> +	')
>   ')
>   
>   ########################################
> diff --git a/policy/modules/services/bluetooth.te b/policy/modules/services/bluetooth.te
> index 45e5a361..39af72d5 100644
> --- a/policy/modules/services/bluetooth.te
> +++ b/policy/modules/services/bluetooth.te
> @@ -133,6 +133,10 @@ userdom_dontaudit_use_unpriv_user_fds(bluetooth_t)
>   userdom_dontaudit_use_user_terminals(bluetooth_t)
>   userdom_dontaudit_search_user_home_dirs(bluetooth_t)
>   
> +tunable_policy(`allow_bluetooth',`
> +	allow bluetooth_t self:bluetooth_socket create_stream_socket_perms;
> +')
> +
>   optional_policy(`
>   	dbus_system_bus_client(bluetooth_t)
>   	dbus_connect_system_bus(bluetooth_t)
> diff --git a/policy/modules/services/ntop.te b/policy/modules/services/ntop.te
> index 178bbb1d..537d9323 100644
> --- a/policy/modules/services/ntop.te
> +++ b/policy/modules/services/ntop.te
> @@ -96,6 +96,10 @@ miscfiles_read_localization(ntop_t)
>   userdom_dontaudit_use_unpriv_user_fds(ntop_t)
>   userdom_dontaudit_search_user_home_dirs(ntop_t)
>   
> +tunable_policy(`allow_bluetooth',`
> +	allow ntop_t self:bluetooth_socket create_socket_perms;
> +')
> +
>   optional_policy(`
>   	apache_read_sys_content(ntop_t)
>   ')
> diff --git a/policy/modules/system/userdomain.if b/policy/modules/system/userdomain.if
> index 5221bd13..5654de6e 100644
> --- a/policy/modules/system/userdomain.if
> +++ b/policy/modules/system/userdomain.if
> @@ -1189,6 +1189,10 @@ template(`userdom_unpriv_user_template', `
>   		corenet_udp_bind_generic_port($1_t)
>   	')
>   
> +	tunable_policy(`allow_bluetooth',`
> +		allow $1_t self:bluetooth_socket create_socket_perms;
> +	')
> +
>   	optional_policy(`
>   		netutils_run_ping_cond($1_t, $1_r)
>   		netutils_run_traceroute_cond($1_t, $1_r)
> @@ -1362,6 +1366,10 @@ template(`userdom_admin_user_template',`
>   	userdom_manage_user_home_content_sockets($1_t)
>   	userdom_user_home_dir_filetrans_user_home_content($1_t, { dir file lnk_file fifo_file sock_file })
>   
> +	tunable_policy(`allow_bluetooth',`
> +		allow $1_t self:bluetooth_socket create_stream_socket_perms;
> +	')
> +
>   	optional_policy(`
>   		postgresql_unconfined($1_t)
>   	')
> 


-- 
Chris PeBenito

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Introduce allow_bluetooth boolean
  2019-04-30 23:37 ` Chris PeBenito
@ 2019-05-04 10:26   ` Lukas Vrabec
  2019-05-06  0:36     ` Chris PeBenito
  0 siblings, 1 reply; 7+ messages in thread
From: Lukas Vrabec @ 2019-05-04 10:26 UTC (permalink / raw)
  To: Chris PeBenito, selinux-refpolicy


[-- Attachment #1.1: Type: text/plain, Size: 6681 bytes --]

On 5/1/19 1:37 AM, Chris PeBenito wrote:
> On 4/30/19 1:53 PM, Lukas Vrabec wrote:
>> Because of new bluetooth_socket which is part of extended_socket_class
>> policy capability, it's possible to control which SELinux domains can
>> use bluetooth wireless technology. Default value of the boolean is
>> turned off.
>>
>> Signed-off-by: Lukas Vrabec <lvrabec@redhat.com>
>> ---
>>   policy/global_tunables               | 7 +++++++
>>   policy/modules/admin/netutils.te     | 4 ++++
>>   policy/modules/services/arpwatch.te  | 4 ++++
>>   policy/modules/services/bluetooth.if | 4 ++++
>>   policy/modules/services/bluetooth.te | 4 ++++
>>   policy/modules/services/ntop.te      | 4 ++++
>>   policy/modules/system/userdomain.if  | 8 ++++++++
>>   7 files changed, 35 insertions(+)
>>
>> diff --git a/policy/global_tunables b/policy/global_tunables
>> index affc020f..69b356e2 100644
>> --- a/policy/global_tunables
>> +++ b/policy/global_tunables
>> @@ -4,6 +4,13 @@
>>   # file should be used.
>>   #
>>   +## <desc>
>> +## <p>
>> +## Allow all system processes and Linux users to use bluetooth
>> wireless technology.
>> +## </p>
>> +## </desc>
>> +gen_tunable(allow_bluetooth,false)
>> +
>>   ## <desc>
>>   ## <p>
>>   ## Allow unconfined executables to make their heap memory
>> executable.  Doing this is a really bad idea. Probably indicates a
>> badly coded executable, but could indicate an attack. This executable
>> should be reported in bugzilla
>> diff --git a/policy/modules/admin/netutils.te
>> b/policy/modules/admin/netutils.te
>> index 46560a09..8821b108 100644
>> --- a/policy/modules/admin/netutils.te
>> +++ b/policy/modules/admin/netutils.te
>> @@ -99,6 +99,10 @@ optional_policy(`
>>       xen_append_log(netutils_t)
>>   ')
>>   +tunable_policy(`allow_bluetooth',`
>> +        allow netutils_t self:bluetooth_socket
>> create_stream_socket_perms;
>> +')
>> +
>>   ########################################
>>   #
>>   # Ping local policy
>> diff --git a/policy/modules/services/arpwatch.te
>> b/policy/modules/services/arpwatch.te
>> index 87aed96f..6f05441a 100644
>> --- a/policy/modules/services/arpwatch.te
>> +++ b/policy/modules/services/arpwatch.te
>> @@ -77,6 +77,10 @@ miscfiles_read_localization(arpwatch_t)
>>   userdom_dontaudit_search_user_home_dirs(arpwatch_t)
>>   userdom_dontaudit_use_unpriv_user_fds(arpwatch_t)
>>   +tunable_policy(`allow_bluetooth',`
>> +    allow arpwatch_t self:bluetooth_socket create_socket_perms;
>> +')
>> +
>>   optional_policy(`
>>       mta_send_mail(arpwatch_t)
>>   ')
>> diff --git a/policy/modules/services/bluetooth.if
>> b/policy/modules/services/bluetooth.if
>> index dc61988c..9097803f 100644
>> --- a/policy/modules/services/bluetooth.if
>> +++ b/policy/modules/services/bluetooth.if
>> @@ -68,6 +68,10 @@ interface(`bluetooth_stream_connect',`
>>       files_search_pids($1)
>>       allow $1 bluetooth_t:socket rw_socket_perms;
>>       stream_connect_pattern($1, bluetooth_var_run_t,
>> bluetooth_var_run_t, bluetooth_t)
>> +
>> +    tunable_policy(`deny_bluetooth',`',`
> 
> Missed a deny_bluetooth.
> 
> I'm also a little uneasy with adding this access here, as this would
> seem to be a side effect to a simple stream socket connection.  Perhaps
> there should be a new interface like bluetooth_client().  It might also
> make sense in bluetooth_role(), as there is a generic socket class rule
> in there too.
> 

Hi Chris,

I'll update deny_bluetooth() to allow_bluetooth().

So, you're suggesting create new interface bluetooth_client() but all
bluetooth related stuff there, and use this interface in tunable_policy
block instead of just allowing using bluetooth socket?

bluetooth_role() should be fixed to use only bluetooth_socket, not the
general one. I'll create PR also for it.

Thanks,
Lukas.

> 
> 
>> +        allow $1 bluetooth_t:bluetooth_socket rw_socket_perms;
>> +    ')
>>   ')
>>     ########################################
>> diff --git a/policy/modules/services/bluetooth.te
>> b/policy/modules/services/bluetooth.te
>> index 45e5a361..39af72d5 100644
>> --- a/policy/modules/services/bluetooth.te
>> +++ b/policy/modules/services/bluetooth.te
>> @@ -133,6 +133,10 @@ userdom_dontaudit_use_unpriv_user_fds(bluetooth_t)
>>   userdom_dontaudit_use_user_terminals(bluetooth_t)
>>   userdom_dontaudit_search_user_home_dirs(bluetooth_t)
>>   +tunable_policy(`allow_bluetooth',`
>> +    allow bluetooth_t self:bluetooth_socket create_stream_socket_perms;
>> +')
>> +
>>   optional_policy(`
>>       dbus_system_bus_client(bluetooth_t)
>>       dbus_connect_system_bus(bluetooth_t)
>> diff --git a/policy/modules/services/ntop.te
>> b/policy/modules/services/ntop.te
>> index 178bbb1d..537d9323 100644
>> --- a/policy/modules/services/ntop.te
>> +++ b/policy/modules/services/ntop.te
>> @@ -96,6 +96,10 @@ miscfiles_read_localization(ntop_t)
>>   userdom_dontaudit_use_unpriv_user_fds(ntop_t)
>>   userdom_dontaudit_search_user_home_dirs(ntop_t)
>>   +tunable_policy(`allow_bluetooth',`
>> +    allow ntop_t self:bluetooth_socket create_socket_perms;
>> +')
>> +
>>   optional_policy(`
>>       apache_read_sys_content(ntop_t)
>>   ')
>> diff --git a/policy/modules/system/userdomain.if
>> b/policy/modules/system/userdomain.if
>> index 5221bd13..5654de6e 100644
>> --- a/policy/modules/system/userdomain.if
>> +++ b/policy/modules/system/userdomain.if
>> @@ -1189,6 +1189,10 @@ template(`userdom_unpriv_user_template', `
>>           corenet_udp_bind_generic_port($1_t)
>>       ')
>>   +    tunable_policy(`allow_bluetooth',`
>> +        allow $1_t self:bluetooth_socket create_socket_perms;
>> +    ')
>> +
>>       optional_policy(`
>>           netutils_run_ping_cond($1_t, $1_r)
>>           netutils_run_traceroute_cond($1_t, $1_r)
>> @@ -1362,6 +1366,10 @@ template(`userdom_admin_user_template',`
>>       userdom_manage_user_home_content_sockets($1_t)
>>       userdom_user_home_dir_filetrans_user_home_content($1_t, { dir
>> file lnk_file fifo_file sock_file })
>>   +    tunable_policy(`allow_bluetooth',`
>> +        allow $1_t self:bluetooth_socket create_stream_socket_perms;
>> +    ')
>> +
>>       optional_policy(`
>>           postgresql_unconfined($1_t)
>>       ')
>>
> 
> 


-- 
Lukas Vrabec
Senior Software Engineer, Security Technologies
Red Hat, Inc.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Introduce allow_bluetooth boolean
  2019-05-04 10:26   ` Lukas Vrabec
@ 2019-05-06  0:36     ` Chris PeBenito
  0 siblings, 0 replies; 7+ messages in thread
From: Chris PeBenito @ 2019-05-06  0:36 UTC (permalink / raw)
  To: Lukas Vrabec, selinux-refpolicy

On 5/4/19 6:26 AM, Lukas Vrabec wrote:
> On 5/1/19 1:37 AM, Chris PeBenito wrote:
>> On 4/30/19 1:53 PM, Lukas Vrabec wrote:
>>> Because of new bluetooth_socket which is part of extended_socket_class
>>> policy capability, it's possible to control which SELinux domains can
>>> use bluetooth wireless technology. Default value of the boolean is
>>> turned off.
>>>
>>> Signed-off-by: Lukas Vrabec <lvrabec@redhat.com>
>>> ---
>>>    policy/global_tunables               | 7 +++++++
>>>    policy/modules/admin/netutils.te     | 4 ++++
>>>    policy/modules/services/arpwatch.te  | 4 ++++
>>>    policy/modules/services/bluetooth.if | 4 ++++
>>>    policy/modules/services/bluetooth.te | 4 ++++
>>>    policy/modules/services/ntop.te      | 4 ++++
>>>    policy/modules/system/userdomain.if  | 8 ++++++++
>>>    7 files changed, 35 insertions(+)
>>>
>>> diff --git a/policy/global_tunables b/policy/global_tunables
>>> index affc020f..69b356e2 100644
>>> --- a/policy/global_tunables
>>> +++ b/policy/global_tunables
>>> @@ -4,6 +4,13 @@
>>>    # file should be used.
>>>    #
>>>    +## <desc>
>>> +## <p>
>>> +## Allow all system processes and Linux users to use bluetooth
>>> wireless technology.
>>> +## </p>
>>> +## </desc>
>>> +gen_tunable(allow_bluetooth,false)
>>> +
>>>    ## <desc>
>>>    ## <p>
>>>    ## Allow unconfined executables to make their heap memory
>>> executable.  Doing this is a really bad idea. Probably indicates a
>>> badly coded executable, but could indicate an attack. This executable
>>> should be reported in bugzilla
>>> diff --git a/policy/modules/admin/netutils.te
>>> b/policy/modules/admin/netutils.te
>>> index 46560a09..8821b108 100644
>>> --- a/policy/modules/admin/netutils.te
>>> +++ b/policy/modules/admin/netutils.te
>>> @@ -99,6 +99,10 @@ optional_policy(`
>>>        xen_append_log(netutils_t)
>>>    ')
>>>    +tunable_policy(`allow_bluetooth',`
>>> +        allow netutils_t self:bluetooth_socket
>>> create_stream_socket_perms;
>>> +')
>>> +
>>>    ########################################
>>>    #
>>>    # Ping local policy
>>> diff --git a/policy/modules/services/arpwatch.te
>>> b/policy/modules/services/arpwatch.te
>>> index 87aed96f..6f05441a 100644
>>> --- a/policy/modules/services/arpwatch.te
>>> +++ b/policy/modules/services/arpwatch.te
>>> @@ -77,6 +77,10 @@ miscfiles_read_localization(arpwatch_t)
>>>    userdom_dontaudit_search_user_home_dirs(arpwatch_t)
>>>    userdom_dontaudit_use_unpriv_user_fds(arpwatch_t)
>>>    +tunable_policy(`allow_bluetooth',`
>>> +    allow arpwatch_t self:bluetooth_socket create_socket_perms;
>>> +')
>>> +
>>>    optional_policy(`
>>>        mta_send_mail(arpwatch_t)
>>>    ')
>>> diff --git a/policy/modules/services/bluetooth.if
>>> b/policy/modules/services/bluetooth.if
>>> index dc61988c..9097803f 100644
>>> --- a/policy/modules/services/bluetooth.if
>>> +++ b/policy/modules/services/bluetooth.if
>>> @@ -68,6 +68,10 @@ interface(`bluetooth_stream_connect',`
>>>        files_search_pids($1)
>>>        allow $1 bluetooth_t:socket rw_socket_perms;
>>>        stream_connect_pattern($1, bluetooth_var_run_t,
>>> bluetooth_var_run_t, bluetooth_t)
>>> +
>>> +    tunable_policy(`deny_bluetooth',`',`
>>
>> Missed a deny_bluetooth.
>>
>> I'm also a little uneasy with adding this access here, as this would
>> seem to be a side effect to a simple stream socket connection.  Perhaps
>> there should be a new interface like bluetooth_client().  It might also
>> make sense in bluetooth_role(), as there is a generic socket class rule
>> in there too.
>>
> 
> Hi Chris,
> 
> I'll update deny_bluetooth() to allow_bluetooth().
> 
> So, you're suggesting create new interface bluetooth_client() but all
> bluetooth related stuff there, and use this interface in tunable_policy
> block instead of just allowing using bluetooth socket?

bluetooth_client() would have the rules of bluetooth_stream_connect() 
and then the allow_bluetooth conditional rule.  The stream socket 
connection can remain unconditional, if the bluetooth_socket access is 
sufficient to block bluetooth use.


> bluetooth_role() should be fixed to use only bluetooth_socket, not the
> general one. I'll create PR also for it.
> 
> Thanks,
> Lukas.
> 
>>
>>
>>> +        allow $1 bluetooth_t:bluetooth_socket rw_socket_perms;
>>> +    ')
>>>    ')
>>>      ########################################
>>> diff --git a/policy/modules/services/bluetooth.te
>>> b/policy/modules/services/bluetooth.te
>>> index 45e5a361..39af72d5 100644
>>> --- a/policy/modules/services/bluetooth.te
>>> +++ b/policy/modules/services/bluetooth.te
>>> @@ -133,6 +133,10 @@ userdom_dontaudit_use_unpriv_user_fds(bluetooth_t)
>>>    userdom_dontaudit_use_user_terminals(bluetooth_t)
>>>    userdom_dontaudit_search_user_home_dirs(bluetooth_t)
>>>    +tunable_policy(`allow_bluetooth',`
>>> +    allow bluetooth_t self:bluetooth_socket create_stream_socket_perms;
>>> +')
>>> +
>>>    optional_policy(`
>>>        dbus_system_bus_client(bluetooth_t)
>>>        dbus_connect_system_bus(bluetooth_t)
>>> diff --git a/policy/modules/services/ntop.te
>>> b/policy/modules/services/ntop.te
>>> index 178bbb1d..537d9323 100644
>>> --- a/policy/modules/services/ntop.te
>>> +++ b/policy/modules/services/ntop.te
>>> @@ -96,6 +96,10 @@ miscfiles_read_localization(ntop_t)
>>>    userdom_dontaudit_use_unpriv_user_fds(ntop_t)
>>>    userdom_dontaudit_search_user_home_dirs(ntop_t)
>>>    +tunable_policy(`allow_bluetooth',`
>>> +    allow ntop_t self:bluetooth_socket create_socket_perms;
>>> +')
>>> +
>>>    optional_policy(`
>>>        apache_read_sys_content(ntop_t)
>>>    ')
>>> diff --git a/policy/modules/system/userdomain.if
>>> b/policy/modules/system/userdomain.if
>>> index 5221bd13..5654de6e 100644
>>> --- a/policy/modules/system/userdomain.if
>>> +++ b/policy/modules/system/userdomain.if
>>> @@ -1189,6 +1189,10 @@ template(`userdom_unpriv_user_template', `
>>>            corenet_udp_bind_generic_port($1_t)
>>>        ')
>>>    +    tunable_policy(`allow_bluetooth',`
>>> +        allow $1_t self:bluetooth_socket create_socket_perms;
>>> +    ')
>>> +
>>>        optional_policy(`
>>>            netutils_run_ping_cond($1_t, $1_r)
>>>            netutils_run_traceroute_cond($1_t, $1_r)
>>> @@ -1362,6 +1366,10 @@ template(`userdom_admin_user_template',`
>>>        userdom_manage_user_home_content_sockets($1_t)
>>>        userdom_user_home_dir_filetrans_user_home_content($1_t, { dir
>>> file lnk_file fifo_file sock_file })
>>>    +    tunable_policy(`allow_bluetooth',`
>>> +        allow $1_t self:bluetooth_socket create_stream_socket_perms;
>>> +    ')
>>> +
>>>        optional_policy(`
>>>            postgresql_unconfined($1_t)
>>>        ')
>>>
>>
>>
> 
> 


-- 
Chris PeBenito

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Introduce allow_bluetooth boolean
  2019-04-26 18:52 ` Dominick Grift
@ 2019-04-27 17:16   ` Dominick Grift
  0 siblings, 0 replies; 7+ messages in thread
From: Dominick Grift @ 2019-04-27 17:16 UTC (permalink / raw)
  To: Lukas Vrabec, selinux-refpolicy

[-- Attachment #1: Type: text/plain, Size: 7046 bytes --]

On Fri, Apr 26, 2019 at 08:52:50PM +0200, Dominick Grift wrote:
> On Fri, Apr 26, 2019 at 11:27:10AM +0200, Lukas Vrabec wrote:
> > Because of new bluetooth_socket which is part of extended_socket_class
> > policy capability, it's possible to control which SELinux domains can
> > use bluetooth wireless technology. Default value of the boolean is
> > turned off.
> 
> Two observations:
> 
> 1. are you using 4 spaces ident instead of 8 space tab indentation?
> 2. this rule is questionable:
> allow init_t self:bluetooth_socket { create_socket_perms listen };

I looked into this and tracked the above down to this:

https://bugzilla.redhat.com/show_bug.cgi?id=1592223

In that report the bluetoothd executable file was mislabeled and that is why it ended up in init_t.

Please address the indents and remove the above rule.

> 
> > 
> > Signed-off-by: Lukas Vrabec <lvrabec@redhat.com>
> > ---
> >  policy/global_tunables               | 7 +++++++
> >  policy/modules/admin/netutils.te     | 4 ++++
> >  policy/modules/services/arpwatch.te  | 4 ++++
> >  policy/modules/services/bluetooth.if | 4 ++++
> >  policy/modules/services/bluetooth.te | 4 ++++
> >  policy/modules/services/ntop.te      | 4 ++++
> >  policy/modules/system/init.te        | 4 ++++
> >  policy/modules/system/userdomain.if  | 8 ++++++++
> >  8 files changed, 39 insertions(+)
> > 
> > diff --git a/policy/global_tunables b/policy/global_tunables
> > index affc020f..69b356e2 100644
> > --- a/policy/global_tunables
> > +++ b/policy/global_tunables
> > @@ -4,6 +4,13 @@
> >  # file should be used.
> >  #
> >  
> > +## <desc>
> > +## <p>
> > +## Allow all system processes and Linux users to use bluetooth wireless technology.
> > +## </p>
> > +## </desc>
> > +gen_tunable(allow_bluetooth,false)
> > +
> >  ## <desc>
> >  ## <p>
> >  ## Allow unconfined executables to make their heap memory executable.  Doing this is a really bad idea. Probably indicates a badly coded executable, but could indicate an attack. This executable should be reported in bugzilla
> > diff --git a/policy/modules/admin/netutils.te b/policy/modules/admin/netutils.te
> > index 46560a09..b4e66e8f 100644
> > --- a/policy/modules/admin/netutils.te
> > +++ b/policy/modules/admin/netutils.te
> > @@ -99,6 +99,10 @@ optional_policy(`
> >  	xen_append_log(netutils_t)
> >  ')
> >  
> > +tunable_policy(`allow_bluetooth',`
> > +    allow netutils_t self:bluetooth_socket create_stream_socket_perms;
> > +')
> > +
> >  ########################################
> >  #
> >  # Ping local policy
> > diff --git a/policy/modules/services/arpwatch.te b/policy/modules/services/arpwatch.te
> > index 87aed96f..7e817035 100644
> > --- a/policy/modules/services/arpwatch.te
> > +++ b/policy/modules/services/arpwatch.te
> > @@ -77,6 +77,10 @@ miscfiles_read_localization(arpwatch_t)
> >  userdom_dontaudit_search_user_home_dirs(arpwatch_t)
> >  userdom_dontaudit_use_unpriv_user_fds(arpwatch_t)
> >  
> > +tunable_policy(`allow_bluetooth',`
> > +    allow arpwatch_t self:bluetooth_socket create_socket_perms;
> > +')
> > +
> >  optional_policy(`
> >  	mta_send_mail(arpwatch_t)
> >  ')
> > diff --git a/policy/modules/services/bluetooth.if b/policy/modules/services/bluetooth.if
> > index dc61988c..5fda4f69 100644
> > --- a/policy/modules/services/bluetooth.if
> > +++ b/policy/modules/services/bluetooth.if
> > @@ -68,6 +68,10 @@ interface(`bluetooth_stream_connect',`
> >  	files_search_pids($1)
> >  	allow $1 bluetooth_t:socket rw_socket_perms;
> >  	stream_connect_pattern($1, bluetooth_var_run_t, bluetooth_var_run_t, bluetooth_t)
> > +
> > +    tunable_policy(`deny_bluetooth',`',`
> > +        allow $1 bluetooth_t:bluetooth_socket rw_socket_perms;
> > +    ')
> >  ')
> >  
> >  ########################################
> > diff --git a/policy/modules/services/bluetooth.te b/policy/modules/services/bluetooth.te
> > index 45e5a361..fa9daa48 100644
> > --- a/policy/modules/services/bluetooth.te
> > +++ b/policy/modules/services/bluetooth.te
> > @@ -133,6 +133,10 @@ userdom_dontaudit_use_unpriv_user_fds(bluetooth_t)
> >  userdom_dontaudit_use_user_terminals(bluetooth_t)
> >  userdom_dontaudit_search_user_home_dirs(bluetooth_t)
> >  
> > +tunable_policy(`allow_bluetooth',`
> > +    allow bluetooth_t self:bluetooth_socket create_stream_socket_perms;
> > +')
> > +
> >  optional_policy(`
> >  	dbus_system_bus_client(bluetooth_t)
> >  	dbus_connect_system_bus(bluetooth_t)
> > diff --git a/policy/modules/services/ntop.te b/policy/modules/services/ntop.te
> > index 178bbb1d..50157b88 100644
> > --- a/policy/modules/services/ntop.te
> > +++ b/policy/modules/services/ntop.te
> > @@ -96,6 +96,10 @@ miscfiles_read_localization(ntop_t)
> >  userdom_dontaudit_use_unpriv_user_fds(ntop_t)
> >  userdom_dontaudit_search_user_home_dirs(ntop_t)
> >  
> > +tunable_policy(`allow_bluetooth',`
> > +    allow ntop_t self:bluetooth_socket create_socket_perms;
> > +')
> > +
> >  optional_policy(`
> >  	apache_read_sys_content(ntop_t)
> >  ')
> > diff --git a/policy/modules/system/init.te b/policy/modules/system/init.te
> > index 00f36c99..26eff7bc 100644
> > --- a/policy/modules/system/init.te
> > +++ b/policy/modules/system/init.te
> > @@ -523,6 +523,10 @@ optional_policy(`
> >  	unconfined_domain(init_t)
> >  ')
> >  
> > +tunable_policy(`allow_bluetooth',`
> > +    allow init_t self:bluetooth_socket { create_socket_perms listen };
> > +')
> > +
> >  ########################################
> >  #
> >  # Init script local policy
> > diff --git a/policy/modules/system/userdomain.if b/policy/modules/system/userdomain.if
> > index 5221bd13..50d2e080 100644
> > --- a/policy/modules/system/userdomain.if
> > +++ b/policy/modules/system/userdomain.if
> > @@ -1189,6 +1189,10 @@ template(`userdom_unpriv_user_template', `
> >  		corenet_udp_bind_generic_port($1_t)
> >  	')
> >  
> > +    tunable_policy(`allow_bluetooth',`
> > +        allow $1_t self:bluetooth_socket create_socket_perms;
> > +    ')
> > +
> >  	optional_policy(`
> >  		netutils_run_ping_cond($1_t, $1_r)
> >  		netutils_run_traceroute_cond($1_t, $1_r)
> > @@ -1362,6 +1366,10 @@ template(`userdom_admin_user_template',`
> >  	userdom_manage_user_home_content_sockets($1_t)
> >  	userdom_user_home_dir_filetrans_user_home_content($1_t, { dir file lnk_file fifo_file sock_file })
> >  
> > +    tunable_policy(`allow_bluetooth',`
> > +        allow $1_t self:bluetooth_socket create_stream_socket_perms;
> > +    ')
> > +
> >  	optional_policy(`
> >  		postgresql_unconfined($1_t)
> >  	')
> > -- 
> > 2.20.1
> > 
> 
> -- 
> Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
> https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
> Dominick Grift



-- 
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Introduce allow_bluetooth boolean
  2019-04-26  9:27 Lukas Vrabec
@ 2019-04-26 18:52 ` Dominick Grift
  2019-04-27 17:16   ` Dominick Grift
  0 siblings, 1 reply; 7+ messages in thread
From: Dominick Grift @ 2019-04-26 18:52 UTC (permalink / raw)
  To: Lukas Vrabec; +Cc: selinux-refpolicy

[-- Attachment #1: Type: text/plain, Size: 6204 bytes --]

On Fri, Apr 26, 2019 at 11:27:10AM +0200, Lukas Vrabec wrote:
> Because of new bluetooth_socket which is part of extended_socket_class
> policy capability, it's possible to control which SELinux domains can
> use bluetooth wireless technology. Default value of the boolean is
> turned off.

Two observations:

1. are you using 4 spaces ident instead of 8 space tab indentation?
2. this rule is questionable:
allow init_t self:bluetooth_socket { create_socket_perms listen };

> 
> Signed-off-by: Lukas Vrabec <lvrabec@redhat.com>
> ---
>  policy/global_tunables               | 7 +++++++
>  policy/modules/admin/netutils.te     | 4 ++++
>  policy/modules/services/arpwatch.te  | 4 ++++
>  policy/modules/services/bluetooth.if | 4 ++++
>  policy/modules/services/bluetooth.te | 4 ++++
>  policy/modules/services/ntop.te      | 4 ++++
>  policy/modules/system/init.te        | 4 ++++
>  policy/modules/system/userdomain.if  | 8 ++++++++
>  8 files changed, 39 insertions(+)
> 
> diff --git a/policy/global_tunables b/policy/global_tunables
> index affc020f..69b356e2 100644
> --- a/policy/global_tunables
> +++ b/policy/global_tunables
> @@ -4,6 +4,13 @@
>  # file should be used.
>  #
>  
> +## <desc>
> +## <p>
> +## Allow all system processes and Linux users to use bluetooth wireless technology.
> +## </p>
> +## </desc>
> +gen_tunable(allow_bluetooth,false)
> +
>  ## <desc>
>  ## <p>
>  ## Allow unconfined executables to make their heap memory executable.  Doing this is a really bad idea. Probably indicates a badly coded executable, but could indicate an attack. This executable should be reported in bugzilla
> diff --git a/policy/modules/admin/netutils.te b/policy/modules/admin/netutils.te
> index 46560a09..b4e66e8f 100644
> --- a/policy/modules/admin/netutils.te
> +++ b/policy/modules/admin/netutils.te
> @@ -99,6 +99,10 @@ optional_policy(`
>  	xen_append_log(netutils_t)
>  ')
>  
> +tunable_policy(`allow_bluetooth',`
> +    allow netutils_t self:bluetooth_socket create_stream_socket_perms;
> +')
> +
>  ########################################
>  #
>  # Ping local policy
> diff --git a/policy/modules/services/arpwatch.te b/policy/modules/services/arpwatch.te
> index 87aed96f..7e817035 100644
> --- a/policy/modules/services/arpwatch.te
> +++ b/policy/modules/services/arpwatch.te
> @@ -77,6 +77,10 @@ miscfiles_read_localization(arpwatch_t)
>  userdom_dontaudit_search_user_home_dirs(arpwatch_t)
>  userdom_dontaudit_use_unpriv_user_fds(arpwatch_t)
>  
> +tunable_policy(`allow_bluetooth',`
> +    allow arpwatch_t self:bluetooth_socket create_socket_perms;
> +')
> +
>  optional_policy(`
>  	mta_send_mail(arpwatch_t)
>  ')
> diff --git a/policy/modules/services/bluetooth.if b/policy/modules/services/bluetooth.if
> index dc61988c..5fda4f69 100644
> --- a/policy/modules/services/bluetooth.if
> +++ b/policy/modules/services/bluetooth.if
> @@ -68,6 +68,10 @@ interface(`bluetooth_stream_connect',`
>  	files_search_pids($1)
>  	allow $1 bluetooth_t:socket rw_socket_perms;
>  	stream_connect_pattern($1, bluetooth_var_run_t, bluetooth_var_run_t, bluetooth_t)
> +
> +    tunable_policy(`deny_bluetooth',`',`
> +        allow $1 bluetooth_t:bluetooth_socket rw_socket_perms;
> +    ')
>  ')
>  
>  ########################################
> diff --git a/policy/modules/services/bluetooth.te b/policy/modules/services/bluetooth.te
> index 45e5a361..fa9daa48 100644
> --- a/policy/modules/services/bluetooth.te
> +++ b/policy/modules/services/bluetooth.te
> @@ -133,6 +133,10 @@ userdom_dontaudit_use_unpriv_user_fds(bluetooth_t)
>  userdom_dontaudit_use_user_terminals(bluetooth_t)
>  userdom_dontaudit_search_user_home_dirs(bluetooth_t)
>  
> +tunable_policy(`allow_bluetooth',`
> +    allow bluetooth_t self:bluetooth_socket create_stream_socket_perms;
> +')
> +
>  optional_policy(`
>  	dbus_system_bus_client(bluetooth_t)
>  	dbus_connect_system_bus(bluetooth_t)
> diff --git a/policy/modules/services/ntop.te b/policy/modules/services/ntop.te
> index 178bbb1d..50157b88 100644
> --- a/policy/modules/services/ntop.te
> +++ b/policy/modules/services/ntop.te
> @@ -96,6 +96,10 @@ miscfiles_read_localization(ntop_t)
>  userdom_dontaudit_use_unpriv_user_fds(ntop_t)
>  userdom_dontaudit_search_user_home_dirs(ntop_t)
>  
> +tunable_policy(`allow_bluetooth',`
> +    allow ntop_t self:bluetooth_socket create_socket_perms;
> +')
> +
>  optional_policy(`
>  	apache_read_sys_content(ntop_t)
>  ')
> diff --git a/policy/modules/system/init.te b/policy/modules/system/init.te
> index 00f36c99..26eff7bc 100644
> --- a/policy/modules/system/init.te
> +++ b/policy/modules/system/init.te
> @@ -523,6 +523,10 @@ optional_policy(`
>  	unconfined_domain(init_t)
>  ')
>  
> +tunable_policy(`allow_bluetooth',`
> +    allow init_t self:bluetooth_socket { create_socket_perms listen };
> +')
> +
>  ########################################
>  #
>  # Init script local policy
> diff --git a/policy/modules/system/userdomain.if b/policy/modules/system/userdomain.if
> index 5221bd13..50d2e080 100644
> --- a/policy/modules/system/userdomain.if
> +++ b/policy/modules/system/userdomain.if
> @@ -1189,6 +1189,10 @@ template(`userdom_unpriv_user_template', `
>  		corenet_udp_bind_generic_port($1_t)
>  	')
>  
> +    tunable_policy(`allow_bluetooth',`
> +        allow $1_t self:bluetooth_socket create_socket_perms;
> +    ')
> +
>  	optional_policy(`
>  		netutils_run_ping_cond($1_t, $1_r)
>  		netutils_run_traceroute_cond($1_t, $1_r)
> @@ -1362,6 +1366,10 @@ template(`userdom_admin_user_template',`
>  	userdom_manage_user_home_content_sockets($1_t)
>  	userdom_user_home_dir_filetrans_user_home_content($1_t, { dir file lnk_file fifo_file sock_file })
>  
> +    tunable_policy(`allow_bluetooth',`
> +        allow $1_t self:bluetooth_socket create_stream_socket_perms;
> +    ')
> +
>  	optional_policy(`
>  		postgresql_unconfined($1_t)
>  	')
> -- 
> 2.20.1
> 

-- 
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Introduce allow_bluetooth boolean
@ 2019-04-26  9:27 Lukas Vrabec
  2019-04-26 18:52 ` Dominick Grift
  0 siblings, 1 reply; 7+ messages in thread
From: Lukas Vrabec @ 2019-04-26  9:27 UTC (permalink / raw)
  To: selinux-refpolicy; +Cc: Lukas Vrabec

Because of new bluetooth_socket which is part of extended_socket_class
policy capability, it's possible to control which SELinux domains can
use bluetooth wireless technology. Default value of the boolean is
turned off.

Signed-off-by: Lukas Vrabec <lvrabec@redhat.com>
---
 policy/global_tunables               | 7 +++++++
 policy/modules/admin/netutils.te     | 4 ++++
 policy/modules/services/arpwatch.te  | 4 ++++
 policy/modules/services/bluetooth.if | 4 ++++
 policy/modules/services/bluetooth.te | 4 ++++
 policy/modules/services/ntop.te      | 4 ++++
 policy/modules/system/init.te        | 4 ++++
 policy/modules/system/userdomain.if  | 8 ++++++++
 8 files changed, 39 insertions(+)

diff --git a/policy/global_tunables b/policy/global_tunables
index affc020f..69b356e2 100644
--- a/policy/global_tunables
+++ b/policy/global_tunables
@@ -4,6 +4,13 @@
 # file should be used.
 #
 
+## <desc>
+## <p>
+## Allow all system processes and Linux users to use bluetooth wireless technology.
+## </p>
+## </desc>
+gen_tunable(allow_bluetooth,false)
+
 ## <desc>
 ## <p>
 ## Allow unconfined executables to make their heap memory executable.  Doing this is a really bad idea. Probably indicates a badly coded executable, but could indicate an attack. This executable should be reported in bugzilla
diff --git a/policy/modules/admin/netutils.te b/policy/modules/admin/netutils.te
index 46560a09..b4e66e8f 100644
--- a/policy/modules/admin/netutils.te
+++ b/policy/modules/admin/netutils.te
@@ -99,6 +99,10 @@ optional_policy(`
 	xen_append_log(netutils_t)
 ')
 
+tunable_policy(`allow_bluetooth',`
+    allow netutils_t self:bluetooth_socket create_stream_socket_perms;
+')
+
 ########################################
 #
 # Ping local policy
diff --git a/policy/modules/services/arpwatch.te b/policy/modules/services/arpwatch.te
index 87aed96f..7e817035 100644
--- a/policy/modules/services/arpwatch.te
+++ b/policy/modules/services/arpwatch.te
@@ -77,6 +77,10 @@ miscfiles_read_localization(arpwatch_t)
 userdom_dontaudit_search_user_home_dirs(arpwatch_t)
 userdom_dontaudit_use_unpriv_user_fds(arpwatch_t)
 
+tunable_policy(`allow_bluetooth',`
+    allow arpwatch_t self:bluetooth_socket create_socket_perms;
+')
+
 optional_policy(`
 	mta_send_mail(arpwatch_t)
 ')
diff --git a/policy/modules/services/bluetooth.if b/policy/modules/services/bluetooth.if
index dc61988c..5fda4f69 100644
--- a/policy/modules/services/bluetooth.if
+++ b/policy/modules/services/bluetooth.if
@@ -68,6 +68,10 @@ interface(`bluetooth_stream_connect',`
 	files_search_pids($1)
 	allow $1 bluetooth_t:socket rw_socket_perms;
 	stream_connect_pattern($1, bluetooth_var_run_t, bluetooth_var_run_t, bluetooth_t)
+
+    tunable_policy(`deny_bluetooth',`',`
+        allow $1 bluetooth_t:bluetooth_socket rw_socket_perms;
+    ')
 ')
 
 ########################################
diff --git a/policy/modules/services/bluetooth.te b/policy/modules/services/bluetooth.te
index 45e5a361..fa9daa48 100644
--- a/policy/modules/services/bluetooth.te
+++ b/policy/modules/services/bluetooth.te
@@ -133,6 +133,10 @@ userdom_dontaudit_use_unpriv_user_fds(bluetooth_t)
 userdom_dontaudit_use_user_terminals(bluetooth_t)
 userdom_dontaudit_search_user_home_dirs(bluetooth_t)
 
+tunable_policy(`allow_bluetooth',`
+    allow bluetooth_t self:bluetooth_socket create_stream_socket_perms;
+')
+
 optional_policy(`
 	dbus_system_bus_client(bluetooth_t)
 	dbus_connect_system_bus(bluetooth_t)
diff --git a/policy/modules/services/ntop.te b/policy/modules/services/ntop.te
index 178bbb1d..50157b88 100644
--- a/policy/modules/services/ntop.te
+++ b/policy/modules/services/ntop.te
@@ -96,6 +96,10 @@ miscfiles_read_localization(ntop_t)
 userdom_dontaudit_use_unpriv_user_fds(ntop_t)
 userdom_dontaudit_search_user_home_dirs(ntop_t)
 
+tunable_policy(`allow_bluetooth',`
+    allow ntop_t self:bluetooth_socket create_socket_perms;
+')
+
 optional_policy(`
 	apache_read_sys_content(ntop_t)
 ')
diff --git a/policy/modules/system/init.te b/policy/modules/system/init.te
index 00f36c99..26eff7bc 100644
--- a/policy/modules/system/init.te
+++ b/policy/modules/system/init.te
@@ -523,6 +523,10 @@ optional_policy(`
 	unconfined_domain(init_t)
 ')
 
+tunable_policy(`allow_bluetooth',`
+    allow init_t self:bluetooth_socket { create_socket_perms listen };
+')
+
 ########################################
 #
 # Init script local policy
diff --git a/policy/modules/system/userdomain.if b/policy/modules/system/userdomain.if
index 5221bd13..50d2e080 100644
--- a/policy/modules/system/userdomain.if
+++ b/policy/modules/system/userdomain.if
@@ -1189,6 +1189,10 @@ template(`userdom_unpriv_user_template', `
 		corenet_udp_bind_generic_port($1_t)
 	')
 
+    tunable_policy(`allow_bluetooth',`
+        allow $1_t self:bluetooth_socket create_socket_perms;
+    ')
+
 	optional_policy(`
 		netutils_run_ping_cond($1_t, $1_r)
 		netutils_run_traceroute_cond($1_t, $1_r)
@@ -1362,6 +1366,10 @@ template(`userdom_admin_user_template',`
 	userdom_manage_user_home_content_sockets($1_t)
 	userdom_user_home_dir_filetrans_user_home_content($1_t, { dir file lnk_file fifo_file sock_file })
 
+    tunable_policy(`allow_bluetooth',`
+        allow $1_t self:bluetooth_socket create_stream_socket_perms;
+    ')
+
 	optional_policy(`
 		postgresql_unconfined($1_t)
 	')
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-05-06  0:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30 17:53 [PATCH] Introduce allow_bluetooth boolean Lukas Vrabec
2019-04-30 23:37 ` Chris PeBenito
2019-05-04 10:26   ` Lukas Vrabec
2019-05-06  0:36     ` Chris PeBenito
  -- strict thread matches above, loose matches on Subject: below --
2019-04-26  9:27 Lukas Vrabec
2019-04-26 18:52 ` Dominick Grift
2019-04-27 17:16   ` Dominick Grift

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).