Embedded Linux Library
 help / color / mirror / Atom feed
From: Ryan Walklin <ryan@testtoast.com>
To: ell@lists.linux.dev
Cc: Ryan Walklin <ryan@testtoast.com>
Subject: [PATCH 2/6] netconfig: Fix leak of RA route data
Date: Tue, 17 Nov 2026 11:27:48 +1300	[thread overview]
Message-ID: <20261116222756.2921577-3-ryan@testtoast.com> (raw)
In-Reply-To: <20261116222756.2921577-1-ryan@testtoast.com>

netconfig_remove_icmp6_route() and netconfig_check_route_expired() drop
the struct netconfig_route_data from icmp_route_data without freeing it,
leaking 32 bytes for every RA route that's withdrawn or expires.  Free
it in both places.

Also free the route itself if it was still on the added list, i.e. it
was never passed to the user, since it's then on no other list that
would free it.

Fixes: 6eb8b8bccdcb ("netconfig: Ratelimit route lifetime updates")
---
 ell/netconfig.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/ell/netconfig.c b/ell/netconfig.c
index 2444d97..1be26ad 100644
--- a/ell/netconfig.c
+++ b/ell/netconfig.c
@@ -953,12 +953,16 @@ static bool netconfig_check_route_expired(void *data, void *user_data)
 	 * If for some reason the route is still on the added list, drop it
 	 * from there and there's nothing to notify the user of.
 	 */
-	if (!l_queue_remove(nc->routes.added, rd->route))
-		l_queue_push_tail(nc->routes.expired, rd->route);
-
 	l_queue_remove(nc->routes.current, rd->route);
 	l_queue_remove(nc->routes.updated, rd->route);
 	l_queue_remove(nc->routes.removed, rd->route);
+
+	if (l_queue_remove(nc->routes.added, rd->route))
+		l_rtnl_route_free(rd->route);
+	else
+		l_queue_push_tail(nc->routes.expired, rd->route);
+
+	l_free(rd);
 	return true;
 }
 
@@ -1137,8 +1141,13 @@ static void netconfig_remove_icmp6_route(struct l_netconfig *nc,
 	l_queue_remove(nc->routes.current, rd->route);
 	l_queue_remove(nc->routes.updated, rd->route);
 
-	if (!l_queue_remove(nc->routes.added, rd->route))
+	/* Not committed yet so there's nothing for the user to remove */
+	if (l_queue_remove(nc->routes.added, rd->route))
+		l_rtnl_route_free(rd->route);
+	else
 		l_queue_push_tail(nc->routes.removed, rd->route);
+
+	l_free(rd);
 }
 
 static void netconfig_icmp6_event_handler(struct l_icmp6_client *client,
-- 
2.55.0


  parent reply	other threads:[~2026-11-16 22:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 22:27 [PATCH 0/6] netconfig: RA route, SLAAC lifetime and DNS fixes Ryan Walklin
2026-11-16 22:27 ` [PATCH 1/6] netconfig: Allocate the expired lists Ryan Walklin
2026-11-16 22:27 ` Ryan Walklin [this message]
2026-11-16 22:27 ` [PATCH 3/6] netconfig: Expire RA routes never refreshed Ryan Walklin
2026-11-16 22:27 ` [PATCH 4/6] netconfig: Fix the RFC 4862 2-hour rule Ryan Walklin
2026-11-16 22:27 ` [PATCH 5/6] netconfig: Skip duplicate DNS servers and domains Ryan Walklin
2026-11-16 22:27 ` [PATCH 6/6] icmp6: Fix RA leak when stopped from a handler Ryan Walklin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261116222756.2921577-3-ryan@testtoast.com \
    --to=ryan@testtoast.com \
    --cc=ell@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox