ell.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 12/14] netconfig: Set a limit on number of routes from ICMPv6
@ 2022-06-15 22:47 Andrew Zaborowski
  0 siblings, 0 replies; only message in thread
From: Andrew Zaborowski @ 2022-06-15 22:47 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 1224 bytes --]

While some networks can be configured in a way that prevents rogue
Router Advertisements from reaching clients, add a very basic mechanism
to avoid a denial-of-service in such a case by limiting the number of
routes we track from RAs.  This won't prevent the loss of routing but
might prevent OOM crashes or slowdowns.
---
 ell/netconfig.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ell/netconfig.c b/ell/netconfig.c
index 197b69d..bcb2df9 100644
--- a/ell/netconfig.c
+++ b/ell/netconfig.c
@@ -133,6 +133,8 @@ union netconfig_addr {
 static struct l_queue *addr_wait_list;
 static unsigned int rtnl_id;
 
+static const unsigned int max_icmp6_routes = 100;
+
 static void netconfig_update_cleanup(struct l_netconfig *nc)
 {
 	l_queue_clear(nc->addresses.added, NULL);
@@ -743,6 +745,9 @@ static struct netconfig_route_data *netconfig_add_icmp6_route(
 	struct netconfig_route_data *rd;
 	struct l_rtnl_route *rt;
 
+	if (l_queue_length(nc->icmp_route_data) >= max_icmp6_routes)
+		return NULL;	/* TODO: log a warning the first time */
+
 	rt = netconfig_route_new(nc, AF_INET6, dst ? dst->address : NULL,
 					dst ? dst->prefix_len : 0, gateway,
 					RTPROT_RA);
-- 
2.34.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-15 22:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 22:47 [PATCH 12/14] netconfig: Set a limit on number of routes from ICMPv6 Andrew Zaborowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).