All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Cc: christopher.lee@cspi.com, davem@davemloft.net, pabeni@redhat.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] myri10ge: fix an incorrect free for skb in myri10ge_sw_tso
Date: Wed, 6 Apr 2022 10:50:33 -0700	[thread overview]
Message-ID: <20220406105033.6e0f1978@kernel.org> (raw)
In-Reply-To: <20220406035556.730-1-xiam0nd.tong@gmail.com>

On Wed,  6 Apr 2022 11:55:56 +0800 Xiaomeng Tong wrote:
> All remaining skbs should be released when myri10ge_xmit fails to
> transmit a packet. Fix it within another skb_list_walk_safe.

I think it was also a UAF.

> diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
> index 50ac3ee2577a..21d2645885ce 100644
> --- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
> +++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
> @@ -2903,11 +2903,9 @@ static netdev_tx_t myri10ge_sw_tso(struct sk_buff *skb,
>  		status = myri10ge_xmit(curr, dev);
>  		if (status != 0) {
>  			dev_kfree_skb_any(curr);
> -			if (segs != NULL) {
> -				curr = segs;
> -				segs = next;
> +			skb_list_walk_safe(next, curr, next) {
>  				curr->next = NULL;
> -				dev_kfree_skb_any(segs);
> +				dev_kfree_skb_any(curr);
>  			}
>  			goto drop;
>  		}

Much better, thanks. 

kfree_skb_list() exists but the patch was already applied, so whatever.

      parent reply	other threads:[~2022-04-06 19:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-06  3:55 [PATCH v3] myri10ge: fix an incorrect free for skb in myri10ge_sw_tso Xiaomeng Tong
2022-04-06 11:36 ` Denis Kirjanov
2022-04-06 12:33 ` Denis Kirjanov
2022-04-06 14:30 ` patchwork-bot+netdevbpf
2022-04-06 17:50 ` Jakub Kicinski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220406105033.6e0f1978@kernel.org \
    --to=kuba@kernel.org \
    --cc=christopher.lee@cspi.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=xiam0nd.tong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.