mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-06 00:39:48 +00:00
xfrm: Fix potential null pointer dereference in xdst_queue_output
The net_device might be not set on the skb when we try refcounting. This leads to a null pointer dereference in xdst_queue_output(). It turned out that the refcount to the net_device is not needed after all. The dst_entry has a refcount to the net_device before we queue the skb, so it can't go away. Therefore we can remove the refcount on queueing to fix the null pointer dereference. Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
parent
9c9c9ad5fa
commit
302a50bc94
1 changed files with 1 additions and 8 deletions
|
@ -320,11 +320,9 @@ static void xfrm_queue_purge(struct sk_buff_head *list)
|
||||||
{
|
{
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
|
|
||||||
while ((skb = skb_dequeue(list)) != NULL) {
|
while ((skb = skb_dequeue(list)) != NULL)
|
||||||
dev_put(skb->dev);
|
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Rule must be locked. Release descentant resources, announce
|
/* Rule must be locked. Release descentant resources, announce
|
||||||
* entry dead. The rule must be unlinked from lists to the moment.
|
* entry dead. The rule must be unlinked from lists to the moment.
|
||||||
|
@ -1758,7 +1756,6 @@ static void xfrm_policy_queue_process(unsigned long arg)
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
struct sock *sk;
|
struct sock *sk;
|
||||||
struct dst_entry *dst;
|
struct dst_entry *dst;
|
||||||
struct net_device *dev;
|
|
||||||
struct xfrm_policy *pol = (struct xfrm_policy *)arg;
|
struct xfrm_policy *pol = (struct xfrm_policy *)arg;
|
||||||
struct xfrm_policy_queue *pq = &pol->polq;
|
struct xfrm_policy_queue *pq = &pol->polq;
|
||||||
struct flowi fl;
|
struct flowi fl;
|
||||||
|
@ -1805,7 +1802,6 @@ static void xfrm_policy_queue_process(unsigned long arg)
|
||||||
dst = xfrm_lookup(xp_net(pol), skb_dst(skb)->path,
|
dst = xfrm_lookup(xp_net(pol), skb_dst(skb)->path,
|
||||||
&fl, skb->sk, 0);
|
&fl, skb->sk, 0);
|
||||||
if (IS_ERR(dst)) {
|
if (IS_ERR(dst)) {
|
||||||
dev_put(skb->dev);
|
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1814,9 +1810,7 @@ static void xfrm_policy_queue_process(unsigned long arg)
|
||||||
skb_dst_drop(skb);
|
skb_dst_drop(skb);
|
||||||
skb_dst_set(skb, dst);
|
skb_dst_set(skb, dst);
|
||||||
|
|
||||||
dev = skb->dev;
|
|
||||||
err = dst_output(skb);
|
err = dst_output(skb);
|
||||||
dev_put(dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -1839,7 +1833,6 @@ static int xdst_queue_output(struct sk_buff *skb)
|
||||||
}
|
}
|
||||||
|
|
||||||
skb_dst_force(skb);
|
skb_dst_force(skb);
|
||||||
dev_hold(skb->dev);
|
|
||||||
|
|
||||||
spin_lock_bh(&pq->hold_queue.lock);
|
spin_lock_bh(&pq->hold_queue.lock);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue