Re: [PATCH] can: m_can: m_can_tx_handler(): fix use after free of skb

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Apr 04, 2022 at 09:08:30PM +0200, Marc Kleine-Budde wrote:
> commit 2e8e79c416aae1de224c0f1860f2e3350fa171f8 upstream.
> 
> can_put_echo_skb() will clone skb then free the skb. Move the
> can_put_echo_skb() for the m_can version 3.0.x directly before the
> start of the xmit in hardware, similar to the 3.1.x branch.
> 
> Fixes: 80646733f11c ("can: m_can: update to support CAN FD features")
> Link: https://lore.kernel.org/all/20220317081305.739554-1-mkl@xxxxxxxxxxxxxx
> Cc: stable@xxxxxxxxxxxxxxx
> Reported-by: Hangyu Hua <hbh25y@xxxxxxxxx>
> Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
> ---
> Hello Greg, hello Sasha,
> 
> This is
> 
> | 2e8e79c416aa can: m_can: m_can_tx_handler(): fix use after free of skb
> 
> ported to v5.10.109.
> 
> regards,
> Marc
> 
>  drivers/net/can/m_can/m_can.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
> index 19a7e4adb933..52386460fe92 100644
> --- a/drivers/net/can/m_can/m_can.c
> +++ b/drivers/net/can/m_can/m_can.c
> @@ -1491,8 +1491,6 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
>  					 M_CAN_FIFO_DATA(i / 4),
>  					 *(u32 *)(cf->data + i));
>  
> -		can_put_echo_skb(skb, dev, 0);
> -
>  		if (cdev->can.ctrlmode & CAN_CTRLMODE_FD) {
>  			cccr = m_can_read(cdev, M_CAN_CCCR);
>  			cccr &= ~(CCCR_CMR_MASK << CCCR_CMR_SHIFT);
> @@ -1509,6 +1507,9 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
>  			m_can_write(cdev, M_CAN_CCCR, cccr);
>  		}
>  		m_can_write(cdev, M_CAN_TXBTIE, 0x1);
> +
> +		can_put_echo_skb(skb, dev, 0, 0);

You didn't build this patch :(

I'll go fix this by hand...

greg k-h



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux