Skip to content
/ linux Public

Commit e7ff754

Browse files
JohannesLksgregkh
authored andcommitted
Bluetooth: L2CAP: Validate L2CAP_INFO_RSP payload length before access
commit dd815e6 upstream. l2cap_information_rsp() checks that cmd_len covers the fixed l2cap_info_rsp header (type + result, 4 bytes) but then reads rsp->data without verifying that the payload is present: - L2CAP_IT_FEAT_MASK calls get_unaligned_le32(rsp->data), which reads 4 bytes past the header (needs cmd_len >= 8). - L2CAP_IT_FIXED_CHAN reads rsp->data[0], 1 byte past the header (needs cmd_len >= 5). A truncated L2CAP_INFO_RSP with result == L2CAP_IR_SUCCESS triggers an out-of-bounds read of adjacent skb data. Guard each data access with the required payload length check. If the payload is too short, skip the read and let the state machine complete with safe defaults (feat_mask and remote_fixed_chan remain zero from kzalloc), so the info timer cleanup and l2cap_conn_start() still run and the connection is not stalled. Fixes: 4e8402a ("[Bluetooth] Retrieve L2CAP features mask on connection setup") 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 5a1ea29 commit e7ff754

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/bluetooth/l2cap_core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4622,7 +4622,8 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn,
46224622

46234623
switch (type) {
46244624
case L2CAP_IT_FEAT_MASK:
4625-
conn->feat_mask = get_unaligned_le32(rsp->data);
4625+
if (cmd_len >= sizeof(*rsp) + sizeof(u32))
4626+
conn->feat_mask = get_unaligned_le32(rsp->data);
46264627

46274628
if (conn->feat_mask & L2CAP_FEAT_FIXED_CHAN) {
46284629
struct l2cap_info_req req;
@@ -4641,7 +4642,8 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn,
46414642
break;
46424643

46434644
case L2CAP_IT_FIXED_CHAN:
4644-
conn->remote_fixed_chan = rsp->data[0];
4645+
if (cmd_len >= sizeof(*rsp) + sizeof(rsp->data[0]))
4646+
conn->remote_fixed_chan = rsp->data[0];
46454647
conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE;
46464648
conn->info_ident = 0;
46474649

0 commit comments

Comments
 (0)