Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp159452lqp; Tue, 21 May 2024 23:46:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXierRQ3SBmvEsAc+jn3F/HxsHX4xqWB/negpfNTKksPRYaAkwqjELAaZB8zIXmGqVMV1TSdS1bGrg2GEBD/T/8w8k8/VEmqfYSIfHNMg== X-Google-Smtp-Source: AGHT+IGQ+jREfI74YjEkex7FR68zmPbep7XnBXEJsfxVsG1M2EETyi1fWyUvjzNhpbQcUKw+sS4s X-Received: by 2002:a05:6a00:992:b0:6ed:e1c:1035 with SMTP id d2e1a72fcca58-6f6d61e2f79mr1104664b3a.28.1716360400884; Tue, 21 May 2024 23:46:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716360400; cv=pass; d=google.com; s=arc-20160816; b=uQ5OZ4pwa8Ho21Z7HRL140n00NCCYZqh5c3ehgW9vmh/XzMf/kYlHbOrwqreTE4cwF /3LZ2eulPWX/gCnCZmxNfffp/KGZZeOE340go3iHsJryDX5AAX8zU0j/CAqkQ0KfEOx2 htr50ndimzqMD2PQz5MMZ5jv9M9m05Fm8VAIbXOS2t4r7gyCius4qJ/f39Zk5h0Z+qIk rtPT5tw5z/vDCWAbnMRQ3TvlNhHHSJW1XeWPTPQ1ciXyIB2Si64yaSUt93V9s4rEyrYK 5xhjwKkNr6NUh26vz9GjA6eMm/nL5N8N/UkqMPjipjEXEZn1Kbs1mwwYAPLPQrSp4Ww2 F9Tg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from:dkim-signature; bh=XWRkozx8TCowux1NoIf+27F4uip+VIohfG9luFthSLU=; fh=g2HXUed9xQkao+U7zso5pVvK8gbD6N30k1Drf5atVTo=; b=rdFkm2tTAy/HfeK49nzyMJY+fLRPli3QFVB7FiIvHiN3G+U7yoZKeauUg648z9XMMy dn8SvEOhaX7biMobFT2GFRLSoyUa92/5ot1zhJ1AfuPBmwZl77kVYCJb3Kvmrzmi+JQa jEWTfb8AONlDjK6wtlZ3e1wfFx03XKMeMOHKkXDvT94PbTV/Lc6PxKR9k0wvxxfZglEw +iB15x82TsVFopEOF2GNvRSXiHNm0QSTN3tZOP8sMiYOoqzvT5iSdjRKgzRysk2/PNID P8sIqF0daR7tJAtExeGPyMQZwy+enHUZ0CacWRjB9X9Z6aRjUrbD+ioOYrYL5fVvGdmF BEyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=QTaHRZmv; 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 linux-bluetooth+bounces-4854-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4854-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2aee614si6061905b3a.204.2024.05.21.23.46.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 23:46:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4854-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=QTaHRZmv; 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 linux-bluetooth+bounces-4854-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4854-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CD9D62826B2 for ; Wed, 22 May 2024 06:46:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8075033080; Wed, 22 May 2024 06:46:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="QTaHRZmv" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 6AE084C62 for ; Wed, 22 May 2024 06:46:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716360394; cv=none; b=RIhgx+w8DUAvt6jufUFyNeuGrMMh5kXHZSDkoyRyGEdmLU+kEYx+/Ra6pv4HB3ip6djIMjG859zx6w9R8HNdvnQLlsYvaAHYA6h1pptjKiOnq/K1d/TyKVVNs2JeV3AOPJOpVUxodMkjiTfw0XkP08AYyFCeCRuQSR1zvl0sWjU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716360394; c=relaxed/simple; bh=y1yeO4wU3N6j8W2IujkYei4L5Ono7242K5JFDw6qOu8=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=QiW9c7T9HjJGXgU4QNEmCE9YFsZcB7eNbMDobxTMdUWrcOXenR9baMLhfFj8S7aaB6G7X77xXw4818JFCoN5LVDCCobHT+Tt8v9kcKsWsm81uM8S+V1POFCt9fxPCWsyRTPFBWcoIwCfUb1WJZdBaBhWBcNdgwfQswgO5/RL71E= 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=QTaHRZmv; arc=none smtp.client-ip=205.220.180.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 (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44LMkbjX013663 for ; Wed, 22 May 2024 06:46:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version:content-type; s= qcppdkim1; bh=XWRkozx8TCowux1NoIf+27F4uip+VIohfG9luFthSLU=; b=QT aHRZmvBQloR7BNa/VL4eG447FMetee2xCTRXls8LdS2Nc0yaqsKrSnKGq3jbFD7v dLMaco9nvoKJQRT5FEBLeRy4ukhXDADsdsXJ3qSL/P8i0MdjP5DUMjMM/5S/l5Cy e+uMhfDj0V1S0iL49m8vPS7Hu89w1RtmchAu/OWepQ9CZAsqg+gGRo1Abvtsh8EV u8IZfnF0gZyNblxh1lhPFuHYxYWwn6KU1SI7PQPxFJm0Xlym0qs52oXXWyzc/d+6 NT7g3ShKRfuvTNW4N2YmeQ4ttZeztwDHm16jxPhC6XD9q6MxIEAcQ/p2q8ZqsBcB BwWT3ar0so45kZBu0ZPw== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3y6n4p8kjq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 May 2024 06:46:31 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 44M6kUDA022032 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 May 2024 06:46:30 GMT Received: from hu-nakella-hyd.qualcomm.com (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; Tue, 21 May 2024 23:46:28 -0700 From: Naga Bhavani Akella To: CC: , , , Naga Bhavani Akella Subject: [PATCH v3] Adding Sepolicy rules to allow bluetoothctl and dbus-daemon to access unix stream sockets. Date: Wed, 22 May 2024 12:15:04 +0530 Message-ID: <20240522064504.7560-1-quic_nakella@quicinc.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) 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-ORIG-GUID: fxcVEamIA8-50S2-yKPxozRGa2dA-oA0 X-Proofpoint-GUID: fxcVEamIA8-50S2-yKPxozRGa2dA-oA0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-22_03,2024-05-21_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 spamscore=0 impostorscore=0 clxscore=1015 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405220048 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/apps/pulseaudio.te | 2 +- policy/modules/services/bluetooth.if | 23 +++++++++++++++++++++++ policy/modules/services/dbus.te | 2 +- policy/modules/services/obex.te | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/policy/modules/apps/pulseaudio.te b/policy/modules/apps/pulseaudio.te index 65b9a7428..42ed3a1d2 100644 --- a/policy/modules/apps/pulseaudio.te +++ b/policy/modules/apps/pulseaudio.te @@ -193,7 +193,7 @@ optional_policy(` ') optional_policy(` - bluetooth_stream_connect(pulseaudio_t) + bluetooth_use(pulseaudio_t) ') optional_policy(` diff --git a/policy/modules/services/bluetooth.if b/policy/modules/services/bluetooth.if index c7e1c3f14..edead1fa1 100644 --- a/policy/modules/services/bluetooth.if +++ b/policy/modules/services/bluetooth.if @@ -85,6 +85,29 @@ interface(`bluetooth_stream_connect',` stream_connect_pattern($1, bluetooth_runtime_t, bluetooth_runtime_t, bluetooth_t) ') +##################################### +## +## Connect to bluetooth over a unix domain +## stream socket. +## +## +## +## Domain allowed access. +## +## +# +interface(`bluetooth_use',` + gen_require(` + type bluetooth_t, bluetooth_runtime_t; + ') + + files_search_runtime($1) + allow $1 bluetooth_t:bluetooth_socket rw_socket_perms; + allow $1 bluetooth_t:unix_stream_socket { connectto rw_socket_perms }; + allow $1 bluetooth_t:fd use; + bluetooth_stream_connect($1); +') + ######################################## ## ## Execute bluetooth in the bluetooth domain. diff --git a/policy/modules/services/dbus.te b/policy/modules/services/dbus.te index 2d1d09d71..855ce86bd 100644 --- a/policy/modules/services/dbus.te +++ b/policy/modules/services/dbus.te @@ -265,7 +265,7 @@ optional_policy(` ') optional_policy(` - bluetooth_stream_connect(system_dbusd_t) + bluetooth_use(system_dbusd_t) ') optional_policy(` diff --git a/policy/modules/services/obex.te b/policy/modules/services/obex.te index 6686edb37..5e2f20578 100644 --- a/policy/modules/services/obex.te +++ b/policy/modules/services/obex.te @@ -31,7 +31,7 @@ miscfiles_read_localization(obex_t) userdom_search_user_home_content(obex_t) optional_policy(` - bluetooth_stream_connect(obex_t) + bluetooth_use(obex_t) ') optional_policy(` --