]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nexthops: don't modify published nexthop groups
authorNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Tue, 26 May 2020 18:56:15 +0000 (12:56 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Jun 2020 06:23:36 +0000 (08:23 +0200)
commit62524a84b6ce6eef41668334cbd213870ac02614
tree018bf816ebc5020beec4f63c431d49fbb1604937
parentcf424af7fa19f3c71b523af45594b7cbcc057502
nexthops: don't modify published nexthop groups

commit 90f33bffa382598a32cc82abfeb20adc92d041b6 upstream.

We must avoid modifying published nexthop groups while they might be
in use, otherwise we might see NULL ptr dereferences. In order to do
that we allocate 2 nexthoup group structures upon nexthop creation
and swap between them when we have to delete an entry. The reason is
that we can't fail nexthop group removal, so we can't handle allocation
failure thus we move the extra allocation on creation where we can
safely fail and return ENOMEM.

Fixes: 430a049190de ("nexthop: Add support for nexthop groups")
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/net/nexthop.h
net/ipv4/nexthop.c