From: Cen Zhang <zzzccc427@gmail.com>
To: marcel@holtmann.org, luiz.dentz@gmail.com
Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, baijiaju1990@gmail.com,
jjzuming@gmail.com, zzzccc427@gmail.com
Subject: [PATCH 1/2] Bluetooth: RFCOMM: Reject listen after socket shutdown
Date: Wed, 25 Nov 2026 23:22:17 +0800 [thread overview]
Message-ID: <pm-bluetooth-objects-candidate-0218-followup-v2-88edfec8c72ed860e626-1@gmail.com> (raw)
In-Reply-To: <pm-bluetooth-objects-candidate-0218-followup-v2-88edfec8c72ed860e626-0@gmail.com>
RFCOMM drains a listener's accept queue on its first shutdown. A bound
socket can retain BT_BOUND after shutdown, however, and the listen
state check can admit it as a listener. Release then skips the accept
queue cleanup because sk_shutdown is already set. Queued children can
retain a pointer to the listener after it is freed.
Check sk_shutdown before entering BT_LISTEN. The socket lock serializes
this check with rfcomm_sock_shutdown() setting the flag.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Link: https://lkml.iu.edu/hypermail/linux/kernel/2611.2/24606.html
Cc: stable@vger.kernel.org
Signed-off-by: Cen Zhang <zzzccc427@gmail.com>
---
This patch was written with assistance from Codex (OpenAI).
net/bluetooth/rfcomm/sock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 889e45dd5d04e..86a43dc0ab5e3 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -448,7 +448,7 @@ static int rfcomm_sock_listen(struct socket *sock, int backlog)
lock_sock(sk);
- if (sk->sk_state != BT_BOUND) {
+ if (sk->sk_state != BT_BOUND || sk->sk_shutdown) {
err = -EBADFD;
goto done;
}
next prev parent reply other threads:[~2026-11-25 15:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 15:22 [PATCH 0/2] Bluetooth: RFCOMM: Fix listener shutdown and TTY setup Cen Zhang
2026-11-25 15:22 ` Cen Zhang [this message]
2026-11-25 15:22 ` [PATCH 2/2] Bluetooth: RFCOMM: Close DLC on TTY registration failure 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=pm-bluetooth-objects-candidate-0218-followup-v2-88edfec8c72ed860e626-1@gmail.com \
--to=zzzccc427@gmail.com \
--cc=baijiaju1990@gmail.com \
--cc=jjzuming@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--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 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®