Commit 559fafb9 authored by xeb@mail.ru's avatar xeb@mail.ru Committed by David S. Miller

gre: fix improper error handling

Fix improper protocol err_handler, current implementation is fully
unapplicable and may cause kernel crash due to double kfree_skb.
Signed-off-by: default avatarDmitry Kozlov <xeb@mail.ru>
Acked-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b0fe4a31
......@@ -15,6 +15,7 @@
#include <linux/kmod.h>
#include <linux/skbuff.h>
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/netdevice.h>
#include <linux/spinlock.h>
#include <net/protocol.h>
......@@ -96,27 +97,17 @@ static int gre_rcv(struct sk_buff *skb)
static void gre_err(struct sk_buff *skb, u32 info)
{
const struct gre_protocol *proto;
u8 ver;
if (!pskb_may_pull(skb, 12))
goto drop;
const struct iphdr *iph = (const struct iphdr *)skb->data;
u8 ver = skb->data[(iph->ihl<<2) + 1]&0x7f;
ver = skb->data[1]&0x7f;
if (ver >= GREPROTO_MAX)
goto drop;
return;
rcu_read_lock();
proto = rcu_dereference(gre_proto[ver]);
if (!proto || !proto->err_handler)
goto drop_unlock;
proto->err_handler(skb, info);
rcu_read_unlock();
return;
drop_unlock:
if (proto && proto->err_handler)
proto->err_handler(skb, info);
rcu_read_unlock();
drop:
kfree_skb(skb);
}
static const struct net_protocol net_gre_protocol = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment