mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 22:14:04 +02:00
ipv6: route: Fix return value of ip6_neigh_lookup() on neigh_create() error
[ Upstream commit7adf324609] In ip6_neigh_lookup(), we must not return errors coming from neigh_create(): if creation of a neighbour entry fails, the lookup should return NULL, in the same way as it's done in __neigh_lookup(). Otherwise, callers legitimately checking for a non-NULL return value of the lookup function might dereference an invalid pointer. For instance, on neighbour table overflow, ndisc_router_discovery() crashes ndisc_update() by passing ERR_PTR(-ENOBUFS) as 'neigh' argument. Reported-by: Jianlin Shi <jishi@redhat.com> Fixes:f8a1b43b70("net/ipv6: Create a neigh_lookup for FIB entries") Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2210c2737e
commit
ccc8b37473
|
|
@ -210,7 +210,9 @@ struct neighbour *ip6_neigh_lookup(const struct in6_addr *gw,
|
|||
n = __ipv6_neigh_lookup(dev, daddr);
|
||||
if (n)
|
||||
return n;
|
||||
return neigh_create(&nd_tbl, daddr, dev);
|
||||
|
||||
n = neigh_create(&nd_tbl, daddr, dev);
|
||||
return IS_ERR(n) ? NULL : n;
|
||||
}
|
||||
|
||||
static struct neighbour *ip6_dst_neigh_lookup(const struct dst_entry *dst,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user