Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp758183lqp; Wed, 22 May 2024 21:13:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXw5IHMfvQ1/JZYCvrviTiuhAOn5GLxAVLQe6063rfHRIVjacEGqMMBi61qsIZhNKKEC1hjRvPAiCipfClcKsSJE8ni8N19AtZrNSijHg== X-Google-Smtp-Source: AGHT+IG+8BbqTcN4u03L5Fi1zBxqkLQbl2xypGoHV50WmzSAdQ9LYufaTYaZGsOgbM50T5gsB96L X-Received: by 2002:a05:6a21:3417:b0:1af:a6bb:45c5 with SMTP id adf61e73a8af0-1b1f8a06af4mr4224005637.30.1716437620044; Wed, 22 May 2024 21:13:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716437620; cv=pass; d=google.com; s=arc-20160816; b=XgmYuuY8v20MtTpSf+KwHaJz/LlsWPVIq2nrIMJrHabzSd3blXyKtI/T7iq4Rkt7xt SBFQsP+lDpojjYkxCS/Bz7N3asqTPmiAK8hArIoZ7BlDu/wS2l9ru5O1CLIJia0lWghV ULnenMtVuVwxc7gxm7mj6gl0FJSx+/Nr4vIcLdHOkJ8WIE4B4dbMQdO5FfEOK27FSFDm xiCzl42xzk5i27LIy2rE7MtaYFt59cPPOG+lKkNOQyB9smVipOeqR8qw5C9gWHDOQB81 bE7ysIj8asFpunxUg/mLdYJD1IsOOgXT0kkfESvDZpG4gZvDTcsxf9mDwn5FEqpVBuxy Gs8Q== 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=KbreB3X5w5PX89R/JhNeRPZtSm6GfztEz9WxktC6eQ0=; b=vfTup/pPUCcjaCVGXi2eeruzE3MAdNafazGbWrkgo58CKLTGjMGfoDV1Fbgq+E4Hxk CfTEZV6UkSq4tpIprGSmUChUPt/pCtMpUXJO4gSLPFwlCdMy33Le3FSdLWKMoPkK1ldP nxw0g9YQIf8IAMbVtuGPH0ZS469IguOi3lM1b74YjGUNfpZU0BWUW6MGIXUaoVtrbcQe CG5153azSyN8Z5r6onIBy29NSQp+vqyB1d3V6QSpX1FhE2GOqbfcuDDYXFv6DMs8sEiD WPNnXbnzShj9v0JBx8gaRrhYSx8r1tMZMzEk+xWSyA8aa5MFH4OXZP9aieCQxev5TQi0 czhg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=j1jCIgy4; 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-20-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="selinux-refpolicy+bounces-20-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 d9443c01a7336-1f309035f4dsi51898885ad.74.2024.05.22.21.13.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 21:13:40 -0700 (PDT) Received-SPF: pass (google.com: domain of selinux-refpolicy+bounces-20-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=j1jCIgy4; 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-20-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="selinux-refpolicy+bounces-20-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 79798282B3F for ; Thu, 23 May 2024 04:13:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52AAA21362; Thu, 23 May 2024 04:13:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="j1jCIgy4" 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 B4F9F1F5E6 for ; Thu, 23 May 2024 04:13:35 +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=1716437617; cv=none; b=YdtVn4nOoUly6ilN8DdVSIEPxH+M3jdWwQ2Xtp5TllZGkn1ys8gMzZWsS0nAumo44EOhJDgzxum3rCxcXrs/oA+Nmgvl3uqYx3jomgVNaqso+aig7VbuMfQA3gJ6p1lpeG2CBpIxlOkjjCY/pv71pPsiX4KANy47IZeW4cHfA5o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716437617; c=relaxed/simple; bh=y1yeO4wU3N6j8W2IujkYei4L5Ono7242K5JFDw6qOu8=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=C85cH1X1nnZ9Nht7lHiYq03Li4vE3B5d/dR8cKxtt5G8NqTVN4rBMaoRzPZPtavqGMedpFHV+ILJUpIHLvh3k+yrwluGs/vZUgJP4BuJ5OQ1rXJJ2LxKHxXXLpIJCXcA2vJprhZigVa/zgu6eIdwA0asLPbkff7qyvjbbXRNOME= 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=j1jCIgy4; 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 (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44N1OH3o014011 for ; Thu, 23 May 2024 04:13:35 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=j1 jCIgy4XQ1hHDfmtYtC9dfUmVvIXnNIhAvabKii1PGZScyIhMkEJUmM/8AxdHd4z1 GfATNCVme1DlIaPC5lHixGk89WpmGgkFViGOLNFHdyTASmCeGNg3tKQVTlbcEebh CKbRqjIB5kjKv5IhMFM/ggmPXAPF1IMlONcxi+Xq7/odwpqKtqio+PNdId/BFr55 5gi0T2IFhvuPZ+oiwYF53AY9BsE7u8nn1wL8kx9wFiusnilpvmWNcMLVgMMPz9Il 3VKU4nVAtNhoIWj6tqu48MH6cSFAjUrktJwdaffRkgaMAD4xkoNjwKxnTYbpnyxX J9+dGUOOkQbjNXCoU4sg== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3y6psnjjj1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 23 May 2024 04:13:34 +0000 (GMT) Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 44N4DXrK022197 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 23 May 2024 04:13:33 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; Wed, 22 May 2024 21:13:31 -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: Thu, 23 May 2024 09:43:14 +0530 Message-ID: <20240523041314.21998-1-quic_nakella@quicinc.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: selinux-refpolicy@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain 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: L07L8ZiBR515x3us7VeqlINvLbAB_bKy X-Proofpoint-ORIG-GUID: L07L8ZiBR515x3us7VeqlINvLbAB_bKy 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-23_02,2024-05-22_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 phishscore=0 impostorscore=0 adultscore=0 mlxlogscore=957 clxscore=1015 priorityscore=1501 suspectscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405230027 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(` --