Skip to content

Commit

Permalink
Bluetooth: ISO: Fix memory corruption
Browse files Browse the repository at this point in the history
The following memory corruption can happen since iso_pinfo.base size
did not account for its headers (4 bytes):

net/bluetooth/eir.c
    76          memcpy(&eir[eir_len], data, data_len);
                            ^^^^^^^         ^^^^^^^^
    77          eir_len += data_len;
    78
    79          return eir_len;
    80  }

The "eir" buffer has 252 bytes and data_len is 252 but we do a memcpy()
to &eir[4] so this can corrupt 4 bytes beyond the end of the buffer.

Fixes: f764a6c ("Bluetooth: ISO: Add broadcast support")
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
  • Loading branch information
Vudentz committed Aug 9, 2022
1 parent ce78e55 commit b444342
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/bluetooth/iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ static void iso_sock_kill(struct sock *sk);
/* ----- ISO socket info ----- */
#define iso_pi(sk) ((struct iso_pinfo *)sk)

#define EIR_SERVICE_DATA_LENGTH 4
#define BASE_MAX_LENGTH (HCI_MAX_PER_AD_LENGTH - EIR_SERVICE_DATA_LENGTH)

struct iso_pinfo {
struct bt_sock bt;
bdaddr_t src;
Expand All @@ -57,7 +60,7 @@ struct iso_pinfo {
__u32 flags;
struct bt_iso_qos qos;
__u8 base_len;
__u8 base[HCI_MAX_PER_AD_LENGTH];
__u8 base[BASE_MAX_LENGTH];
struct iso_conn *conn;
};

Expand Down

0 comments on commit b444342

Please sign in to comment.