From: Eric Dumazet <hidden> Date: 2011-07-06 15:18:22
Le mercredi 06 juillet 2011 à 14:06 +0000, Penttilä Mika a écrit :
quoted
+static struct sk_buff *fanout_check_defrag(struct sk_buff *skb)
+{
+ const struct iphdr *iph;
+ u32 len;
+
+ if (skb->protocol != htons(ETH_P_IP))
+ return skb;
+
+ if (!pskb_may_pull(skb, sizeof(struct iphdr)))
+ return skb;
+
+ iph = ip_hdr(skb);
+ if (iph->ihl < 5 || iph->version != 4)
+ return skb;
+ if (!pskb_may_pull(skb, iph->ihl*4))
+ return skb;
+ iph = ip_hdr(skb);
+ len = ntohs(iph->tot_len);
+ if (skb->len < len || len < (iph->ihl * 4))
+ return skb;
+
+ if (ip_is_fragment(ip_hdr(skb))) {
+ skb = skb_clone(skb, GFP_ATOMIC);
Isn't this leaking the original skb?
Yes, there are several problems here.
More fundamentally, there is a problem if two (or more) applications use
FANOUT sockets.
Only one will get the defragmented packet.
We probably need to have separate frag lists, or adding/using skb->sk as
a key.
Thanks
[PATCH] packet: fix a leak in fanout_check_defrag()
Reported-by: Penttilä Mika <redacted>
Signed-off-by: Eric Dumazet <redacted>
---
net/packet/af_packet.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
[PATCH] packet: fix a leak in fanout_check_defrag()
Reported-by: Penttilä Mika <redacted>
Signed-off-by: Eric Dumazet <redacted>
Eric, see what I commited, it's much simpler than all
of this code movement you added, ala skb_share_check()
:-)
I tried to not lose the original packet and let application catch it ;)
We probably need to add some atomic_inc(&sk->sk_drops) to at least warn
the application.