From nobody Wed May 22 17:38:09 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Vkz6V0n4Yz5M66q; Wed, 22 May 2024 17:38:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Vkz6V00Ccz4lGF; Wed, 22 May 2024 17:38:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716399490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5Mfdp7d2OokRW21Y1f4Wc+e5dztvlykk1Cz6M46gu5o=; b=B+pyQYz85ndKUUmT23t0wtfSErF0MTSqUJLpmN/UX8KXt+RQkFrEkX0Gl0fsCl/USgeYwB W9+wlTfFrqo3VOlWLZg+60DwVHyC62CLzE7WJCLcGxP8QAQWE+6jxdfui2rbwLt6SGirqE NIkppDsklhvoGUl4M7PRo/AtDtAHV+2Xr/RG4f6Xo25IOlk35s/hxnJ6wcddktNPDoysys 4LkSbrB1C0ogatIgrhk/z23LyPfSSWY/KOaGTgU0ujV8cnc94KAVNsU3GJ8UBVu8yys7fx kU4MeiGAUumJCCiDZ/i5Wxef4E6zPrjhtv05E70UBCynwmAZ1P5/a1kEZMpoBg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716399490; a=rsa-sha256; cv=none; b=U6jlwr1RjtUgkkHzjdAbZGxx4nGIE1b4AomiPOL6/ve7FKzjFN31yk1hLpIutrdsLAHl/9 JxwjBP9rCvexsdWb87c171A9qNF7bpL1YwlY5RlrSuvCkGJNRUSmlSL0WI0+r01/5sU5j3 JeqBoX9oac7dNBEc19ED2chUMC04zTkNbDdYum113DlR34ovKtF1xsqrT8Kh5UqfkqbOec pMuccefJQ3OHwvgX/RmihKAIGIDew1LuxdFz1w1McKadaMUWo0OepbOtjrVkJ4kEeMeXs5 Z384lrxT83E0LR5tRCwWHKlEjkKKKl16StrhPu/Tkb6E4xn8GgotK5XCyMYN0Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716399490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5Mfdp7d2OokRW21Y1f4Wc+e5dztvlykk1Cz6M46gu5o=; b=yTySAqHBeZgkQrzjvYiKFJ7mZrAQejlmfPgj3yi9pjrXH3RkVVxQGQOeN+/FUNm5/oQO8W iObtJOquSYGKXV5OYoAEMimahRYZEoVRpH2T2fFQ8HKFgxMZwoMhlvPtMIio2y4g38iXUY ZqM93TilezS+fjP/G8Yz0o8hJeTItG7qdPDurnuoRa7mG9F+o43tulQgIFO3HLeC0yp+A4 KHx98bdC4vcr+qW3rkKGPERD+dknk0xQbyhcBbjWw8PV1ojPgUs66eZ5tdUlYRI/uLniXd zD2aa6dvnXj1s80ZQYdYw1upJ850J82Uykas9GMg4smBYa40rnkBUxjiaFRAKw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Vkz6T6dGszFGM; Wed, 22 May 2024 17:38:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44MHc9J9027295; Wed, 22 May 2024 17:38:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44MHc9Zk027292; Wed, 22 May 2024 17:38:09 GMT (envelope-from git) Date: Wed, 22 May 2024 17:38:09 GMT Message-Id: <202405221738.44MHc9Zk027292@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marko Zec Subject: git: 56d8fb274847 - stable/13 - fib_dxr: do not leak memory if FIB constellation hits structural limit List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zec X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 56d8fb27484746416a74c8bd36aacc9edd0f4794 Auto-Submitted: auto-generated The branch stable/13 has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=56d8fb27484746416a74c8bd36aacc9edd0f4794 commit 56d8fb27484746416a74c8bd36aacc9edd0f4794 Author: Marko Zec AuthorDate: 2024-05-17 16:36:21 +0000 Commit: Marko Zec 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);