瀏覽代碼

net: neigh: guard against NULL solicit() method

Dmitry posted a nice reproducer of a bug triggering in neigh_probe()
when dereferencing a NULL neigh->ops->solicit method.

This can happen for arp_direct_ops/ndisc_direct_ops and similar,
which can be used for NUD_NOARP neighbours (created when dev->header_ops
is NULL). Admin can then force changing nud_state to some other state
that would fire neigh timer.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Eric Dumazet 8 年之前
父節點
當前提交
48481c8fa1
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      net/core/neighbour.c

+ 2 - 1
net/core/neighbour.c

@@ -860,7 +860,8 @@ static void neigh_probe(struct neighbour *neigh)
 	if (skb)
 	if (skb)
 		skb = skb_clone(skb, GFP_ATOMIC);
 		skb = skb_clone(skb, GFP_ATOMIC);
 	write_unlock(&neigh->lock);
 	write_unlock(&neigh->lock);
-	neigh->ops->solicit(neigh, skb);
+	if (neigh->ops->solicit)
+		neigh->ops->solicit(neigh, skb);
 	atomic_inc(&neigh->probes);
 	atomic_inc(&neigh->probes);
 	kfree_skb(skb);
 	kfree_skb(skb);
 }
 }