Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 May 2024 17:38:09 GMT
From:      Marko Zec <zec@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 56d8fb274847 - stable/13 - fib_dxr: do not leak memory if FIB constellation hits structural limit
Message-ID:  <202405221738.44MHc9Zk027292@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by zec:

URL: https://cgit.FreeBSD.org/src/commit/?id=56d8fb27484746416a74c8bd36aacc9edd0f4794

commit 56d8fb27484746416a74c8bd36aacc9edd0f4794
Author:     Marko Zec <zec@FreeBSD.org>
AuthorDate: 2024-05-17 16:36:21 +0000
Commit:     Marko Zec <zec@FreeBSD.org>
CommitDate: 2024-05-22 17:37:43 +0000

    fib_dxr: do not leak memory if FIB constellation hits structural limit
    
    DXR lookup table encoding has an inherent structural limit on the amount
    of binary search ranges it can accomodate.  With the current IPv4 BGP views
    (circa 1 M prefixes) and default DXR encoding we are only at around 5% of
    that limit, so far, far away from hitting it.  Just in case it ever gets
    hit, make sure we free the allocated structures, instead of leaking it.
    
    MFC after:      1 week
    
    (cherry picked from commit 19bd24caa4c8c76ddf138b3a1598a21c8c5c3291)
---
 sys/netinet/in_fib_dxr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/netinet/in_fib_dxr.c b/sys/netinet/in_fib_dxr.c
index 539d7fe6c96f..326710cc4c45 100644
--- a/sys/netinet/in_fib_dxr.c
+++ b/sys/netinet/in_fib_dxr.c
@@ -1320,8 +1320,10 @@ dxr_change_rib_batch(struct rib_head *rnh, struct fib_change_queue *q,
 	dxr_build(new_dxr);
 
 	/* Structural limit exceeded, hard error */
-	if (da->rtbl_top >= BASE_MAX)
+	if (da->rtbl_top >= BASE_MAX) {
+		dxr_destroy(new_dxr);
 		return (FLM_ERROR);
+	}
 
 	if (new_dxr->d == NULL) {
 		dxr_destroy(new_dxr);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202405221738.44MHc9Zk027292>