Skip to contentSkip to conversation

Bluetooth: A2MP: Do not set rsp.id to zero

PATCH In review Stefan Gottwald 1 participant 2 messages Oct 18, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: A2MP: Do not set rsp.id to zero

Due to security reasons the rsp struct is not zerod out in one case this will also zero out the former set rsp.id which seems to be wrong.

---
 net/bluetooth/a2mp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/a2mp.c +2 -1
index da7fd7c..7a1e0b7 100644
@@ -381,10 +381,11 @@ static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb,
 	hdev = hci_dev_get(req->id);
 	if (!hdev || hdev->amp_type == AMP_TYPE_BREDR || tmp) {
 		struct a2mp_amp_assoc_rsp rsp;
-		rsp.id = req->id;
 
 		memset(&rsp, 0, sizeof(rsp));
 
+		rsp.id = req->id;
+
 		if (tmp) {
 			rsp.status = A2MP_STATUS_COLLISION_OCCURED;
 			amp_mgr_put(tmp);
Signature · 1 line
2.7.4
#1 lore raw

Am Sonntag, den 18.10.2020, 10:05 +0200 schrieb Stefan Gottwald:

Quoted 15 lines

Due to security reasons the rsp struct is not zerod out in one case this will also zero out the former set rsp.id which seems to be wrong.

---
 net/bluetooth/a2mp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/a2mp.c +0 -0
index da7fd7c..7a1e0b7 100644
@@ -381,10 +381,11 @@ static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb,
 	hdev = hci_dev_get(req->id);
 	if (!hdev || hdev->amp_type == AMP_TYPE_BREDR || tmp) {

net/bluetooth/a2mp.c static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb, · line 391

Quoted 10 lines
net/bluetooth/a2mp.c +2 -1
 		struct a2mp_amp_assoc_rsp rsp;
-		rsp.id = req->id;
 
 		memset(&rsp, 0, sizeof(rsp));
 
+		rsp.id = req->id;
+
 		if (tmp) {
 			rsp.status = A2MP_STATUS_COLLISION_OCCURED;
 			amp_mgr_put(tmp);

As it seems I'm too slow there is already a fix from the author of the initial patch.

https://lore.kernel.org/linux-bluetooth/[email protected]/

There is a additional patch in this series which might also be a important fix

https://lore.kernel.org/linux-bluetooth/[email protected]/

Thanks to a LWN member pointing this out to me.