From patchwork Wed Dec 4 12:28:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 847418 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2062.outbound.protection.outlook.com [40.107.20.62]) (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 6DAA81B87CA for ; Wed, 4 Dec 2024 12:29:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733315346; cv=fail; b=Oc2FTR8nOrHNLHvtdZIuSEG7EBvJmlrS7CsS1BXMPWz+FOz5AhhhimUUw0moPBo1HO37GZv0DMtNvrakd2j3v5nvZYdnHqKQFruIHN2WA1allDdjQ/Wd8LWGC1qzpg/yCs0WcPi6Hx5ZdMoZ0meajO+kqo1baTMrjX5wE3n1kUY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733315346; c=relaxed/simple; bh=cKbokvH51FNUj9okWUSFuvKSlhEIkSxZHstPCZ02+fk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=ajlUZ+IG4q/T1k70KJv0sfCqNgY13YXQBjVc8Ot/jkLJm8zZbj42EL4hRCWZXu+eVsuQ3V2ceSYdWd5nJBlLKcIb9L70HOSowttyuVwOqWjBUVwOE56lYgGebx9ACr52kGgZxJKBN4dnioK/9tIhQwKuod+bfVCOU1dANG8dVVg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=IZa3SePQ; arc=fail smtp.client-ip=40.107.20.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="IZa3SePQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Fx4elqvMUwKjOsYowypI4RLf8sF9jQHJde+QRoApWPCpXup4vjI0AudQnD2pTauM9EDjpDAGaM3uUHqC+jgF/q2pZ1GvEDEL2UQkxdfFBNfwZpp8meIhcSgObfdQtZutnIHsGNYS3l7fWOfhekSVWjozJ9B4j6O3SGX2OssKqwiwgTSMgum/sRaysWGmJAZTCAn1BnNS1slubB1Rq3ZGImdHyfhg+dXJ+rvopKGzEb6rP3GD4OHGlQx8YkQllgIylePnRYHWb0RdjG2ppMj1Iqr0AmlVCkjSjCckPcldoTr9sUbmglDixfrNDW4ZA4YalFGIbywe7Cft578H9+9RCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lKptTudsUtBI84oRe1+J3Txb0cIv4hLrhSdOBdflye4=; b=L67SPKV/8nW2OHsNF9xT/drNCWN8P8LlpqQjYfVW7uhTdOBFiXYwXKMNYk7dj1zxvaFObL1ojuIYaYdy9cJ0ED8MCV3WHeY65tfnYiiwGuOtIOcAS5YevflXQdNd2FT27uxiYvX15I9E7y0VgfRQt3B58sgfqGikfKw34+aIJmGlH+ERPy3aAPjWYve8BimSeuf6SxnqeqfC0QD1KgVEg2/ocahiaNY7t2CY8PdAzovNqRhECjSNjhA8btuRjpi4Qxp8j1G0LkVabgC6Ir5s3DSWcsiFFnTMaG6Y672K/7ftw+e2rDjgt0HIAxP/I8QMILhFOFEhpN++ghM2xiu/HA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lKptTudsUtBI84oRe1+J3Txb0cIv4hLrhSdOBdflye4=; b=IZa3SePQmYVe0IkWYmMdKGMOWllzJxHsb4eI+/RL8xrdrBFCDUXH38kvCJouNC4487FHZuqp5ZvG1Pqur5XYjvSqjdSWZsTSuJy63/HICrc3z8yJ2izsSFSG/LL9Zy6ZStGqEjcIkmgRV7Dbg8JFENxQm1W8fnnMMsg38wxTFtZJP6u618EEeKXV/fA9vVZGTrOWggaSr5GFsNT2U2ow/6tib6DWXlbM4SfGHCbTNCApSnSClLevCotEBIYOO1XAOcp+j+jWZzrQa3ckViPiFMQ82MK0nexexR5ZdUMBNcXmxZElgdjSSyau6wD1rHSVIP4PoD1uKycmr+QKgC15XQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by DBAPR04MB7431.eurprd04.prod.outlook.com (2603:10a6:10:1a1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Wed, 4 Dec 2024 12:28:59 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8230.008; Wed, 4 Dec 2024 12:28:59 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH 1/3] Bluetooth: iso: Fix circular locking dependency warnings Date: Wed, 4 Dec 2024 14:28:47 +0200 Message-ID: <20241204122849.9000-2-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241204122849.9000-1-iulia.tanasescu@nxp.com> References: <20241204122849.9000-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P191CA0033.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:657::20) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|DBAPR04MB7431:EE_ X-MS-Office365-Filtering-Correlation-Id: c70cde51-0a41-4f61-c1b4-08dd145f3ab2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: 9NTz6BMIoZSpDHpA6g4Cvygo9qKSXGipQoGU5beGfBZvm5s04da7PgiissiHmf9HHcdlQE9wrlfFOksaGUkzT/mOvyhWciEWmNqcAzjKSqt5215Q2TXcp/tJH1TOc0sg1RcXbAu/Ayfbae+p0LTsj2IYWbUQ/bpj7+r7kjUVE/oK6+FmOH+/iZsA5srgLE6mdV0IalRaKe/Fi03e6b1rJsSm+skBO1QEYjW1wrMKFizZFJNJOi5zmhZG/+wX4YWPi7UDtHOn/yhnPSntG/vfS/Ra+L29iVtVUEZlSFMZDvYfIZT3SW3Z0HZ4Ivf+Z9LdYhcOK0TnBTj4tUOJpZJKuFsIZF6G/s+P2diDTvZw6Jy8CXWdq6YhHIhfAcx8rFPPvTHPVLnAIc+LbGe6VfG8f/lHuceleuLypCIVsX4RXb2Nwqp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)(1800799024)(376014)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nmxlUe384f5sCsPuRaPSQzW5aMxBzPuMyqwn6OsJcaMoTEsesYfdhCBvYYV9xTtnKw6JKS8ZGaUWmDJOkO01mrSnaD8kJB4Ics28Mjbva+Y0Hpm6vpk9y5882dnvWj1t73Rg6i6Ve7c/9/zoDnHHdStDxRWA1dArr/Ri46hQxQGbPV9CngTEqGeD7v+0FqalGj0S1d0R5vsQf0sTI+HXd7PawlYK/HIQH8qxtElHDEFmOegCnf9sCi7iTf1G08odiKUMYtYJeJcewCHNgO/Et1VAXLb5buM2JLUezySq8aTutcNQhHWDZkB2szfpw7l6HvbpLzXAsx+5VrdTChtK8jGc83NDI98ZSaBsgPDhnzPnkgp/VhgfC4d2DDIuIHFNMyCUU/qIColUr6f9q7mY+4fdXt574//VVxaildyW2GDPpW9EdKdDVhR3YArbOQZK5vzviRLujc63hB12+rrqZE8luyfKZEANo/ZeYFIq8RXCZbpmP5rnCKHl8f2Vti0Q/pgYad6HECvGkvdQVmyegVy2AzlBTaV+M4kRKVDhm9vB0ic8Amgu7+tP+4GjSOIon+XU8B++xmKHcUtq/YoMF4k2EFFzwDbMiNkQfQK0Hrq2rkOmOd0JbQsZmKWLiy7QqemQCD0OcX164AV5Z8E39cY4JKxDifOBQJN+AFHgRzUFNlDY12pnIKGwsepG+diNpxOSNw1kc+4RrYL6EGdoau3aijOvQjAo7MeGnPZNrjp1ldphtKQng4r3D60dGfRf3iMblGUF43McXCN+eo1YNHSM2TrYYUK0NDolLC6LuYj6UjHZrRnNPM9TebnBabfuHo10TL10+mIjyb76QB4zey+11BvgvmPghoQ1T2pPE8Kz0wcdJ0E1ndOavJ+qDq8xhhEzLJ3d+L7mcmSyo0ztpaV1f27cvSKFT5JlcjM4b8TUJw1mVO40L3cktJ54zx7bb+VtQHjJN9QhwPmjZaGqz1RdEU9Ej+w0Ckj7s4eUb4YPaTbge5WL9l15Z+28HZB4gFh70uSnIpgA0J8mFyHD/RcNLDIv0Ktc/95F0dVGgyE6LYnnAGEIvUqm5h25Jfnh62JJvvetlNcS/azXP9L2iHDMMZY7zbqiNsDSbg04ZTJHedxLbGmGi1JAuQswGvdnLfXxgKWlYvCERiO7veYZ5nDpRTnHMkGdAJlEp4Wjp+lJ6Fv5a2fBjT9FT7O7RKhR8NH9MO4FzR4EJ8ArY3J86BCwxCD0TujgAmzabLcPa2vLsKhTlXpmHy5u66HI+hckHFgPCawRaj7VhRjR6FJFiez74o9lb8pW+tbOeeuWU4uwsrJpxfdNW7qUjQuOyNmSsOrDEIyMqUw1gXzP8+CtwnfxQhCF8sDP5KhtDAW3TaFsT6E9THntlOvoGpZY71pelI/MxCbyoc2QYYqX/4Lym9FkSaNk87lVf+oUqFjgbtvKGXMRRB3AW41BIC5zU70sYsy/AvidQCI9B3qtnH7YZEXbHCgJhLMAVZbBZhQuR3eLSuOGKr4x0Gqm2/SObLcK6E86y/JcAKQYudqSlnorPCW1qdzbSNAoxOFCgYEDxP5ijN7pfHpofhHVX7H/9nRxAVWyk6CU8iIuHmjYuT93Rw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c70cde51-0a41-4f61-c1b4-08dd145f3ab2 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2024 12:28:59.7391 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: R47foIdyuYtoyLoJKk8+U36uA5ECxavMDpBq5HHuF94TCY36Fo+w0BPQ33RbUi8t75D0ODFj/y1Y5y6kzJJ8vA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7431 This fixes circular locking dependency warnings, by ensuring the hci_dev_lock -> lock_sk order for all ISO functions. Below is an example of a warning generated because of locking dependencies: [ 75.307983] ====================================================== [ 75.307984] WARNING: possible circular locking dependency detected [ 75.307985] 6.12.0-rc6+ #22 Not tainted [ 75.307987] ------------------------------------------------------ [ 75.307987] kworker/u81:2/2623 is trying to acquire lock: [ 75.307988] ffff8fde1769da58 (sk_lock-AF_BLUETOOTH-BTPROTO_ISO) at: iso_connect_cfm+0x253/0x840 [bluetooth] [ 75.308021] but task is already holding lock: [ 75.308022] ffff8fdd61a10078 (&hdev->lock) at: hci_le_per_adv_report_evt+0x47/0x2f0 [bluetooth] [ 75.308053] which lock already depends on the new lock. [ 75.308054] the existing dependency chain (in reverse order) is: [ 75.308055] -> #1 (&hdev->lock){+.+.}-{3:3}: [ 75.308057] __mutex_lock+0xad/0xc50 [ 75.308061] mutex_lock_nested+0x1b/0x30 [ 75.308063] iso_sock_listen+0x143/0x5c0 [bluetooth] [ 75.308085] __sys_listen_socket+0x49/0x60 [ 75.308088] __x64_sys_listen+0x4c/0x90 [ 75.308090] x64_sys_call+0x2517/0x25f0 [ 75.308092] do_syscall_64+0x87/0x150 [ 75.308095] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 75.308098] -> #0 (sk_lock-AF_BLUETOOTH-BTPROTO_ISO){+.+.}-{0:0}: [ 75.308100] __lock_acquire+0x155e/0x25f0 [ 75.308103] lock_acquire+0xc9/0x300 [ 75.308105] lock_sock_nested+0x32/0x90 [ 75.308107] iso_connect_cfm+0x253/0x840 [bluetooth] [ 75.308128] hci_connect_cfm+0x6c/0x190 [bluetooth] [ 75.308155] hci_le_per_adv_report_evt+0x27b/0x2f0 [bluetooth] [ 75.308180] hci_le_meta_evt+0xe7/0x200 [bluetooth] [ 75.308206] hci_event_packet+0x21f/0x5c0 [bluetooth] [ 75.308230] hci_rx_work+0x3ae/0xb10 [bluetooth] [ 75.308254] process_one_work+0x212/0x740 [ 75.308256] worker_thread+0x1bd/0x3a0 [ 75.308258] kthread+0xe4/0x120 [ 75.308259] ret_from_fork+0x44/0x70 [ 75.308261] ret_from_fork_asm+0x1a/0x30 [ 75.308263] other info that might help us debug this: [ 75.308264] Possible unsafe locking scenario: [ 75.308264] CPU0 CPU1 [ 75.308265] ---- ---- [ 75.308265] lock(&hdev->lock); [ 75.308267] lock(sk_lock- AF_BLUETOOTH-BTPROTO_ISO); [ 75.308268] lock(&hdev->lock); [ 75.308269] lock(sk_lock-AF_BLUETOOTH-BTPROTO_ISO); [ 75.308270] *** DEADLOCK *** [ 75.308271] 4 locks held by kworker/u81:2/2623: [ 75.308272] #0: ffff8fdd66e52148 ((wq_completion)hci0#2){+.+.}-{0:0}, at: process_one_work+0x443/0x740 [ 75.308276] #1: ffffafb488b7fe48 ((work_completion)(&hdev->rx_work)), at: process_one_work+0x1ce/0x740 [ 75.308280] #2: ffff8fdd61a10078 (&hdev->lock){+.+.}-{3:3} at: hci_le_per_adv_report_evt+0x47/0x2f0 [bluetooth] [ 75.308304] #3: ffffffffb6ba4900 (rcu_read_lock){....}-{1:2}, at: hci_connect_cfm+0x29/0x190 [bluetooth] Signed-off-by: Iulia Tanasescu --- net/bluetooth/iso.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c index 8ed818254dc8..cb004b678d65 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -1102,6 +1102,7 @@ static int iso_sock_connect(struct socket *sock, struct sockaddr *addr, return err; } +/* This function requires the caller to hold sk lock */ static int iso_listen_bis(struct sock *sk) { struct hci_dev *hdev; @@ -1128,7 +1129,15 @@ static int iso_listen_bis(struct sock *sk) if (!hdev) return -EHOSTUNREACH; + /* Prevent sk from being freed whilst unlocked */ + sock_hold(sk); + + /* To avoid circular locking dependencies, + * hdev should be locked first before sk. + */ + release_sock(sk); hci_dev_lock(hdev); + lock_sock(sk); /* Fail if user set invalid QoS */ if (iso_pi(sk)->qos_user_set && !check_bcast_qos(&iso_pi(sk)->qos)) { @@ -1161,7 +1170,13 @@ static int iso_listen_bis(struct sock *sk) hci_dev_put(hdev); unlock: + /* Unlock order should be in reverse from lock order. */ + release_sock(sk); hci_dev_unlock(hdev); + lock_sock(sk); + + sock_put(sk); + return err; } @@ -1417,6 +1432,7 @@ static void iso_conn_defer_accept(struct hci_conn *conn) hci_send_cmd(hdev, HCI_OP_LE_ACCEPT_CIS, sizeof(cp), &cp); } +/* This function requires the caller to hold sk lock */ static void iso_conn_big_sync(struct sock *sk) { int err; @@ -1428,6 +1444,14 @@ static void iso_conn_big_sync(struct sock *sk) if (!hdev) return; + /* Prevent sk from being freed whilst unlocked */ + sock_hold(sk); + + /* To avoid circular locking dependencies, hdev should be + * locked first before sk. + */ + release_sock(sk); + /* hci_le_big_create_sync requires hdev lock to be held, since * it enqueues the HCI LE BIG Create Sync command via * hci_cmd_sync_queue_once, which checks hdev flags that might @@ -1435,6 +1459,8 @@ static void iso_conn_big_sync(struct sock *sk) */ hci_dev_lock(hdev); + lock_sock(sk); + if (!test_and_set_bit(BT_SK_BIG_SYNC, &iso_pi(sk)->flags)) { err = hci_le_big_create_sync(hdev, iso_pi(sk)->conn->hcon, &iso_pi(sk)->qos, @@ -1446,7 +1472,12 @@ static void iso_conn_big_sync(struct sock *sk) err); } + /* Unlock order should be in reverse from lock order. */ + release_sock(sk); hci_dev_unlock(hdev); + lock_sock(sk); + + sock_put(sk); } static int iso_sock_recvmsg(struct socket *sock, struct msghdr *msg, From patchwork Wed Dec 4 12:28:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 847646 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2062.outbound.protection.outlook.com [40.107.20.62]) (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 EB3521B87EE for ; Wed, 4 Dec 2024 12:29:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733315348; cv=fail; b=SaAYXcK+5z5mKnuhiIMDFJ9tcQOMKtAN7eVldnVhcuekEYsdUFsie3LW6GLZ+t97RmSkgNommO/Yc2GOBLJVGJm8fBpLoP4ypQOeK/Cvd48Mv7mLrv1Q/7X4QuDGe4wA0MnDip/frQI8HB9Jf7p+TCFrdHlVjZGjnS89lzeFOuk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733315348; c=relaxed/simple; bh=xulDf6KkoDyIuhMIJb32+CdTtEy2VX5BODZhivQXppQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Rn326um2jhbGCtE8ykD4VCCrVECzS6OMUlIJoGKO8qBjYpFsCddmxZBAIKJKcWi82y7L5pcsedDrrxLlK8S1jZy8I6W0r16cttN83IoLfOnl7ERArEqEYaU6sonTgYNTc50mj4FSOFN+2mnRABspoYtxIRS8rQs39T6drWzKa0I= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=kCmlz1YB; arc=fail smtp.client-ip=40.107.20.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="kCmlz1YB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oVZEXfSofSlv07nVmUAGHMmT2d8Vm87azZ4V9mVH9DI8kPgyJqkWk9QXfO1mOc44YZbSPkCYkrCbyJx67wWBUyGUNwR3JnJDZlP20ueUeIKwnIiqDSwJUReH/COwpcmksEQn/98BV/jb0MJW9HQMG+SpoSRjU9o34gF8BUbNkmfwoK0iIhMYiyy+PYGNcrb1VSlOWcF0XAJSzbIQpi4Qn0AuIwOXBopKkX07lg6cMLD1CNnzEI4qzzpJgN046gU2f5Ojea2A5Dopm12X9d+6x1qzO+y1T8p4u/Da05+CRokZrKlPsx7MlJZyaJxM+vl+6PMAiirkgT8RUe+HLL5vow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5WgwJD9I4tM20m0QPM+aPwj+T+FWGadm9j2m4AN3uJM=; b=kxFJRnneQKe6qkFHoqc8Kw/0AIhLxbSbfc/t7f+xU6o5TIMx+EWuJ5KahDQSUhQ41eOQ8OAkSAgys1XHuhoh8q5MRj9qLvoct1Ub+/6HlAAB/n8KuXReLaWwqTQaYc0hwO/ZdnwL+atMRUAy5oWycecbrL33ubI8ifEPQKZO5fodiM6+ww/TV9vF2oMSo5IMf8+QqKuGHb8NTe0om34ZiAlQTt8FWUU96pq5IAFf8ANjh1ZxYX1iHeDPYmxpmOstXJAD52uJBBV1tmAchMDy0ZtdV6JOqaEkZRTjbWF3TV2ifC/3A7SFxmOBD/PSx7D6fODrlB0nMK+bPISac4fw3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5WgwJD9I4tM20m0QPM+aPwj+T+FWGadm9j2m4AN3uJM=; b=kCmlz1YBhFmcdCOk1/VPIKYx4XogSZc/R7HrpcNjh2CjQIKVmh69Fk5qLWw8awqOSLYwOK1vPM9etR/mX63by6q16KNhhjU0CSSmUjLnfvveYLrrwQgfhb24LrXY7BqWMR8C4TmCe6QOFJjxxCCTIecyIVTi7PvpA+uOAHHF8ni87akIanbBn/0/UELCELc/7SZhNsjo4JZFBFyqiNJpJE/FZoIR0apFnN7kARoyZxfdJ1rUmbrWSX1HaemBV4ttHNvXxqgVNEQ1X6nPeBUTmpSYsZDFBdCdJd2lcKkvmrplCjf3/OJV4ep/qlAxWgAMo6NqFDHYPf90TJ8r5CZfRA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by DBAPR04MB7431.eurprd04.prod.outlook.com (2603:10a6:10:1a1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Wed, 4 Dec 2024 12:29:05 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8230.008; Wed, 4 Dec 2024 12:29:04 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH 2/3] Bluetooth: iso: Always release hdev at the end of iso_listen_bis Date: Wed, 4 Dec 2024 14:28:48 +0200 Message-ID: <20241204122849.9000-3-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241204122849.9000-1-iulia.tanasescu@nxp.com> References: <20241204122849.9000-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P189CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5db::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|DBAPR04MB7431:EE_ X-MS-Office365-Filtering-Correlation-Id: dd9be283-1e0d-46cc-107f-08dd145f3dca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: 9Gl/xA4Lzrdi2S/czjyeV6bimt7zzO37gmdyPFIiGI1fmr8+1enj5//cxcSBLtVWLst11SLsbUh1dG1QXzrpPcKxyhF0hQjUdinOLAnKj00GtyG6Imjt6HmU6KOhORuH16qHkM3m3AZsawPTinSEW50LZl5Jhqz48hQygZPij+pathPdTrgzVQl/bjCuP2m7H6G9xUeolADHIwWlawKcDipH3XPY600jwmZ3xSsYcJYOi84+9gicffkr721TIn1qX4q7rY/fpfaIIw/wJLV6nxsDW5De+PuvIgREdpF8tHe3pJdX2dKpFvLkfgDZC+fV3/52E7jlLdxUa4700CmnxNoL2QmciD3RhC1ctFdyy4jHlkAKbAwCrq+Ezmi7IyQVUkaG0mXquxK/aZEHE0i8hzAagQE1KcHkrmgWEOLTb4UIYVhb0gmdnkiedFikPnHaKiQr4RQNyzB99VpNS2fFQ48KqFQoelMCktsyyWD183Z9WP7Ljd0K2c2lzysnysZzG02mCGMGd0yDwfm/A2mBRFz0O1Cnu+YtvaY9I36UUMMUvweYv5q2KsdJY8GqVkuI7uL2YdV/PCoWi4jEhvDpcVh4e+ZCMk4q6RXEUnc5oqgcWH8VEy+kIa+/rbJzk0UGhl+l3ZPur8PEFdF/plSSFW9TQtvVVNb3pX6aLSpN7+ELYDWZYo9kzK5Ug5oAWuNvAfovEHfMMKsOPGIYJV5mZ2Jvi7yZoZSr0jIxLduPptNxOIvUtBZNim/yCeXecMM5qcMY7quM/YEwIn4FCbn9LXP1CH7xr+ubjI+iRMGJAdftbJSza5KuQzoiv1NiQaYczBX2b8AAFkjYpLGj1SRV8SzQz+DnhIz13tiLX3QSLWfZbqoDHxc6Z6sO6eKt2Pq0/dkzJZT9w/gWR8tS1ubKXFmCccPQN8UShajYKjOdEEC6WQlP5Q743ioPbnpE2mR/DsMMK4zVANMV7SOOcxahyepkkoY+pSA4BVjbkxCiltcmribAWDFZaeA3JvtYzND8K1ptcWcGm9Kn+I4YLZpI3/q832HX0FRtLbIwC7LwI8DeC7SGUoF3sWb1YiLoJHwcYg20gIizzRLu5YyooLaqKI3WO17x0kFrF0DBN8AH1h0DFQZ2CocRuiFN+d6Z1GbFPs58lXKB8Voa8GsF1oEn0ikboyc4DPcZzUMk2n83o2C2X9UbQIcKjqlxcKVaqFWbsZgHPuyhMOEc4VzI+rBxcK4zwxXWStcjJ/z0JnSVttYiUnILYYHLpDKr4VAmGk7tdby1bXYJFXk45IhD5OJ4uNCiWtpJF2UWVGW+yhPlHpnOBOCBm8LrwLuo1i7jMrJEAM0wENAVFW6mK06BJ8Vs7w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lmXswiOJfNbDqa5KpZ3dfVuRVKB2QaR+nrreqc6rBcXlIrUK/ahOUpOCSEAwWGxrxRhaozjw3wCZ7YpU2eGSH/+asZSRlrFsar/LE5lOio/rrICFMT43j+Ct+2sg7Ux6KTFylMRxJS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epktiSsuiqXYc1WvHg77NQXzdJ31hrPM47/vbx4SgC9NqfYgagk8GPxtuf7PAlpSTaBSxCUsicA1NRaC+M+1z7YsCt5jWehgwFnWU4mcHj2Ko/ogSAP0in2VH2XZnuSfKjCV+6T2UZh65r6KcLihf3/8ZDPPy8sjRlX45hM0QS+5X94sBoaU46Cy8wb1WmIs/wYi9w5Q49Zjl1eXDzW80fUthvnAdp1bHmiII1FGnWJANhLuvy/8P7My/o3rR19Mwoz7A2izVZzpLxLI5X7PC5029WU2O10KcNFFoPyLzcT/Hhk7QMpwTZrnfVlnctpNHHvemshU89ZNG2+upkm2M6VCMS5ldJlBiDstorWn6TPag2yX4JdzEwY8eBDATVsnwWi0M6aASut0GSTtw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd9be283-1e0d-46cc-107f-08dd145f3dca X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2024 12:29:04.9065 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WHc88r3nC8sowufGfVOmVp7jq550cSrKTbKLLNj8C+eSDNJL8LV/e8ptS1AuStb4J0BwE9vo17f3Ee1J7nXIUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7431 Since hci_get_route holds the device before returning, the hdev should be released with hci_dev_put at the end of iso_listen_bis even if the function returns with an error. Signed-off-by: Iulia Tanasescu --- net/bluetooth/iso.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c index cb004b678d65..df523a09ca9a 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -1167,14 +1167,14 @@ static int iso_listen_bis(struct sock *sk) goto unlock; } - hci_dev_put(hdev); - unlock: /* Unlock order should be in reverse from lock order. */ release_sock(sk); hci_dev_unlock(hdev); lock_sock(sk); + hci_dev_put(hdev); + sock_put(sk); return err; From patchwork Wed Dec 4 12:28:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 847417 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2085.outbound.protection.outlook.com [40.107.20.85]) (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 798D71B218D for ; Wed, 4 Dec 2024 12:29:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733315359; cv=fail; b=fMkz/LlKG5EawdojbkI8RR9E/+MfpXtjWF2QlJb+VPvIc//iOZhteJn7FthgHXj1KhFrxe1CdeSwX+A0MLsfhUizuSv83dkxrTXrGZMpdxL9BshkfnoIoMF9TZOaWjh64X0yQIOtYFexKm3IkAMHqKSeO97jh5tCXYk6ExEAm3g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733315359; c=relaxed/simple; bh=Fm0O1TFhfd7mqvhZCRYXdsyx6ZYHSr1aTzSQsJnLqqE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=MeiLq1nlVGEZgeaeSi97/RsdZKzKsO40rzXQO5j9Xzdo/JlfPQ4IXc6t+E+0b6DrxFcordTXa7JVy0IrUXsbH0Hds64x6Vf3A6OJN6GppY4cBe8HqVnSHmoPrcICLQcPrJvlx1mIwekno+NgFJ0133p6mD28epGdxmcHpPNPNgg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=aMUBxgG6; arc=fail smtp.client-ip=40.107.20.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="aMUBxgG6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VyF8GDTRTi32NtEgVmG/IiULZrXl9jA3eP23BEeTBUVSdE3+43/d7jevq/R7UcXcOM1akuxnySffKQwKOB/8OxgAXOPT0W05ZhM7puaAA+KTeLu9lkbEi4wTiGNJuoLVhkqfPsrRKS+oP2Y+AbIyNPKA1uhn2+EDgK8IBuFbVk44YDc9ByRFZmnlKI0S7zkTeeyV3L0hT/D8i84wk5gtRJTQdgQJhDSj0Suc0q9B6GX07WBR/ipwnXvWbLUL6fbQn4B19GJYME5YH0cnqSh+6fL/nW/ly2HNAzZ0jY5TuZUfP04rEwJHdxfvLcoKKN6r7BXbhrze9IOshtnd7S4p+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ceQTuQ3LVzADRCH8pv1jQbxGfTAcKlc+P7Ofm9S2lUk=; b=e08lWNFkSz8n+c3IULz8Kik96TSh3PdVF6nJ/VPabOmBLUacxQuHxsXTPF7tvU2MkVau0G34MUPKLaqS3fHoqKh8Jba0OhPqmbamzl9cviyp/a939v5N18teFziRVI6LV5Vq5xHqmnkEhIgBpVDHyv6bR0CPUTO/6EvF1o46xUyBP6Z7LbrQVyOebKLMLD6ORLpc7B6hBCgyNnbhEmpyI6mcp2n4f8ZeQauG22DUQ/bLgvZYVFVYazBFhUoCYSx9/4gSVM+kP7jZc0PVygU7epopEdUCD3x8pVXxnydzkm5dXvDox7qL2FdLuffBNmgMozVcMiS/AjjmwxJUTKto7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ceQTuQ3LVzADRCH8pv1jQbxGfTAcKlc+P7Ofm9S2lUk=; b=aMUBxgG64PtdZ1MxxnGj9ug65bkkEJBSZZ2StZVFPxQRWLGX6ASQbJMKG8koy7MewEO09BJaeY+rr6366cBQhKLz+dubEAPGFBvHk771GVYRikSBtBJoetzrFnEi+bTIYbemNyt4QPzJNdiRjxcXXixrLtzxxYAO/v9+GwsFFT24D+svjdnMHQlifw8Eh+oeLqKaDmLqnuF1DUbWxdkGrPjWU4W+/SLHR+XgXcEuPWqtDCnvsl5GnVgNYpx6mwVv6qXTo4LZzyGrEm1V9bSHGWbRiSKNcFgz9Whqi8DPez/QsKQhu7A9PBDqxYx4b2oeZML/mahzNSlbiGCqKRUGhA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by AS8PR04MB7575.eurprd04.prod.outlook.com (2603:10a6:20b:29c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Wed, 4 Dec 2024 12:29:14 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8230.008; Wed, 4 Dec 2024 12:29:14 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH 3/3] Bluetooth: iso: Fix recursive locking warning Date: Wed, 4 Dec 2024 14:28:49 +0200 Message-ID: <20241204122849.9000-4-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241204122849.9000-1-iulia.tanasescu@nxp.com> References: <20241204122849.9000-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P192CA0044.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:658::8) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|AS8PR04MB7575:EE_ X-MS-Office365-Filtering-Correlation-Id: ec0adcd5-1f6a-4263-6222-08dd145f4399 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: vgIWkBO+lrMXmc8zQxz4jC5exA4gvUkBmlNKWyAfKj1OGlkYA77KSu24NTUmZRoG4ILU5WoXruwvytL6B//PW5JfcPVwjiWRZWWkf0dJ+rppRL/dzhz2ZE0MD1ThCFNpm+IeBVpyU/DGXfJROsugY6JykhBFI1DGJLUAQ3sWeWk4m+yDyLAcZtW1lUAJ7X1DXqL6a9547mWCLCF6o7UNi9HqZzM9HfijsM3qPtEbhHmW0rY2jCol7yd6n74Pt402EWpj7FIkoysikKr7u0SkRE0xnevxB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== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: l7oEBO3cFYryfYcMzdZZmNAYehgCh6q+HL30B740vlg3WLeQ8v7mdi7OcUZOt3Wv5tBFjTCrPtR5yTu9JxhLnKmvEU/UuACnfxUa5IY0EIradHYuyFgbGkIrC559HkC//B5ob3QzpN85DiZHN76R0bXpZilv3y0+BqTCIAR5HDyRF+ofFpPUozaRnt3q2Mbhi864yLoE5P+sT4Dg9DFfNyvi+SavDWPxfLOhnmf/0I2AyzEc47myQlFIYw+NOqgY1wvruweC2C4OIb9+B8cyQ3OcbvI4WOpPZY4MwBUXsERUMjajCvDTbbncc3+vTKjTjDK1y8rjjBOVyn6NhG02BTzd9IOcmhCc2AviJsUCVByNgApDV5NZzZ8YmE77aUrrphKZCnW8pMTz5apSb3Dp2ZcWoU5dqw/XlPUCHJWH7+2D6TwVMlORSjzuXbKqKs28m/9zlIY6yslT/yzdnVEyZUp4q7KTKeCr3TpBMF8maki3PneT+BLWdE7TWBxRInlPGZ6oFla3lyFcEPriN81uSeW1eKwU+LAnE/ZfOhiz1dA4pNCj+O4UHEJAdFhX6mlv8MKFtmNbg4Yx1HfPzRCccbWINQVHaLit6rHghNeOO/35lCy6wPIIyy7ratHSpVgFfykTuXYifsJC1GqxTj0S2pPQzUfh0Nj8KMOWDGtQTL0IHnbz7m9ZWTmUWXpAr2vNv1+msbBxCOJ8pOyzH1OEE3E041e1SCCVeEKln1a9DHWvpnpBFsVvJ5zE10Dg3k6aswR0djJcq1T4GIgZwbJkS5KtPg7HlAtPWSq59I7JBRbnfMSmGVVGE6sZT4AtBhbscXV9+zEaEhIM/8wvzUiV+3mGNVE4hrj2Y52IeX3WHAhwg1VnKSJQ8XV4TmbYWOlbUnxLiXO3zNFdD9+YueOHM3gnIyfN/+MQF8L818PaI9yOirvY7qsRR5j8ZbkEXxUk1lEdb8nlAlbI/Z7LXR2YGBy+3V9iFsXdbTmeU8K+1SNie3/aXvHIBYWKYXyMSgDLXui3GMq26mY+vUegEO/PTVvcG38G82M1X9rLhOAl2eochyVDAMin1CQJKRBiuoInF0J7am1fWRCMH4M5VOyjTB3OvU2l34EoHBQMebcOC0hedcnjdPCcboHzlRt5LMBadd5Zw+xIongKU9n3wyF1z+ChPCx3QPU48eXM+YmeOxrLgy8UI0NVLviHW8doNOz+Ts2Aj3Lp+RZz8z9HOJE/qKwgGqNYrOOZEe55up09MecmR/Nv/Sy05N6L26J6kpGGfGtyBRO+fuAEMVuIUEsLYX4RsLqwfNRuATkJ0A0TeUcOdir2ayhaSpnwlkb6dj36SHpLSwxHJ6zaL/6Z59WmnZROo4Ijlw7myUsyXMAMOALB5ayOCBIzglIi55Loy5xnUq0try4kV8RLYiPfzIZG21lj2XFc5Nrj+VLjbnuXkiVe8G/3UBXKqD43+AfiJHqSZFUfHuxQHxZhl3Mlohn3kE98z/DWX0+QCLee9O0FQpAOhrrjYL0pkmbVhEhl6x222CPdFS9FF9xLgMBI6HikZFC13pT7MqJaJ00AiVno3o5Z0N1qOfXRfw6DPVsikGrixOAaEeR+4v3I3HXJnR5XVA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec0adcd5-1f6a-4263-6222-08dd145f4399 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2024 12:29:14.6295 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5XCajlNVyT+CjRp18m0qaHvNLUkOjVNnvxnBFStwNaXmDp+/RLswLaTWrIJ4LIsvLC7EMgYzaMj3MYHz6ezpxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7575 This updates iso_sock_accept to use nested locking for the parent socket, to avoid lockdep warnings caused because the parent and child sockets are locked by the same thread: [ 41.585683] ============================================ [ 41.585688] WARNING: possible recursive locking detected [ 41.585694] 6.12.0-rc6+ #22 Not tainted [ 41.585701] -------------------------------------------- [ 41.585705] iso-tester/3139 is trying to acquire lock: [ 41.585711] ffff988b29530a58 (sk_lock-AF_BLUETOOTH) at: bt_accept_dequeue+0xe3/0x280 [bluetooth] [ 41.585905] but task is already holding lock: [ 41.585909] ffff988b29533a58 (sk_lock-AF_BLUETOOTH) at: iso_sock_accept+0x61/0x2d0 [bluetooth] [ 41.586064] other info that might help us debug this: [ 41.586069] Possible unsafe locking scenario: [ 41.586072] CPU0 [ 41.586076] ---- [ 41.586079] lock(sk_lock-AF_BLUETOOTH); [ 41.586086] lock(sk_lock-AF_BLUETOOTH); [ 41.586093] *** DEADLOCK *** [ 41.586097] May be due to missing lock nesting notation [ 41.586101] 1 lock held by iso-tester/3139: [ 41.586107] #0: ffff988b29533a58 (sk_lock-AF_BLUETOOTH) at: iso_sock_accept+0x61/0x2d0 [bluetooth] Signed-off-by: Iulia Tanasescu --- net/bluetooth/iso.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c index df523a09ca9a..fb15f53e2ce5 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -1241,7 +1241,11 @@ static int iso_sock_accept(struct socket *sock, struct socket *newsock, long timeo; int err = 0; - lock_sock(sk); + /* Use explicit nested locking to avoid lockdep warnings generated + * because the parent socket and the child socket are locked on the + * same thread. + */ + lock_sock_nested(sk, SINGLE_DEPTH_NESTING); timeo = sock_rcvtimeo(sk, arg->flags & O_NONBLOCK); @@ -1272,7 +1276,7 @@ static int iso_sock_accept(struct socket *sock, struct socket *newsock, release_sock(sk); timeo = wait_woken(&wait, TASK_INTERRUPTIBLE, timeo); - lock_sock(sk); + lock_sock_nested(sk, SINGLE_DEPTH_NESTING); } remove_wait_queue(sk_sleep(sk), &wait);