aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm
diff options
context:
space:
mode:
authorSteffen Klassert <steffen.klassert@secunet.com>2013-08-28 02:47:14 -0400
committerSteffen Klassert <steffen.klassert@secunet.com>2013-08-28 02:47:14 -0400
commit302a50bc941010d7a67f288fd0db31981e4d722d (patch)
tree162abbe125b769187a43c8d7ed133765d2134c7a /net/xfrm
parent9c9c9ad5fae7e9ef56a38acb508a01919b225e9a (diff)
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>
Diffstat (limited to 'net/xfrm')
-rw-r--r--net/xfrm/xfrm_policy.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index e52cab3591dd..f77c371ea72b 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -320,10 +320,8 @@ static void xfrm_queue_purge(struct sk_buff_head *list)
320{ 320{
321 struct sk_buff *skb; 321 struct sk_buff *skb;
322 322
323 while ((skb = skb_dequeue(list)) != NULL) { 323 while ((skb = skb_dequeue(list)) != NULL)
324 dev_put(skb->dev);
325 kfree_skb(skb); 324 kfree_skb(skb);
326 }
327} 325}
328 326
329/* Rule must be locked. Release descentant resources, announce 327/* Rule must be locked. Release descentant resources, announce
@@ -1758,7 +1756,6 @@ static void xfrm_policy_queue_process(unsigned long arg)
1758 struct sk_buff *skb; 1756 struct sk_buff *skb;
1759 struct sock *sk; 1757 struct sock *sk;
1760 struct dst_entry *dst; 1758 struct dst_entry *dst;
1761 struct net_device *dev;
1762 struct xfrm_policy *pol = (struct xfrm_policy *)arg; 1759 struct xfrm_policy *pol = (struct xfrm_policy *)arg;
1763 struct xfrm_policy_queue *pq = &pol->polq; 1760 struct xfrm_policy_queue *pq = &pol->polq;
1764 struct flowi fl; 1761 struct flowi fl;
@@ -1805,7 +1802,6 @@ static void xfrm_policy_queue_process(unsigned long arg)
1805 dst = xfrm_lookup(xp_net(pol), skb_dst(skb)->path, 1802 dst = xfrm_lookup(xp_net(pol), skb_dst(skb)->path,
1806 &fl, skb->sk, 0); 1803 &fl, skb->sk, 0);
1807 if (IS_ERR(dst)) { 1804 if (IS_ERR(dst)) {
1808 dev_put(skb->dev);
1809 kfree_skb(skb); 1805 kfree_skb(skb);
1810 continue; 1806 continue;
1811 } 1807 }
@@ -1814,9 +1810,7 @@ static void xfrm_policy_queue_process(unsigned long arg)
1814 skb_dst_drop(skb); 1810 skb_dst_drop(skb);
1815 skb_dst_set(skb, dst); 1811 skb_dst_set(skb, dst);
1816 1812
1817 dev = skb->dev;
1818 err = dst_output(skb); 1813 err = dst_output(skb);
1819 dev_put(dev);
1820 } 1814 }
1821 1815
1822 return; 1816 return;
@@ -1839,7 +1833,6 @@ static int xdst_queue_output(struct sk_buff *skb)
1839 } 1833 }
1840 1834
1841 skb_dst_force(skb); 1835 skb_dst_force(skb);
1842 dev_hold(skb->dev);
1843 1836
1844 spin_lock_bh(&pq->hold_queue.lock); 1837 spin_lock_bh(&pq->hold_queue.lock);
1845 1838