From nobody Mon Feb 9 01:22:49 2026 Received: from meesny.iki.fi (meesny.iki.fi [195.140.195.201]) (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 EE46C22FAFD; Sun, 2 Nov 2025 16:23:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=195.140.195.201 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762100588; cv=pass; b=GYXX963ZC4puZtJl4On5Cc1pfbbJoxCNq2JebLPY3+EYXzOWOiJfvRxsz/wM3kIFyTWHBA5bSBt+hxwyhJz5DqW5o18wXDTYvvIa8UeuspdAkX/viUWk6au80AkXY06Uql+GQz6t7Eb4xB/lPRcMVyjNI1Tuw4TBHYgf6AwWp1M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762100588; c=relaxed/simple; bh=9P2BfdWr0ULqbleM1ZYC3iKyp/JalPh7fDzObFhwjiU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g/k3QcP32EU/b5NYCE5Rkrh3PYNpw851zt9vvfwg1EG5/prvEMJAbsV4/tY0ihJIa28zRVruCp3A9VAw/dqm+KcQUMn7EixMogqQPAwB8MZeHsQgssNeu7Z6EZRRRBDlNOCvA949X8KsF+5365baZ2yoXq3u4eEXTmhG7LBNfUE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iki.fi; spf=pass smtp.mailfrom=iki.fi; dkim=pass (1024-bit key) header.d=iki.fi header.i=@iki.fi header.b=yJCz2zKb; arc=pass smtp.client-ip=195.140.195.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iki.fi Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iki.fi Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=iki.fi header.i=@iki.fi header.b="yJCz2zKb" Received: from monolith.lan (unknown [IPv6:2a02:ed04:3581:1::d001]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pav) by meesny.iki.fi (Postfix) with ESMTPSA id 4d00PX0TWPz102R; Sun, 2 Nov 2025 18:22:55 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1762100576; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FXhhbeiBtqg1CFuh+OtSZuOuHQVw/IOKMOafPmVriC4=; b=yJCz2zKbg6SzBpz7fxhEiZeTowd6b0X3UrxV9cOum9ZBXOVGYuREAO/isGSwK5SsraVR4I dAuoROBP8SQE64gLc4Ui/KRRI4wmK6t2INm/fwZY+do4P2pgu/K34/wZ82q3x8tb8+Yw+n i2hzDA2uR388hq+5xlm2yWEmVUkZTo8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1762100576; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FXhhbeiBtqg1CFuh+OtSZuOuHQVw/IOKMOafPmVriC4=; b=hdFcW7whbEow/4kiWn4sa1bMyjyz/V0ZD/P2jZd7ITtdBFLd0RfYrogZ10jcNPa9GAA0h3 dryXmHxQTTHbCMafDwJYreqF7epHVTTTpYlEttRCEfwddKlIKZ+N8C0bxvmB4eqSNrar7k E52YB6B17CtjFK+NC1lyYVtp9rs0G7k= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav smtp.mailfrom=pav@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1762100576; a=rsa-sha256; cv=none; b=xMi5b177SK/nVf+oPZtWPnNj1xZkFLfp8BRszsiFvSvwX6E5T57zuYC27Vdh+MHGJ7qkF6 zsYY2aD40JpLRqw6mFw7IX8wUxmVKerPPWUwQKw+oCFr5MVxQgn4Bh/tRaZ15C1bwNTard TokORly0KnVFsDwB6vmnRnt+7VZH64k= From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen , marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/8] Bluetooth: hci_event: extend hdev lock in hci_le_remote_conn_param_req_evt Date: Sun, 2 Nov 2025 18:19:33 +0200 Message-ID: <2486739e3daff8e4fbc0e7fc95fb2e86f866cbc2.1762100290.git.pav@iki.fi> X-Mailer: git-send-email 2.51.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Cover conn lookup and field access with hdev lock in hci_le_remote_conn_param_req_evt. This avoids any concurrent deletion of the conn before we are done dereferencing it. Fixes: 95118dd4edfec ("Bluetooth: hci_event: Use of a function table to han= dle LE subevents") Signed-off-by: Pauli Virtanen --- Notes: v2: - no change net/bluetooth/hci_event.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index ba0a7b41611f..54f757017f3f 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -6675,25 +6675,31 @@ static void hci_le_remote_conn_param_req_evt(struct= hci_dev *hdev, void *data, latency =3D le16_to_cpu(ev->latency); timeout =3D le16_to_cpu(ev->timeout); =20 + hci_dev_lock(hdev); + hcon =3D hci_conn_hash_lookup_handle(hdev, handle); - if (!hcon || hcon->state !=3D BT_CONNECTED) - return send_conn_param_neg_reply(hdev, handle, - HCI_ERROR_UNKNOWN_CONN_ID); + if (!hcon || hcon->state !=3D BT_CONNECTED) { + send_conn_param_neg_reply(hdev, handle, + HCI_ERROR_UNKNOWN_CONN_ID); + goto unlock; + } =20 - if (max > hcon->le_conn_max_interval) - return send_conn_param_neg_reply(hdev, handle, - HCI_ERROR_INVALID_LL_PARAMS); + if (max > hcon->le_conn_max_interval) { + send_conn_param_neg_reply(hdev, handle, + HCI_ERROR_INVALID_LL_PARAMS); + goto unlock; + } =20 - if (hci_check_conn_params(min, max, latency, timeout)) - return send_conn_param_neg_reply(hdev, handle, - HCI_ERROR_INVALID_LL_PARAMS); + if (hci_check_conn_params(min, max, latency, timeout)) { + send_conn_param_neg_reply(hdev, handle, + HCI_ERROR_INVALID_LL_PARAMS); + goto unlock; + } =20 if (hcon->role =3D=3D HCI_ROLE_MASTER) { struct hci_conn_params *params; u8 store_hint; =20 - hci_dev_lock(hdev); - params =3D hci_conn_params_lookup(hdev, &hcon->dst, hcon->dst_type); if (params) { @@ -6706,8 +6712,6 @@ static void hci_le_remote_conn_param_req_evt(struct h= ci_dev *hdev, void *data, store_hint =3D 0x00; } =20 - hci_dev_unlock(hdev); - mgmt_new_conn_param(hdev, &hcon->dst, hcon->dst_type, store_hint, min, max, latency, timeout); } @@ -6721,6 +6725,9 @@ static void hci_le_remote_conn_param_req_evt(struct h= ci_dev *hdev, void *data, cp.max_ce_len =3D 0; =20 hci_send_cmd(hdev, HCI_OP_LE_CONN_PARAM_REQ_REPLY, sizeof(cp), &cp); + +unlock: + hci_dev_unlock(hdev); } =20 static void hci_le_direct_adv_report_evt(struct hci_dev *hdev, void *data, --=20 2.51.1