net: neigh: guard against NULL solicit() method
authorEric Dumazet <edumazet@google.com>
Thu, 23 Mar 2017 19:39:21 +0000 (12:39 -0700)
committerJiri Slaby <jslaby@suse.cz>
Tue, 9 May 2017 06:19:45 +0000 (08:19 +0200)
[ Upstream commit 48481c8fa16410ffa45939b13b6c53c2ca609e5f ]

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>
net/core/neighbour.c

index 7957daa334ccf0a3721323ef611cf0a7951979dd..3a6a4f11e8764a0193c7f31d1c5c0a624b9f677d 100644 (file)
@@ -872,7 +872,8 @@ static void neigh_probe(struct neighbour *neigh)
        if (skb)
                skb = skb_copy(skb, GFP_ATOMIC);
        write_unlock(&neigh->lock);
-       neigh->ops->solicit(neigh, skb);
+       if (neigh->ops->solicit)
+               neigh->ops->solicit(neigh, skb);
        atomic_inc(&neigh->probes);
        kfree_skb(skb);
 }