Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1916355yba; Sun, 5 May 2019 17:38:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7v4uWHZ4koJQsOSbl+7ePovyey95W/buRR6C19VlBbl9J/N9AnjyQt7kwviAZwsdKoQGW X-Received: by 2002:a62:ac0a:: with SMTP id v10mr20784142pfe.57.1557103101765; Sun, 05 May 2019 17:38:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557103101; cv=none; d=google.com; s=arc-20160816; b=fWc8fDlEqwDK1N6titH2HAxkZaoB3qUo7uWivdbqu1WXkklW7x24dsTCxRFIj+PJnx oSwfcxQKUIfY8AFvzGAoJKYTVcVPLBsoY3TBDosDsy1XRCm1A1D3MbsHgl/m+Ew4QIdn 4lUNPcgjOZGOoqP4sAv4IOB6xV/erK7r5Tp6pb5jNUX6flwu4xzpP6lSBfPNGBoHSmoZ Qo7CrCkKfdr3LJxXzRsXEbTrzQVEAqgfpHE5L+4GZ0Kw9Gn04SXcyaitRXqYTpHNxBWB JU6L+uurS1kAWikQTINcfFlifKrNplIs5d7ivh60tv6RiMuCw1HBh4HZYXQSBejY9/C6 CmKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=w9EW9cN6Ik5KMEwdiFOIOa9SseuzWX3pBAxgfo5Ao9s=; b=Mnn8Na/u8O6k+05uWeheqGNkFrokX3KEBOTcCU6Nb4qpJa24JPmO+BKRx+vWTiR+Lm z1ZMyYa8IzI2UAzLKENAhRR594bvC4dxK25OckJ3dKfNQQkQTqYrQV7ssAmVAIoCDndI JlrEapEoFF3jDLJUcZnJwPo26GTBrfa9BWivKhrs33o4j6tGP8biclAjq6WtG/ck9dz+ 1LN6r2pkC5UfTh5f4YLVwIoZQDgJxPCJDxu0zeWpg4G3GKtgNqAxsa8rFY2wARhXIOfc nSkJYm6URCUV0vGpEbDbgkZgHk8cYu9sMwf2jXruVK1HzYc+cOOK96OyNaR6chCwhc// YH5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ieee.org header.s=google header.b=Pjp+W7nQ; spf=pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ieee.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si1117547plm.44.2019.05.05.17.38.15; Sun, 05 May 2019 17:38:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ieee.org header.s=google header.b=Pjp+W7nQ; spf=pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ieee.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727373AbfEFAgN (ORCPT + 11 others); Sun, 5 May 2019 20:36:13 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:33145 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727285AbfEFAgM (ORCPT ); Sun, 5 May 2019 20:36:12 -0400 Received: by mail-qt1-f196.google.com with SMTP id m32so9848886qtf.0 for ; Sun, 05 May 2019 17:36:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ieee.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=w9EW9cN6Ik5KMEwdiFOIOa9SseuzWX3pBAxgfo5Ao9s=; b=Pjp+W7nQmsth3p+CduqMdpYuHUNdw7+pijI5SRfqbXZEUEcqQfaoUUN/t0usetXrhF pIazLO1cb9jTk5F93q3hV7V28fKL2ovB5aYZd1HbyqJ4e+eOFTr80ffVaO1h3DiiaKu2 I5QroTtR4Xlz62cc5/O5+sIqoUNLgj997Bp4g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=w9EW9cN6Ik5KMEwdiFOIOa9SseuzWX3pBAxgfo5Ao9s=; b=WJY51jrsSunSSJqgMrZz28/qrdRpMeYgSXJEQ++AjxlKfy9CUqcD8niFurD46/aSCl 00DIBQsjc2UDI5eKAw5gS4+psw2ELJAuG0t3aqfjO7grmAGfRZYvqc6tuPb33psllWmc aQjA4sPzw4Z14EoX4KuyqsEpAt93q7BTjQRwQtDZQaaDkXHg/ZbQVdV5z60dRGYArpmN sTBrlaQlZ9N53JyjvXWlPilC3yvDLC5V4jBnvalT/p6sTNeYB/W0D/B13el0EjXlshsB qwK0SBTqfQBGeAD/drWVPnr1+w8WuthL1ZRCvjswUjXRgXIGna6gKAKoRuthJ0jA4ADl I/Dw== X-Gm-Message-State: APjAAAXgZaEetKpg/yfx72RVnsTr4aNUApgmsQSeLq9yKfndroTVA1W+ sOYs3ek6yqau/wqAH4YevxnIXeGGHlg= X-Received: by 2002:a0c:8069:: with SMTP id 96mr18678469qva.1.1557102971212; Sun, 05 May 2019 17:36:11 -0700 (PDT) Received: from [192.168.1.190] (pool-108-15-23-247.bltmmd.fios.verizon.net. [108.15.23.247]) by smtp.gmail.com with ESMTPSA id f129sm4813748qkj.47.2019.05.05.17.36.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 May 2019 17:36:10 -0700 (PDT) Subject: Re: [PATCH] Introduce allow_bluetooth boolean To: Lukas Vrabec , selinux-refpolicy@vger.kernel.org References: <20190430175329.25335-1-lvrabec@redhat.com> <4438fae1-fa76-27ea-a7dc-509112540e8c@ieee.org> <5a75d7e6-c56b-e4f5-653c-b846388cfbb4@redhat.com> From: Chris PeBenito Message-ID: Date: Sun, 5 May 2019 20:36:09 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <5a75d7e6-c56b-e4f5-653c-b846388cfbb4@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org 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 >>> --- >>>   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. >>>   # >>>   +## >>> +##

>>> +## Allow all system processes and Linux users to use bluetooth >>> wireless technology. >>> +##

>>> +##
>>> +gen_tunable(allow_bluetooth,false) >>> + >>>   ## >>>   ##

>>>   ## 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