Netdev List
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: dongli.zhang@oracle.com
Cc: xen-devel@lists.xenproject.org, netdev@vger.kernel.org,
	boris.ostrovsky@oracle.com, jgross@suse.com,
	sstabellini@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] xen-netfront: do not assume sk_buff_head list is empty in error handling
Date: Mon, 16 Sep 2019 21:47:07 +0200 (CEST)	[thread overview]
Message-ID: <20190916.214707.1312089672859838604.davem@davemloft.net> (raw)
In-Reply-To: <1568605619-22219-1-git-send-email-dongli.zhang@oracle.com>

From: Dongli Zhang <dongli.zhang@oracle.com>
Date: Mon, 16 Sep 2019 11:46:59 +0800

> When skb_shinfo(skb) is not able to cache extra fragment (that is,
> skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS), xennet_fill_frags() assumes
> the sk_buff_head list is already empty. As a result, cons is increased only
> by 1 and returns to error handling path in xennet_poll().
> 
> However, if the sk_buff_head list is not empty, queue->rx.rsp_cons may be
> set incorrectly. That is, queue->rx.rsp_cons would point to the rx ring
> buffer entries whose queue->rx_skbs[i] and queue->grant_rx_ref[i] are
> already cleared to NULL. This leads to NULL pointer access in the next
> iteration to process rx ring buffer entries.
> 
> Below is how xennet_poll() does error handling. All remaining entries in
> tmpq are accounted to queue->rx.rsp_cons without assuming how many
> outstanding skbs are remained in the list.
> 
>  985 static int xennet_poll(struct napi_struct *napi, int budget)
> ... ...
> 1032           if (unlikely(xennet_set_skb_gso(skb, gso))) {
> 1033                   __skb_queue_head(&tmpq, skb);
> 1034                   queue->rx.rsp_cons += skb_queue_len(&tmpq);
> 1035                   goto err;
> 1036           }
> 
> It is better to always have the error handling in the same way.
> 
> Fixes: ad4f15dc2c70 ("xen/netfront: don't bug in case of too many frags")
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>

Applied and queued up for -stable.

      reply	other threads:[~2019-09-16 19:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-16  3:46 [PATCH 1/1] xen-netfront: do not assume sk_buff_head list is empty in error handling Dongli Zhang
2019-09-16 19:47 ` David Miller [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=20190916.214707.1312089672859838604.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=boris.ostrovsky@oracle.com \
    --cc=dongli.zhang@oracle.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox