Skip to content

Commit

Permalink
Bluetooth: Controller: Handle overlapping buffers on ull_adv{.c,_aux.c}
Browse files Browse the repository at this point in the history
* Setting the adv data, scan rsp and adv aux ad data can happen on
overlapping buffers
* There can be other memcpy's that need to be changed to memmove but
these are the only ones I could reproduce the issue and since memmove
has a performance penalty, I left the others as is.

Signed-off-by: Yago Fontoura do Rosario <yafo@demant.com>
  • Loading branch information
Yago Fontoura do Rosario authored and aescolar committed Oct 9, 2024
1 parent 5b5d636 commit 029540a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions subsys/bluetooth/controller/ll_sw/ull_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1870,7 +1870,7 @@ uint8_t ull_adv_data_set(struct ll_adv_set *adv, uint8_t len,

pdu->tx_addr = prev->tx_addr;
pdu->rx_addr = prev->rx_addr;
memcpy(&pdu->adv_ind.addr[0], &prev->adv_ind.addr[0], BDADDR_SIZE);
memmove(&pdu->adv_ind.addr[0], &prev->adv_ind.addr[0], BDADDR_SIZE);
memcpy(&pdu->adv_ind.data[0], data, len);
pdu->len = BDADDR_SIZE + len;

Expand Down Expand Up @@ -1926,7 +1926,7 @@ uint8_t ull_scan_rsp_set(struct ll_adv_set *adv, uint8_t len,
pdu->tx_addr = prev->tx_addr;
pdu->rx_addr = 0;
pdu->len = BDADDR_SIZE + len;
memcpy(&pdu->scan_rsp.addr[0], &prev->scan_rsp.addr[0], BDADDR_SIZE);
memmove(&pdu->scan_rsp.addr[0], &prev->scan_rsp.addr[0], BDADDR_SIZE);
memcpy(&pdu->scan_rsp.data[0], data, len);

/* Update time reservation */
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/controller/ll_sw/ull_adv_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,7 @@ uint8_t ull_adv_aux_hdr_set_clear(struct ll_adv_set *adv,

sec_dptr -= BDADDR_SIZE;

(void)memcpy(sec_dptr, bdaddr, BDADDR_SIZE);
(void)memmove(sec_dptr, bdaddr, BDADDR_SIZE);
}

/* Set the common extended header format flags in the current primary
Expand Down

0 comments on commit 029540a

Please sign in to comment.