Skip to content

Commit

Permalink
gro: Fix page ref count for skbs freed normally
Browse files Browse the repository at this point in the history
When an skb with page frags is merged into an existing one, we
cannibalise its reference count.  This is OK when the skb is
reused because we set nr_frags to zero in that case.  However,
for the case where the skb is freed through kfree_skb, we didn't
clear nr_frags which causes the page to be freed prematurely.

This is fixed by moving the skb resetting into skb_gro_receive.

Reported-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Herbert Xu authored and David S. Miller committed Jan 15, 2009
1 parent fc8c7dc commit f557206
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 0 additions & 6 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2491,12 +2491,6 @@ EXPORT_SYMBOL(napi_gro_receive);

void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb)
{
skb_shinfo(skb)->nr_frags = 0;

skb->len -= skb->data_len;
skb->truesize -= skb->data_len;
skb->data_len = 0;

__skb_pull(skb, skb_headlen(skb));
skb_reserve(skb, NET_IP_ALIGN - skb_headroom(skb));

Expand Down
6 changes: 6 additions & 0 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -2602,6 +2602,12 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
skb_shinfo(skb)->nr_frags * sizeof(skb_frag_t));

skb_shinfo(p)->nr_frags += skb_shinfo(skb)->nr_frags;
skb_shinfo(skb)->nr_frags = 0;

skb->truesize -= skb->data_len;
skb->len -= skb->data_len;
skb->data_len = 0;

NAPI_GRO_CB(skb)->free = 1;
goto done;
}
Expand Down

0 comments on commit f557206

Please sign in to comment.