History

gre: fix a possible skb leak

commit 68c331631143 ("v4 GRE: Add TCP segmentation offload for GRE") added a possible skb leak, because it frees only the head of segment list, in case a skb_linearize() call fails. This patch adds a kfree_skb_list() helper to fix the bug.

Eric Dumazet committed 13 years ago

Commit bd8a7031 parent 2b7a5db3 files · +14 −9Browse files

Unified · Split

3 files
  1. include/linux/skbuff.h +1 −0
  2. net/core/skbuff.c +12 −8
  3. net/ipv4/gre.c +1 −1
include/linux/skbuff.h+1−0
@@ -627,6 +627,7 @@ static inline struct rtable *skb_rtable(const struct sk_buff *skb) · 626 unmodified lines
627}627}
628 628
629extern void kfree_skb(struct sk_buff *skb);629extern void kfree_skb(struct sk_buff *skb);
630extern void kfree_skb_list(struct sk_buff *segs);
630extern void skb_tx_error(struct sk_buff *skb);631extern void skb_tx_error(struct sk_buff *skb);
631extern void consume_skb(struct sk_buff *skb);632extern void consume_skb(struct sk_buff *skb);
632extern void __kfree_skb(struct sk_buff *skb);633extern void __kfree_skb(struct sk_buff *skb);
net/core/skbuff.c+12−8
@@ -483,15 +483,8 @@ EXPORT_SYMBOL(skb_add_rx_frag); · 482 unmodified lines
483 483
484static void skb_drop_list(struct sk_buff **listp)484static void skb_drop_list(struct sk_buff **listp)
485{485{
486 struct sk_buff *list = *listp;486 kfree_skb_list(*listp);
487
488 *listp = NULL;487 *listp = NULL;
489
490 do {
491 struct sk_buff *this = list;
492 list = list->next;
493 kfree_skb(this);
494 } while (list);
495}488}
496 489
497static inline void skb_drop_fraglist(struct sk_buff *skb)490static inline void skb_drop_fraglist(struct sk_buff *skb)
@@ -651,6 +644,17 @@ void kfree_skb(struct sk_buff *skb) · 153 unmodified lines
651}644}
652EXPORT_SYMBOL(kfree_skb);645EXPORT_SYMBOL(kfree_skb);
653 646
647void kfree_skb_list(struct sk_buff *segs)
648{
649 while (segs) {
650 struct sk_buff *next = segs->next;
651
652 kfree_skb(segs);
653 segs = next;
654 }
655}
656EXPORT_SYMBOL(kfree_skb_list);
657
654/**658/**
655 * skb_tx_error - report an sk_buff xmit error659 * skb_tx_error - report an sk_buff xmit error
656 * @skb: buffer that triggered an error660 * @skb: buffer that triggered an error
net/ipv4/gre.c+1−1
@@ -178,7 +178,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb, · 177 unmodified lines
178 178
179 err = __skb_linearize(skb);179 err = __skb_linearize(skb);
180 if (err) {180 if (err) {
181 kfree_skb(segs);181 kfree_skb_list(segs);
182 segs = ERR_PTR(err);182 segs = ERR_PTR(err);
183 goto out;183 goto out;
184 }184 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t