Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3144646lqo; Wed, 15 May 2024 00:30:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU1bVuQlF+2EvRwMhyPlMJ2bRpjqZ8dMMEppuSW1BD1gtI3lyXTjdG/ombY64AmqdF9XEU7Neg/FXxqTWHgRT+v4AoD9m+PAB5yWiJ6hw== X-Google-Smtp-Source: AGHT+IGKVHmVodhndARqzJfZzXwh5sX1/rUH1vnfko5grWmpmLgYtSCZSZz0E0LI2BSXrHBEtU7p X-Received: by 2002:a05:622a:215:b0:43d:dfb3:e4a8 with SMTP id d75a77b69052e-43dfdb6aebcmr168005961cf.53.1715758214413; Wed, 15 May 2024 00:30:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715758214; cv=pass; d=google.com; s=arc-20160816; b=CtxdMBx/dhtiGoOmdr96UJjK4GUeS33ZtfiK2CCcHOsXYOSApS3NiefZaOYlSrJYmG DI9SQVO9M+GA/KU5adPQHZbjxhhla1hGQncWq8ee89JGP9cRVEumU/WWQfuAeNyyp3nZ dCS4jRHdipqBI+kYAJi4Xas4YE4zqKa89TaNpVuFtLxpxQA2NgB1+k3S77i2Y3E+ODUQ qEyzynTTNxZrRqqqF/PwWYl9wwuGh4on6vPLP0iD0s2ltKOJJrgvV7akHXLQ5rOHAS7L VNA8YFz+zPgNI1Tz4Q5mVvzLA0YBQVSmIVMddQznBRazcwr9VXLqmH4WYALzA/cb6MAl ZsTQ== 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=R1z7MYUxgRVr0PsMWI6nRm+5ofVp3nDMHURjSGkWHoo=; fh=IImizUpgYQGqiJQxdvmKf6mnuTxyqQ5pcSftwZ2TLno=; b=OFYrnMJgAW8YMjPaJxDBJ/hc+AMGRA4LU/Xc9NdLbRNUaXrNbq8FVNFdnkQokxoNwP 4h8fyn51jtsPZgxqPBEYE9ZWA21bLeAT7ZqLsFa+76+TtQ2hLAFJu9M5W0BiNln05hBl ukP4IpkC08gNA5q7lZvZcP2X+N8bH3r80lX2j1lA6GSVd2+JLSObb9Zgcg7VqloXetQV i8EDZngCTu6uAkvG1CsPbMq0yGJDEKshRBpAlAON0mPIeoQZbNpKg98A4+X4XbB3qoLZ dKWUNRNe/QnSeAxC/x6aCViehJQjzLU+8EUeWeEmQXoC6Ah+PyPyJTnlf+ZnVnxBfn8p xq5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="LP8qY/gu"; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of selinux-refpolicy+bounces-10-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="selinux-refpolicy+bounces-10-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43e10810e93si78249261cf.468.2024.05.15.00.30.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 00:30:14 -0700 (PDT) Received-SPF: pass (google.com: domain of selinux-refpolicy+bounces-10-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=@quicinc.com header.s=qcppdkim1 header.b="LP8qY/gu"; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of selinux-refpolicy+bounces-10-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="selinux-refpolicy+bounces-10-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com 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 062111C20A83 for ; Wed, 15 May 2024 07:30:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D91041C84; Wed, 15 May 2024 07:30:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="LP8qY/gu" X-Original-To: selinux-refpolicy@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41C1743AA2 for ; Wed, 15 May 2024 07:30:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715758211; cv=none; b=cvo+fFzc2QiAYV1dTt9t1wpzz9u3JmevDlKVR70S46GJVSbgGg+PGazf1rAVJ2wkjZ4pWOoyI4YykCavg1usjFvLISgbGjrpN/6kKsJ99s2xyHA5BKRCUm8LMsImosPQdHHc00yBNjXgGb5iGZuHZp9LotuFArpb+6doMBCxkE0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715758211; c=relaxed/simple; bh=9VdDhnfZSyBl5RFvhqD9Hzbnxl7z1aTC50o8yhJ5XCg=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=AxjKDeDRxRMJZ1aU7m/9/NQr2r/mqQCWKQAxZ5dKU23AG+WbJsR4dhIAfeNZqsbw/Pyx/QlD2LDBgl1PkUW3IGCzBYLaYeNKS0frVzUA1ZvEiS05en+BEaK+VcTVGQyWcjWboMKcA/ufCsvy5Vz6Mpl6crgJrLiRkaMAQUPUt+w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=LP8qY/gu; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44F3kVUs004109; Wed, 15 May 2024 07:30:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=R1z7MYUxgRVr0PsMWI6nRm+5ofVp3nDMHURjSGkWHoo=; b=LP 8qY/guyu/yWEzT/5jVffiDi5XwVeDD9f6+LdtaBzIFxq4AihQdgvR01Gvpd8iYW2 x+d9M3yTlQzCIMyxPJVhuXrQTRCHnrwYCmXjPvunjeWJrem4AOXvfHINCbbBlzUo eiOYGe2U0UzF8EyF6P9WSUPNtT3DFt2HQHfiCQYw+Z4Ft6pppGPDkVAXc5qKH27r H1msoH7CCtaysH3YaqHeSG0ed+4wYGmW8O4iRIMOLEJcVF99aeA4xptHPGmWvX4F WSiRMYeoyg6p/cVT63i+eoffVo7dga9FdwSLRtLaNPeYN2NjVkEVl4zZeOvY1YEC 6OWnAn6YKBNR4v0YRW8g== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3y49gdsv9r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 May 2024 07:30:05 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 44F7TtnS005692 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 May 2024 07:29:55 GMT Received: from [10.218.30.62] (10.80.80.8) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 15 May 2024 00:29:52 -0700 Message-ID: <695f447e-b9db-414f-8fa5-1b12b8379c48@quicinc.com> Date: Wed, 15 May 2024 12:59:39 +0530 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: Chris PeBenito , CC: , , References: <20240514072123.11376-1-quic_nakella@quicinc.com> <877cf03e-037d-4708-8ac0-bce5b2caa48a@ieee.org> Content-Language: en-US From: Naga Bhavani Akella In-Reply-To: <877cf03e-037d-4708-8ac0-bce5b2caa48a@ieee.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: cQSpu7vChxQWjWI-UfKbvw8QMbtSf0mb X-Proofpoint-ORIG-GUID: cQSpu7vChxQWjWI-UfKbvw8QMbtSf0mb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-15_03,2024-05-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 impostorscore=0 clxscore=1011 priorityscore=1501 phishscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405150051 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. > 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. - Naga Bhavani Akella