net: ll_temac: Make sure to free skb when it is completely used
authorEsben Haabendal <esben@geanix.com>
Fri, 18 Jun 2021 10:52:23 +0000 (12:52 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Jun 2021 12:42:53 +0000 (14:42 +0200)
commit019ab7d044d0ebf97e1236bb8935b7809be92358
treef2882ab59307deb2cef982a88c513354bcc5047b
parent41984d4fbe21d7e0638212c42fdeaead76f5513d
net: ll_temac: Make sure to free skb when it is completely used

commit 6aa32217a9a446275440ee8724b1ecaf1838df47 upstream.

With the skb pointer piggy-backed on the TX BD, we have a simple and
efficient way to free the skb buffer when the frame has been transmitted.
But in order to avoid freeing the skb while there are still fragments from
the skb in use, we need to piggy-back on the TX BD of the skb, not the
first.

Without this, we are doing use-after-free on the DMA side, when the first
BD of a multi TX BD packet is seen as completed in xmit_done, and the
remaining BDs are still being processed.

Cc: stable@vger.kernel.org # v5.4+
Signed-off-by: Esben Haabendal <esben@geanix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/xilinx/ll_temac_main.c