Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp25862lqo; Wed, 15 May 2024 06:51:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXFVbFAUu07cQCPag46RABwhy1Q+a4HDigP+9ZEYWfwPPPx8NvrgpnjNk3ielN8ooa0ctO30yu5FR8RoDRE+zE5/Irv4216WKw0f743uQ== X-Google-Smtp-Source: AGHT+IGvqXTPaSN8QMKUf3f8h9qc35l2+gREdYN2ujBpHBdxyfBYruuEx0ZTczaLHc84iIMBnbCS X-Received: by 2002:a05:620a:1916:b0:790:e76a:33e2 with SMTP id af79cd13be357-792c75f36d9mr2103399285a.61.1715781083870; Wed, 15 May 2024 06:51:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715781083; cv=pass; d=google.com; s=arc-20160816; b=sG0nGLJcll1QKsV4T1DsqsKtaheMiWBlq+wMW7PZEb0W7vivPgWjYp/YWHGZ2QifUv B0MvH1PiiBq6kSlgb5fKq+ieWYomGMjWdezdWKR4Cuk+68bW/lDigv8Pc36ZefFI/jJl dJyM2OBB/ku0QdXt9T8er4QJmDy1aWg8ObPQ/Oc8ewmtzkeC9z2uMi1m5fHqxK1KbwlY x069758gWLFNIHitas4EuinvYIQmCzxPFCM9ZTDjxdLkh2jA+adIn8KlsUnsK/ABXkzh QEK8DUaQpxXBm+CqIyMaYQPj67X5emlmA0YB652EgByYKIejUPml3h8Nx9fZH2uRwXyh kiig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=h9jbX93d8GdB/Go/fLZjEclo41s6ocrUEKJqrjNutDw=; fh=7qY+kwSu2IfMl0eqnXzKD0v+r76ITh/a7NVcuUORsGg=; b=Yrx8Md5sM5M7a1R96sMiRCB9Cn3qaRMZ7xxiVRl24EgflDioKUTh1Z2XL84m/gd0+7 GjNNWgUqEEfoRBCD9h+0HrfTez3YD5lKndeQvQTwEL/W0rymSOhPMKaGUbSSaBzUZNPi pKaGlDbIEvjVff0clvzF4DnklMDTq7n0JcCKIjDLY0VAUM1DlItf7FJQDeY0gCB43jxr UzwyKY492Z9CciWBYbhmxL32kZs7Q95a3puXNWv1bK6h8QRcgWAWCpQgKFtAZZhRsuwN FthzI64ZTizvzrdSE4JSBcA841dSGSyYZzk47LicjpxQnsNw2GnvZCBIG11yR/8R17sv JL8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ieee.org header.s=google header.b=RiW2PE8x; arc=pass (i=1 spf=pass spfdomain=ieee.org dkim=pass dkdomain=ieee.org dmarc=pass fromdomain=ieee.org); spf=pass (google.com: domain of selinux-refpolicy+bounces-11-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="selinux-refpolicy+bounces-11-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ieee.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792d052073dsi977875985a.770.2024.05.15.06.51.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 06:51:23 -0700 (PDT) Received-SPF: pass (google.com: domain of selinux-refpolicy+bounces-11-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ieee.org header.s=google header.b=RiW2PE8x; arc=pass (i=1 spf=pass spfdomain=ieee.org dkim=pass dkdomain=ieee.org dmarc=pass fromdomain=ieee.org); spf=pass (google.com: domain of selinux-refpolicy+bounces-11-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="selinux-refpolicy+bounces-11-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ieee.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7281F1C20970 for ; Wed, 15 May 2024 13:51:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9049213E8B6; Wed, 15 May 2024 13:51:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ieee.org header.i=@ieee.org header.b="RiW2PE8x" X-Original-To: selinux-refpolicy@vger.kernel.org Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FE108615E for ; Wed, 15 May 2024 13:51:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715781080; cv=none; b=ZTMSU7VtSMPtOeT8echlzSARAeGLq0XAUFY5uED9/8oIg2SCMu02ST1RBxkp9oqY/iP1aL3DTynWWfJC53zYOsl7zHPrBNU2fyQIigyZJwUcDKvbs7A7le+AWVIQX2BeeKLMnNTHQ1ZE1fH33RP2VBm8GoDYu1j0MW/qbNuYV9s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715781080; c=relaxed/simple; bh=qihkLXHaxrrC8kzBwekjfQTvs56gPBkVsrWBZcujLzQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=M3wLIc4U1WcV1+TAQZrlM5Ilt7XAqihvtrnDKIFeUMkZlJV64vgWqyWZJeDmMUoGX80fMr3uS5hZvWGEFnDmlJhJzM9Igbv0TRPBjLqwbwC5gbVnLhm3yQP950Atif4wXbiejRVInyI6JyZGasj73YZ35GUbD6gkP2bAKUsbyyw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ieee.org; spf=pass smtp.mailfrom=ieee.org; dkim=pass (1024-bit key) header.d=ieee.org header.i=@ieee.org header.b=RiW2PE8x; arc=none smtp.client-ip=209.85.222.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ieee.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ieee.org Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-78f049ddd7dso517147985a.1 for ; Wed, 15 May 2024 06:51:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ieee.org; s=google; t=1715781076; x=1716385876; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=h9jbX93d8GdB/Go/fLZjEclo41s6ocrUEKJqrjNutDw=; b=RiW2PE8xYrNw18NSwgXVfs3cBsNESSECZvu6dYIfczjz6G7Ra8mca9tb6LUQYXGobK 3K/wJVm9j86iLMkXlg84McrorHhbSL+91mTxG9SQRkByjqH1YVs3pr99ZJftAgFgk4WD GvghFR9Nl2vSS33m1d2MTZ01wGJum7Qb/hzoY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715781076; x=1716385876; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h9jbX93d8GdB/Go/fLZjEclo41s6ocrUEKJqrjNutDw=; b=YGJz/zOyyCYZNRHFdjYZ+gBAnUzsCSqWKLL6MYZ2MtDuzh3W5q+Pz6I3ZVL5uhirK3 tb7tHj285Vn6vd6HTgKmVp14PEM5f5WyVadS/yHCh3lahwf112iIEawoqYqrBwuSB29m h2+dokOHhF9SCaudhEacvbAHCmBHf6CIfS9d6vIDJiQnkGrAsoj9W+cRxgCkypaOundb XIjhLJxsEyZE7khUQl6vqTAqCUcslRol5eT7yxzJsS7C9owUW6+GUnog7SmS+TsW34EQ Ul0g1bYVgD/q3MWXOX0LqnPF3ty9FbqT6Un8U/HNBa2OJEaSJBqZx4CRDD4IBiLDsmwk NCUA== X-Forwarded-Encrypted: i=1; AJvYcCULC5W9b5qKz9Ope7Pwo3pTFB9lgD4aILUnNK8kj8FxdtIAQ52NUM8+I9G2jpqy5FFITHD2lkurD5OxMwJEQcPM28PeQohc7ZZYAdqNR6+QsCU= X-Gm-Message-State: AOJu0YwXqIdar5J6SEPLUa1nfeGqXefUkuJ9k+Xm45lPPpmMzLCLb5r7 23SVdiUChyt/7mXOuFvJSQNkdOODOcN6dJfL2VfkLaVqL3wua3/Z4GpY4QAblg== X-Received: by 2002:a05:620a:201c:b0:790:ec9c:cc7d with SMTP id af79cd13be357-792c75779c7mr1494143085a.14.1715781075968; Wed, 15 May 2024 06:51:15 -0700 (PDT) Received: from ?IPV6:2601:145:c200:2c70:a014:bdf4:3cb:9462? ([2601:145:c200:2c70:a014:bdf4:3cb:9462]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43df8c1b2f5sm79543301cf.8.2024.05.15.06.51.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 May 2024 06:51:15 -0700 (PDT) Message-ID: <4140be53-76bc-4aee-880f-4799b996897b@ieee.org> Date: Wed, 15 May 2024 09:51:14 -0400 Precedence: bulk X-Mailing-List: selinux-refpolicy@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] Adding Sepolicy rules to allow bluetoothctl and dbus-daemon to access unix stream sockets. To: Naga Bhavani Akella , selinux-refpolicy@vger.kernel.org Cc: quic_mohamull@quicinc.com, quic_hbandi@quicinc.com, quic_anubhavg@quicinc.com References: <20240514072123.11376-1-quic_nakella@quicinc.com> <877cf03e-037d-4708-8ac0-bce5b2caa48a@ieee.org> <695f447e-b9db-414f-8fa5-1b12b8379c48@quicinc.com> Content-Language: en-US From: Chris PeBenito In-Reply-To: <695f447e-b9db-414f-8fa5-1b12b8379c48@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 5/15/2024 3:29 AM, Naga Bhavani Akella wrote: > Hi Chris PeBenito, > > Thank you for your comments. > > On 5/15/2024 1:42 AM, Chris PeBenito wrote: >> On 5/14/2024 3:21 AM, Naga Bhavani Akella wrote: >>> Required for using acquire-notify, acquire-write options (Gatt Client) >>> and Sending notifications (Gatt Server) >>> >>> Below are the avc denials that are fixed with this patch - >>> >>> 1. audit: type=1400 audit(1651238006.276:496): >>> avc:  denied  { read write } for  pid=2165 comm="bluetoothd" >>> path="socket:[43207]" dev="sockfs" ino=43207 >>> scontext=system_u:system_r:bluetooth_t:s0-s15:c0.c1023 >>> tcontext=system_u:system_r:initrc_t:s0-s15:c0.c1023 >>> tclass=unix_stream_socket permissive=1 >>> 2. audit: type=1400 audit(1651238006.276:497): >>> avc:  denied  { getattr } for  pid=2165 comm="bluetoothd" >>> path="socket:[43207]" dev="sockfs" ino=43207 >>> scontext=system_u:system_r:bluetooth_t:s0-s15:c0.c1023 >>> tcontext=system_u:system_r:initrc_t:s0-s15:c0.c1023 >>> tclass=unix_stream_socket permissive=1 >>> 3. audit: type=1400 audit(1651238006.272:495): >>> avc:  denied  { read write } for  pid=689 comm="dbus-daemon" >>> path="socket:[43207]" dev="sockfs" ino=43207 >>> scontext=system_u:system_r:system_dbusd_t:s0-s15:c0.c1023 >>> tcontext=system_u:system_r:initrc_t:s0-s15:c0.c1023 >>> tclass=unix_stream_socket permissive=1 >>> 4. audit: type=1400 audit(315966559.395:444): >>> avc:  denied  { use } for  pid=710 comm="dbus-daemon" >>> path="socket:[13196]" dev="sockfs" ino=13196 >>> scontext=system_u:system_r:system_dbusd_t:s0-s15:c0.c1023 >>> tcontext=system_u:system_r:bluetooth_t:s0-s15:c0.c1023 >>> tclass=fd permissive=0 >>> 5. audit: type=1400 audit(315999854.939:523): >>> avc:  denied  { read write } for  pid=812 comm="dbus-daemon" >>> path="socket:[99469]" dev="sockfs" ino=99469 >>> scontext=system_u:system_r:system_dbusd_t:s0-s15:c0.c1023 >>> tcontext=system_u:system_r:bluetooth_t:s0-s15:c0.c1023 >>> tclass=bluetooth_socket permissive=1 >>> >>> Signed-off-by: Naga Bhavani Akella >>> --- >>>   policy/modules/services/bluetooth.fc | 1 + >>>   policy/modules/services/bluetooth.if | 3 +++ >>>   2 files changed, 4 insertions(+) >>> >>> diff --git a/policy/modules/services/bluetooth.fc b/policy/modules/services/bluetooth.fc >>> index e167e93f7..03f42fc8b 100644 >>> --- a/policy/modules/services/bluetooth.fc >>> +++ b/policy/modules/services/bluetooth.fc >>> @@ -7,6 +7,7 @@ >>>     /usr/bin/blue.*pin    --    gen_context(system_u:object_r:bluetooth_helper_exec_t,s0) >>>   /usr/bin/bluetoothd    --    gen_context(system_u:object_r:bluetooth_exec_t,s0) >>> +/usr/bin/bluetoothctl    --    gen_context(system_u:object_r:bluetooth_exec_t,s0) >>>   /usr/bin/dund    --    gen_context(system_u:object_r:bluetooth_exec_t,s0) >>>   /usr/bin/hciattach    --    gen_context(system_u:object_r:bluetooth_exec_t,s0) >>>   /usr/bin/hcid    --    gen_context(system_u:object_r:bluetooth_exec_t,s0) >>> diff --git a/policy/modules/services/bluetooth.if b/policy/modules/services/bluetooth.if >>> index c7e1c3f14..c869eed71 100644 >>> --- a/policy/modules/services/bluetooth.if >>> +++ b/policy/modules/services/bluetooth.if >>> @@ -82,6 +82,9 @@ interface(`bluetooth_stream_connect',` >>>         files_search_runtime($1) >>>       allow $1 bluetooth_t:socket rw_socket_perms; >>> +    allow $1 bluetooth_t:bluetooth_socket rw_socket_perms; >>> +    allow $1 bluetooth_t:unix_stream_socket { accept connectto listen rw_socket_perms }; >>> +    allow $1 bluetooth_t:fd use; >>>       stream_connect_pattern($1, bluetooth_runtime_t, bluetooth_runtime_t, bluetooth_t) >>>   ') >> >> I have two main concerns: >> >> 1. is the added access in this interface required for all users that connect to bluetoothd over a unix domain socket? >> > As per my understanding any user who wants to use bluetooth over unix domain has to make dbus calls to bluetoothd. So I feel its required. For example- bluetooth_stream_connect is currently being used by pulseaudio_t and obex_t as well, these services also use dbus methods. > Please let us know your opinion on this or better way to fix these AVC denials. In that case, then a new interface with a more abstract name would be warranted. >> 2. does bluetoothctl really need all the access of the bluetooth_t domain?  It may only need a small permission set, like udev and udevctl. >> > By default bluetoothctl is running in initrc_t domain so added bluetooth_exec_t domain to bluetoothctl. bluetoothctl is command line tool to access whole bluetooth functionality like pair/unpair/connect/disconnect etc. There are other tools like hciattach, rfcomm which are using same domain bluetooth_exec_t. Yes, the point is that we probably need a bluetoothctl_t domain so the configuration can be done only via the bluetoothctl process, not just any initrc_t process. The existing bluetooth_helper_t domain may possibly be renamed/retrofitted for this purpose. -- Chris PeBenito