gre: fix improper error handling
[ Upstream commit 559fafb94ad9e4cd8774f39241917c57396f9fc5 ] Fix improper protocol err_handler, current implementation is fully unapplicable and may cause kernel crash due to double kfree_skb. Signed-off-by: Dmitry Kozlov <xeb@mail.ru> Acked-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
cb737cb029
commit
06e67267ad
@@ -15,6 +15,7 @@
|
|||||||
#include <linux/kmod.h>
|
#include <linux/kmod.h>
|
||||||
#include <linux/skbuff.h>
|
#include <linux/skbuff.h>
|
||||||
#include <linux/in.h>
|
#include <linux/in.h>
|
||||||
|
#include <linux/ip.h>
|
||||||
#include <linux/netdevice.h>
|
#include <linux/netdevice.h>
|
||||||
#include <linux/version.h>
|
#include <linux/version.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
@@ -97,27 +98,17 @@ drop:
|
|||||||
static void gre_err(struct sk_buff *skb, u32 info)
|
static void gre_err(struct sk_buff *skb, u32 info)
|
||||||
{
|
{
|
||||||
const struct gre_protocol *proto;
|
const struct gre_protocol *proto;
|
||||||
u8 ver;
|
const struct iphdr *iph = (const struct iphdr *)skb->data;
|
||||||
|
u8 ver = skb->data[(iph->ihl<<2) + 1]&0x7f;
|
||||||
|
|
||||||
if (!pskb_may_pull(skb, 12))
|
|
||||||
goto drop;
|
|
||||||
|
|
||||||
ver = skb->data[1]&0x7f;
|
|
||||||
if (ver >= GREPROTO_MAX)
|
if (ver >= GREPROTO_MAX)
|
||||||
goto drop;
|
return;
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
proto = rcu_dereference(gre_proto[ver]);
|
proto = rcu_dereference(gre_proto[ver]);
|
||||||
if (!proto || !proto->err_handler)
|
if (proto && proto->err_handler)
|
||||||
goto drop_unlock;
|
|
||||||
proto->err_handler(skb, info);
|
proto->err_handler(skb, info);
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
return;
|
|
||||||
|
|
||||||
drop_unlock:
|
|
||||||
rcu_read_unlock();
|
|
||||||
drop:
|
|
||||||
kfree_skb(skb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct net_protocol net_gre_protocol = {
|
static const struct net_protocol net_gre_protocol = {
|
||||||
|
|||||||
Reference in New Issue
Block a user