Skip to content
/ linux Public

Commit 5a1ea29

Browse files
JohannesLksgregkh
authored andcommitted
Bluetooth: L2CAP: Fix type confusion in l2cap_ecred_reconf_rsp()
commit 1514567 upstream. l2cap_ecred_reconf_rsp() casts the incoming data to struct l2cap_ecred_conn_rsp (the ECRED *connection* response, 8 bytes with result at offset 6) instead of struct l2cap_ecred_reconf_rsp (2 bytes with result at offset 0). This causes two problems: - The sizeof(*rsp) length check requires 8 bytes instead of the correct 2, so valid L2CAP_ECRED_RECONF_RSP packets are rejected with -EPROTO. - rsp->result reads from offset 6 instead of offset 0, returning wrong data when the packet is large enough to pass the check. Fix by using the correct type. Also pass the already byte-swapped result variable to BT_DBG instead of the raw __le16 field. Fixes: 15f02b9 ("Bluetooth: L2CAP: Add initial code for Enhanced Credit Based Mode") Cc: stable@vger.kernel.org Signed-off-by: Lukas Johannes Möller <research@johannes-moeller.dev> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1768244 commit 5a1ea29

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/bluetooth/l2cap_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5408,15 +5408,15 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn,
54085408
u8 *data)
54095409
{
54105410
struct l2cap_chan *chan, *tmp;
5411-
struct l2cap_ecred_conn_rsp *rsp = (void *) data;
5411+
struct l2cap_ecred_reconf_rsp *rsp = (void *)data;
54125412
u16 result;
54135413

54145414
if (cmd_len < sizeof(*rsp))
54155415
return -EPROTO;
54165416

54175417
result = __le16_to_cpu(rsp->result);
54185418

5419-
BT_DBG("result 0x%4.4x", rsp->result);
5419+
BT_DBG("result 0x%4.4x", result);
54205420

54215421
if (!result)
54225422
return 0;

0 commit comments

Comments
 (0)