mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pauli Virtanen <pav@iki.fi>
To: Cen Zhang <zzzccc427@gmail.com>, Tejun Heo <tj@kernel.org>,
	Lai Jiangshan	 <jiangshanlai@gmail.com>,
	Marcel Holtmann <marcel@holtmann.org>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	Marco Elver <elver@google.com>,
	Jukka Rissanen	 <jukka.rissanen@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org,
	 baijiaju1990@gmail.com, jjzuming@gmail.com
Subject: Re: [PATCH 1/5] Bluetooth: L2CAP: ignore close requests for deleted channels
Date: Mon, 21 Sep 2026 19:56:44 +0300	[thread overview]
Message-ID: <a0d9ba78f7d3598494f2a6ed31afd789972a1d72.camel@iki.fi> (raw)
In-Reply-To: <pm-series-6lowpan-lifecycle-82fab5876048c8c9503c-1@gmail.com>

Hi,

ma, 2026-09-21 kello 23:38 +0800, Cen Zhang kirjoitti:
> l2cap_chan_del() keeps chan->conn alive until channel destruction and
> marks removal with FLAG_DEL, but does not necessarily change the state.
> A caller retaining a temporary reference can therefore enter
> l2cap_chan_close_unlocked() after deletion and follow a stale connected
> state, rearming the channel timer and sending another disconnection
> request for a channel no longer on the connection list.
> 
> Check FLAG_DEL after taking the channel and connection locks so that
> concurrent deletion is serialized with the decision to close. Return
> without further timer or signaling work when the channel is deleted.
> 
> Fixes: b66774b48dd9 ("Bluetooth: L2CAP: Fix UAF in channel timeout by holding conn ref")
> Assisted-by: LLM
> Signed-off-by: Cen Zhang <zzzccc427@gmail.com>
> ---
>  net/bluetooth/l2cap_core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 49a998804908..65e957fdc7ae 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -939,8 +939,10 @@ void l2cap_chan_close_unlocked(struct l2cap_chan *chan, int reason)
>  
>  	have_conn = l2cap_chan_lock_conn(chan);
>  
> -	/* Context analysis: consider chan->conn->lock held also if conn NULL */
> -	context_unsafe(__l2cap_chan_close(chan, reason));
> +	if (!test_bit(FLAG_DEL, &chan->flags)) {
> +		/* Consider chan->conn->lock held also if conn NULL */
> +		context_unsafe(__l2cap_chan_close(chan, reason));

This probably would better be further down in __l2cap_chan_close()
together with the other state check.

> +	}
>  
>  	l2cap_chan_unlock_conn(chan, have_conn);
>  }
> 
> base-commit: 019debf20bfd648b40ba10377ee0168db5eb241e

-- 
Pauli Virtanen

  reply	other threads:[~2026-09-21 16:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 15:38 [PATCH 0/5] Bluetooth: 6LoWPAN lifecycle fixes Cen Zhang
2026-09-21 15:38 ` [PATCH 1/5] Bluetooth: L2CAP: ignore close requests for deleted channels Cen Zhang
2026-09-21 16:56   ` Pauli Virtanen [this message]
2026-09-21 15:38 ` [PATCH 2/5] workqueue: add support for module-owned work Cen Zhang
2026-09-21 16:16   ` Tejun Heo
2026-09-21 17:03     ` Cen Zhang
2026-09-21 15:39 ` [PATCH 3/5] Bluetooth: L2CAP: drain channel timers on connection teardown Cen Zhang
2026-09-21 15:54   ` Luiz Augusto von Dentz
2026-09-21 15:39 ` [PATCH 4/5] Bluetooth: 6lowpan: handle channel setup failure and callback lifetime Cen Zhang
2026-09-21 15:39 ` [PATCH 5/5] Bluetooth: 6lowpan: quiesce peers before channel deletion Cen Zhang
2026-09-21 16:07 ` [PATCH 0/5] Bluetooth: 6LoWPAN lifecycle fixes Luiz Augusto von Dentz
2026-09-21 16:59   ` Cen Zhang

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=a0d9ba78f7d3598494f2a6ed31afd789972a1d72.camel@iki.fi \
    --to=pav@iki.fi \
    --cc=baijiaju1990@gmail.com \
    --cc=elver@google.com \
    --cc=jiangshanlai@gmail.com \
    --cc=jjzuming@gmail.com \
    --cc=jukka.rissanen@linux.intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=tj@kernel.org \
    --cc=zzzccc427@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®