All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Pereira <danielmaraboo@gmail.com>
To: stable@vger.kernel.org
Subject: [PATCH 6.1.y] Bluetooth: ISO: ensure no dangling hcon references in iso_conn
Date: Sun, 30 Aug 2026 01:58:01 -0300	[thread overview]
Message-ID: <20260830045801.212389-1-danielmaraboo@gmail.com> (raw)

commit aa9f7cb2bd3a2be998ceb739fc9a2f986eba43eb upstream.

After iso_conn_del(), ISO sockets should not dereference the hcon any
more.  Currently, clearing iso_conn::hcon relies on iso_conn_del()
releasing the last reference to the iso_conn.

Simplify this by explicitly clearing conn->hcon in iso_conn_del(), to
avoid more complex reasoning on races about who holds the last
reference.

[ Daniel Pereira ]
Backport notes:
- Adjusted the context in iso_conn_del() as 6.1.y handles iso_conn freeing
  without refcounting (kfree(conn)). Explicitly cleared conn->hcon under
  iso_conn_lock() right before freeing to maintain the safety invariant and
  prevent any concurrent socket accesses from holding dangling hcon pointers.

Signed-off-by: Pauli Virtanen <pav@iki.fi>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Daniel Pereira <danielmaraboo@gmail.com>
---
 net/bluetooth/iso.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c
index aad4baec9..ef31fcd47 100644
--- a/net/bluetooth/iso.c
+++ b/net/bluetooth/iso.c
@@ -183,6 +183,7 @@ static void iso_chan_del(struct sock *sk, int err)
 }
 
 static void iso_conn_del(struct hci_conn *hcon, int err)
+	__must_hold(&hcon->hdev->lock)
 {
 	struct iso_conn *conn = hcon->iso_data;
 	struct sock *sk;
@@ -208,6 +209,9 @@ static void iso_conn_del(struct hci_conn *hcon, int err)
 	/* Ensure no more work items will run before freeing conn. */
 	cancel_delayed_work_sync(&conn->timeout_work);
 
+	iso_conn_lock(conn);
+	conn->hcon = NULL;
+	iso_conn_unlock(conn);
 	hcon->iso_data = NULL;
 	kfree(conn);
 }
@@ -1669,6 +1673,7 @@ static void iso_connect_cfm(struct hci_conn *hcon, __u8 status)
 }
 
 static void iso_disconn_cfm(struct hci_conn *hcon, __u8 reason)
+	__must_hold(&hcon->hdev->lock)
 {
 	if (hcon->type != ISO_LINK)
 		return;
-- 
2.47.3


             reply	other threads:[~2026-08-30  4:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30  4:58 Daniel Pereira [this message]
2026-08-31  1:39 ` [PATCH 6.1.y] Bluetooth: ISO: ensure no dangling hcon references in iso_conn Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260830045801.212389-1-danielmaraboo@gmail.com \
    --to=danielmaraboo@gmail.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.