diff mbox series

[net] net: lantiq_xrx200: fix use after free bug

Message ID 20220305112039.3989-1-olek2@wp.pl (mailing list archive)
State Accepted
Commit dd830aed23c6e07cd8e2a163742bf3d63c9add08
Delegated to: Netdev Maintainers
Headers show
Series [net] net: lantiq_xrx200: fix use after free bug | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Aleksander Jan Bajkowski March 5, 2022, 11:20 a.m. UTC
The skb->len field is read after the packet is sent to the network
stack. In the meantime, skb can be freed. This patch fixes this bug.

Fixes: c3e6b2c35b34 ("net: lantiq_xrx200: add ingress SG DMA support")
Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
---
 drivers/net/ethernet/lantiq_xrx200.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Hauke Mehrtens March 5, 2022, 3:41 p.m. UTC | #1
On 3/5/22 12:20, Aleksander Jan Bajkowski wrote:
> The skb->len field is read after the packet is sent to the network
> stack. In the meantime, skb can be freed. This patch fixes this bug.
> 
> Fixes: c3e6b2c35b34 ("net: lantiq_xrx200: add ingress SG DMA support")
> Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>

Acked-by: Hauke Mehrtens <hauke@hauke-m.de>

> ---
>   drivers/net/ethernet/lantiq_xrx200.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c
> index 41d11137cde0..5712c3e94be8 100644
> --- a/drivers/net/ethernet/lantiq_xrx200.c
> +++ b/drivers/net/ethernet/lantiq_xrx200.c
> @@ -260,9 +260,9 @@ static int xrx200_hw_receive(struct xrx200_chan *ch)
>   
>   	if (ctl & LTQ_DMA_EOP) {
>   		ch->skb_head->protocol = eth_type_trans(ch->skb_head, net_dev);
> -		netif_receive_skb(ch->skb_head);
>   		net_dev->stats.rx_packets++;
>   		net_dev->stats.rx_bytes += ch->skb_head->len;
> +		netif_receive_skb(ch->skb_head);
>   		ch->skb_head = NULL;
>   		ch->skb_tail = NULL;
>   		ret = XRX200_DMA_PACKET_COMPLETE;
patchwork-bot+netdevbpf@kernel.org March 7, 2022, 11:40 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Sat,  5 Mar 2022 12:20:39 +0100 you wrote:
> The skb->len field is read after the packet is sent to the network
> stack. In the meantime, skb can be freed. This patch fixes this bug.
> 
> Fixes: c3e6b2c35b34 ("net: lantiq_xrx200: add ingress SG DMA support")
> Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
> 
> [...]

Here is the summary with links:
  - [net] net: lantiq_xrx200: fix use after free bug
    https://git.kernel.org/netdev/net/c/dd830aed23c6

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c
index 41d11137cde0..5712c3e94be8 100644
--- a/drivers/net/ethernet/lantiq_xrx200.c
+++ b/drivers/net/ethernet/lantiq_xrx200.c
@@ -260,9 +260,9 @@  static int xrx200_hw_receive(struct xrx200_chan *ch)
 
 	if (ctl & LTQ_DMA_EOP) {
 		ch->skb_head->protocol = eth_type_trans(ch->skb_head, net_dev);
-		netif_receive_skb(ch->skb_head);
 		net_dev->stats.rx_packets++;
 		net_dev->stats.rx_bytes += ch->skb_head->len;
+		netif_receive_skb(ch->skb_head);
 		ch->skb_head = NULL;
 		ch->skb_tail = NULL;
 		ret = XRX200_DMA_PACKET_COMPLETE;