Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1900107lqb; Mon, 27 May 2024 00:50:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWT4bneySVkbXiZeKHpNkUnAuAbjnW8LiMGzT0TJfKh2KX1uXaAZx2nO670v1Xyng9xWbs5qvTQ7Q9hKMBT0gjbAbEBmuDjidp6njvUvw== X-Google-Smtp-Source: AGHT+IHVat4p9u5AOueflE1BhIkPIW/D4q4gec68qYgyiMpvRuUbVZpzmMzbkaOAFljuWFCXreLs X-Received: by 2002:a17:907:940b:b0:a62:cf3b:77ad with SMTP id a640c23a62f3a-a62cf3b7972mr486759566b.49.1716796214658; Mon, 27 May 2024 00:50:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716796214; cv=pass; d=google.com; s=arc-20160816; b=N5I6GahYOkf9FGqCS8Ka87YD2fF7j9VJDx6t8greKiUPCoX6/sIMU+pXJGIDBtE39R RTHRY9aVZMLrzpnmmGyisIhRaa9gAcFBCVXp2YTszLbjuqR1zoiSNa76aKBl9SfhMJKG l5aAuRCrNv6pYMjdjLWwkjtKQP8Kv8sYXw8+laxfrcBJ/ifAAT/ZSaZrGIsbVjexqDHx dgIiBcajWHl6JE392oMQrYCiCVGpxwMFwVl7R8PXKnZZoSZKjrgMhMiu4uiOcQlxmeva xQ0MvmNonAHmpNUwnITvIEBnbOaBidjZQbVAtnYskkIveC6eekSLZ+BeiT0IAZUDket7 i12Q== 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=J3Ek5mT/jUFqNjlbhYkh2tt0wS9MIOkArSoXiTpL4Tg=; fh=KbreB3X5w5PX89R/JhNeRPZtSm6GfztEz9WxktC6eQ0=; b=E78JFWuYUvPrFwh5MUlJxikgPDc9RxJZvHtOIy+KPTU1L5EqYP67XR3r9+FN2H9M7R pdw8yKAjzp+1e0i9EVR2YPp8jcPRpizsuurzAkrKyHXVHDHXuenoaYJSA13JdMzqYVrM q6Gs9vv3hpVx83tPP75XFSimuYpuaKjfgHXk8ZhM2SrCM3ILGiZloFJcAnjX+YknxQd1 66pKwE+4eJtMQZ7W0HYD6IQjmyq2c9oETywZk4XfJmgOXJgFR/08OwQqE7RVeGT6SmgV oQpKrCp4IyM+dMN36M8LB64kNlusf6DPDKum3QwUi07oQO1IWlZACCl9BIgnwGM3FycW TBMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=COrwPgfU; 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-22-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="selinux-refpolicy+bounces-22-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cc3755dsi366632266b.456.2024.05.27.00.50.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 00:50:14 -0700 (PDT) Received-SPF: pass (google.com: domain of selinux-refpolicy+bounces-22-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=COrwPgfU; 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-22-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="selinux-refpolicy+bounces-22-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 314FF1F2137D for ; Mon, 27 May 2024 07:50:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 649661A2C2A; Mon, 27 May 2024 07:50:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="COrwPgfU" X-Original-To: selinux-refpolicy@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 59BC5282E1 for ; Mon, 27 May 2024 07:50:08 +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=1716796210; cv=none; b=eZ06OP2PNl+EOkIAyxAz/WmjWyTcTETbGK3UDPWnpR1myv5EDErOAuA6y2umcoHJx6aFhz3EDpon1HR76CBvcZRcd/+mi7NxwCZehTJDX2N1klYZ4Rp9DwVJ6i21odaZSvG83HvghhG0ba02Q1FWb/5/DfeWIc3A3v3iMkEVsIQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716796210; c=relaxed/simple; bh=b7K6x3IhLekiHQdtuglC/BKSzVb7cSna11FkNd80vIE=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=uemC9cuKtcEBxpJ2gZxY66fm04vpV0Q5i8SNogutMQH/vCbUjjXPZOG1V5AsPvbMIpRLN3SBa9CJBFlClz0gc8JnxZuhLGdzcxDRlHoebT3VkM5LEoJ44wH/aHPp0BSCDjDzsmnX5NM0to5jOtvt31fxsRsX4wZLQMaJn1pDzRU= 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=COrwPgfU; 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 (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44R0FqS9003339 for ; Mon, 27 May 2024 07:50:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-type:date:from:message-id:mime-version:subject:to; s= qcppdkim1; bh=J3Ek5mT/jUFqNjlbhYkh2tt0wS9MIOkArSoXiTpL4Tg=; b=CO rwPgfU3DmPv9vO6A84A9ufFiqH3NZKx3IX5qyqxxmktetLc3O0F+IIxI9JmvWxcs FXXki3fRwHZK9N5PnH7pahApIqGSITxybIQouJQxSUApSsSTwUmamueZj4yZrgdg tn4711+UyRcMWtY3KYh90+bFhYDiW19f9WJpPjXJJ0cZCwFKZDzL6k1biD/v5dk8 fHYfqWGhFmt9JNZWTJAZMXKVK04Cas/LEFKKUohgZTinIHdNVuaZ9AFQuSaW49Qb 3O1iSVuQE6ofYXCTqGwnVPqldrvJ4MsisxzCrZ+nqHyLq2k17sTHdAHYjmBXaHwF 1fKVLbMgb62jXULLFbMw== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ybadx2vpd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 May 2024 07:50:06 +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 44R7o5mV020924 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 May 2024 07:50:05 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; Mon, 27 May 2024 00:50:03 -0700 From: Naga Bhavani Akella To: CC: , , , Naga Bhavani Akella Subject: [PATCH v4] Adding Sepolicy rules to allow bluetoothctl and dbus-daemon to access unix stream sockets. Date: Mon, 27 May 2024 13:19:45 +0530 Message-ID: <20240527074945.24168-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: 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: apg5naxtmXNf--1ZH6070Cv_3aTj6l_u X-Proofpoint-GUID: apg5naxtmXNf--1ZH6070Cv_3aTj6l_u 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-26_09,2024-05-24_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 impostorscore=0 bulkscore=0 mlxlogscore=941 malwarescore=0 priorityscore=1501 mlxscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2405270063 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(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 2. 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 | 24 ++++++++++++++++++++++++ policy/modules/services/dbus.te | 2 +- policy/modules/services/obex.te | 2 +- 4 files changed, 27 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..b21dac021 100644 --- a/policy/modules/services/bluetooth.if +++ b/policy/modules/services/bluetooth.if @@ -85,6 +85,30 @@ 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. The socket can be used +## for read and write. +## +## +## +## 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 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(` --