Re: [PATCH v1] net: can: j1939: Fix out-of-bounds memory access in j1939_tp_tx_dat_new
From: Marc Kleine-Budde
Date: Wed Apr 05 2023 - 04:24:19 EST
On 04.04.2023 09:31:28, Oleksij Rempel wrote:
> In the j1939_tp_tx_dat_new function, an out-of-bounds memory access
> could occur during the memcpy operation if the size of skb->cb is
> larger than the size of struct j1939_sk_buff_cb. This is because the
> memcpy operation uses the size of skb->cb, leading to a read beyond
> the struct j1939_sk_buff_cb.
>
> To address this issue, we have updated the memcpy operation to use the
> size of struct j1939_sk_buff_cb instead of the size of skb->cb. This
> ensures that the memcpy operation only reads the memory within the
> bounds of struct j1939_sk_buff_cb, preventing out-of-bounds memory
> access.
>
> Additionally, a static_assert has been added to check that the size of
> skb->cb is greater than or equal to the size of struct j1939_sk_buff_cb.
> This ensures that the skb->cb buffer is large enough to hold the
> j1939_sk_buff_cb structure.
>
> Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
> Reported-by: Shuangpeng Bai <sjb7183@xxxxxxx>
> Tested-by: Shuangpeng Bai <sjb7183@xxxxxxx>
> Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
Applied.
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Attachment:
signature.asc
Description: PGP signature