Bluetooth: L2CAP: Fix printing wrong information if SDU length exceeds MTU
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/2 Bluetooth: L2CAP: Fix printing wrong information if SDU length exceeds MTU
From: Luiz Augusto von Dentz <[email protected]>
The code was printing skb->len and sdu_len in the places where it should be sdu_len and chan->imtu respectively to match the if conditions.
--- net/bluetooth/l2cap_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +1 -1
@@ -6705,7 +6705,7 @@ static int l2cap_ecred_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb)if (sdu_len > chan->imtu) {BT_ERR ("Too big LE L2CAP SDU length: len %u > %u" , - skb->len, sdu_len); + sdu_len, chan->imtu);l2cap_send_disconn_req (chan,ECONNRESET ); err = -EMSGSIZE ; goto failed;
Signature · 1 line
2.53.0
Luiz Augusto von Dentz
maintainerPATCH 2/2 Bluetooth: MGMT: Fix dangling pointer on mgmt_add_adv_patterns_monitor_complete
From: Luiz Augusto von Dentz <[email protected]>
This fixes the condition checking so mgmt_pending_valid is executed whenever status != -ECANCELED otherwise Calling mgmt_pending_free(cmd) would kfree(cmd) without unlinking it from the list first, leaving a dangling pointer. Any subsequent list traversal (e.g., mgmt_pending_foreach during __mgmt_power_off, or another mgmt_pending_valid call) would dereference freed memory.
--- net/bluetooth/mgmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/mgmt.c +1 -1
@@ -5355,7 +5355,7 @@ static void mgmt_add_adv_patterns_monitor_complete(struct hci_dev *hdev,* hci_adv_monitors_clear is about to be called which will take care of * freeing the adv_monitor instances. */ -if (status == -ECANCELED && !mgmt_pending_valid (hdev, cmd)) +if (status == -ECANCELED || !mgmt_pending_valid (hdev, cmd))return ; monitor = cmd->user_data;
Signature · 1 line
2.53.0
Re: [PATCH v1 2/2] Bluetooth: MGMT: Fix dangling pointer on mgmt_add_adv_patterns_monitor_complete
Dear Luiz,
Thank you for your patch.
Am 16.03.26 um 20:09 schrieb Luiz Augusto von Dentz:
Quoted 4 lines
From: Luiz Augusto von Dentz <[email protected]>
This fixes the condition checking so
mgmt_pending_validis executed whenever status !=-ECANCELEDotherwise Callingmgmt_pending_free(cmd)
s/Calling/calling/
Quoted 16 lines
would kfree(cmd) without unlinking it from the list first, leaving a dangling pointer. Any subsequent list traversal (e.g.,
mgmt_pending_foreachduring__mgmt_power_off, or anothermgmt_pending_validcall) would dereference freed memory.Fixes 302a1f674c00 ("Bluetooth: MGMT: Fix possible UAFs")Signed-off-by Luiz Augusto von Dentz <[email protected]>--- net/bluetooth/mgmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/bluetooth/mgmt.c +0
-0
net/bluetooth/mgmt.c static void mgmt_add_adv_patterns_monitor_complete(struct hci_dev *hdev, · line 5361
Quoted 8 lines
net/bluetooth/mgmt.c +1
-1@@ -5355,7 +5355,7 @@ static void mgmt_add_adv_patterns_monitor_complete(struct hci_dev *hdev,* hci_adv_monitors_clear is about to be called which will take care of * freeing the adv_monitor instances. */ -if (status == -ECANCELED && !mgmt_pending_valid (hdev, cmd)) +if (status == -ECANCELED || !mgmt_pending_valid (hdev, cmd))return ; monitor = cmd->user_data;
Kind regards,
Paul
Dear Luiz,
Thank you for your patch.
Am 16.03.26 um 20:09 schrieb Luiz Augusto von Dentz:
Quoted 4 lines
From: Luiz Augusto von Dentz <[email protected]>
The code was printing
skb->lenandsdu_lenin the places where it should besdu_lenandchan->imturespectively to match the if conditions.
Maybe add the URL of the message with the review comments?
Quoted 11 lines
Fixes fa768fce4aae ("Bluetooth: LE L2CAP: Disconnect if received packet's SDU exceeds IMTU")Signed-off-by Luiz Augusto von Dentz <[email protected]>--- net/bluetooth/l2cap_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/bluetooth/l2cap_core.c +0
-0
net/bluetooth/l2cap_core.c static int l2cap_ecred_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) · line 6711
Quoted 8 lines
net/bluetooth/l2cap_core.c +1
-1@@ -6705,7 +6705,7 @@ static int l2cap_ecred_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb)if (sdu_len > chan->imtu) {BT_ERR ("Too big LE L2CAP SDU length: len %u > %u" , - skb->len, sdu_len); + sdu_len, chan->imtu);l2cap_send_disconn_req (chan,ECONNRESET ); err = -EMSGSIZE ; goto failed;
Kind regards,
Paul
This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 9 lines · On Mon, 16 Mar 2026 15:09:56 -0400 you wrote:
From: Luiz Augusto von Dentz <[email protected]>
The code was printing
skb->lenandsdu_lenin the places where it should besdu_lenandchan->imturespectively to match the if conditions.Fixes fa768fce4aae ("Bluetooth: LE L2CAP: Disconnect if received packet's SDU exceeds IMTU")Signed-off-by Luiz Augusto von Dentz <[email protected]>[...]
Here is the summary with links:
- [v1,1/2] Bluetooth: L2CAP: Fix printing wrong information if SDU length exceeds MTU
https://git.kernel.org/bluetooth/bluetooth-next/c/013598897448
- [v1,2/2] Bluetooth: MGMT: Fix dangling pointer on mgmt_add_adv_patterns_monitor_complete
https://git.kernel.org/bluetooth/bluetooth-next/c/3c2dbfa16ca6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html