All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] Bluetooth: L2CAP: check security before completing a BR/EDR connection
@ 2026-11-19 22:16 Luiz Augusto von Dentz
  2026-11-19 22:16 ` [PATCH v2 2/2] Bluetooth: L2CAP: Don't offer deferred channels before security is met Luiz Augusto von Dentz
  2026-11-20  0:04 ` [v2,1/2] Bluetooth: L2CAP: check security before completing a BR/EDR connection bluez.test.bot
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2026-11-19 22:16 UTC (permalink / raw)
  To: linux-bluetooth

From: Mohammed Alquraini <mohammed.saad.alquraini@gmail.com>

A BR/EDR L2CAP service that listens with BT_DEFER_SETUP asks the kernel
to enforce its BT_SECURITY level and only decides which peer to admit.
l2cap_security_cfm() does not honour that for a channel in BT_CONNECT2.

When the security procedure reports success, the BT_CONNECT2 branch only
verifies the encryption key size before answering the pending connection
request with L2CAP_CR_PEND (deferred setup) or L2CAP_CR_SUCCESS. A
successful status doesn't mean the channel's security level is met
though, e.g. if the peer disables encryption while the channel is
waiting for userspace to authorize it, the channel is offered to the
listener again and, once authorized, it is established over an
unencrypted link.

The non-deferred incoming path already checks
l2cap_chan_check_security() before answering, and l2cap_conn_start()
does the same for BT_CONNECT2 channels; only the l2cap_security_cfm()
path was missed. This is the BR/EDR counterpart of commit 522e9ed157e3
("Bluetooth: l2cap: Check encryption key size on incoming connection").

Also require l2cap_chan_check_security() next to
l2cap_check_enc_key_size() in the BT_CONNECT2 branch of
l2cap_security_cfm(), so the channel is only accepted or deferred once
the link meets the required security level and encryption key size, and
is otherwise denied with L2CAP_CR_SEC_BLOCK.

AI assistance was used in finding and preparing this patch.

Fixes: f66dc81f44d9 ("Bluetooth: Add support for deferring L2CAP connection setup")
Signed-off-by: Mohammed Alquraini <mohammed.saad.alquraini@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
v2: Drop BT_SK_ACCEPTED and the changes to l2cap_sock_defer(), only check
    l2cap_chan_check_security() in the BT_CONNECT2 branch of
    l2cap_security_cfm(). The early accept is handled by patch 2/2.
---
 net/bluetooth/l2cap_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 943effc86740..6bf3a162f865 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -8143,7 +8143,8 @@ static void l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
 			struct l2cap_conn_rsp rsp;
 			__u16 res, stat;
 
-			if (!status && l2cap_check_enc_key_size(hcon, chan)) {
+			if (!status && l2cap_check_enc_key_size(hcon, chan) &&
+			    l2cap_chan_check_security(chan, false)) {
 				if (test_bit(FLAG_DEFER_SETUP, &chan->flags)) {
 					res = L2CAP_CR_PEND;
 					stat = L2CAP_CS_AUTHOR_PEND;
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-20  0:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 22:16 [PATCH v2 1/2] Bluetooth: L2CAP: check security before completing a BR/EDR connection Luiz Augusto von Dentz
2026-11-19 22:16 ` [PATCH v2 2/2] Bluetooth: L2CAP: Don't offer deferred channels before security is met Luiz Augusto von Dentz
2026-11-20  0:04 ` [v2,1/2] Bluetooth: L2CAP: check security before completing a BR/EDR connection bluez.test.bot

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.