xen/netfront: don’t cache skb_shinfo() [Linux 4.18]

This Linux kernel change "xen/netfront: don’t cache skb_shinfo()" is included in the Linux 4.18 release. This change is authored by Juergen Gross <jgross [at] suse.com> on Thu Aug 9 16:42:16 2018 +0200. The commit for this change in Linux stable tree is d472b3a (patch).

xen/netfront: don't cache skb_shinfo()

skb_shinfo() can change when calling __pskb_pull_tail(): Don't cache
its return value.

Cc: [email protected]
Signed-off-by: Juergen Gross <[email protected]>
Reviewed-by: Wei Liu <[email protected]>
Signed-off-by: David S. Miller <[email protected]>

There are 8 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/xen-netfront.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 2d8812d..9dd2ca6 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -894,7 +894,6 @@ static RING_IDX xennet_fill_frags(struct netfront_queue *queue,
                  struct sk_buff *skb,
                  struct sk_buff_head *list)
 {
-   struct skb_shared_info *shinfo = skb_shinfo(skb);
    RING_IDX cons = queue->rx.rsp_cons;
    struct sk_buff *nskb;

@@ -903,15 +902,16 @@ static RING_IDX xennet_fill_frags(struct netfront_queue *queue,
            RING_GET_RESPONSE(&queue->rx, ++cons);
        skb_frag_t *nfrag = &skb_shinfo(nskb)->frags[0];

-       if (shinfo->nr_frags == MAX_SKB_FRAGS) {
+       if (skb_shinfo(skb)->nr_frags == MAX_SKB_FRAGS) {
            unsigned int pull_to = NETFRONT_SKB_CB(skb)->pull_to;

            BUG_ON(pull_to <= skb_headlen(skb));
            __pskb_pull_tail(skb, pull_to - skb_headlen(skb));
        }
-       BUG_ON(shinfo->nr_frags >= MAX_SKB_FRAGS);
+       BUG_ON(skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS);

-       skb_add_rx_frag(skb, shinfo->nr_frags, skb_frag_page(nfrag),
+       skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
+               skb_frag_page(nfrag),
                rx->offset, rx->status, PAGE_SIZE);

        skb_shinfo(nskb)->nr_frags = 0;

Leave a Reply

Your email address will not be published. Required fields are marked *