From nobody Fri May 17 16:46:59 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 4VgtCl5MWqz5LRl6; Fri, 17 May 2024 16:46:59 +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 4VgtCl4QcRz4X91; Fri, 17 May 2024 16:46:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715964419; 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=4oRCtMAbvAVrOWQDv2uMZofx8iadoJfA86BColKX2BU=; b=MVstPg3SL0+/AGlTsDuFSGt/Ck9rE8v6cSlTxTQjTr59NN7tmovEOR4n/Xr8NKO3ws8Ywl dPDdOXJfN6Rj0hOflPAwfcT+6GtRea16vx3MAVTMSIbpYbhJoawcyyhqaAoOTGyovhq93d 2mPHllh8KNkMo3afkSnvlgGhVBazdNAOWYqSc/5YeVo0V2i4r0TGJF96LdLh7D0WLa6PmM bIpq7z0veMAQKfiJWtVV1/npXaBT03oXX/wxz0D2A547D7LUBgCTCt/cHaFQk462vAg4CS 9jSYNfNFmFXQ7GFr5KQp8iWf/xywO80XdALTWnsRKN0dHqV9UK/ZHhPnPJ0zMg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715964419; a=rsa-sha256; cv=none; b=GbFCfR0OvvsCPN1wjkAwEbC7p4FIv6B34GkoUJagyhPXSJYRMHoVP8Qbz7NPdKkJUlJCFI HcRVTw7dF9gTUiaRG5bWqaBDPH34rKW9BIwHZSG6rP0kZ0WxEpyQcDRlQCg4q6sM1RSgBc lyLiCTpMsveAyC7uUlZJuwapHcprsLe92yHs4BjK70tFkTn/37ynHRKvg1eEhbGtOAUosI aHXp2RlLA9oyz3JA934gw9bdnwEvL24exo+y9b9Me9GzXuUscn7oXTSFOVbnq0T1X6B8M8 7Y7uhane9vT9CV8LSzKLG0XPiqa3tOXH1FDRwt9sO0AIBQh296rAvKhdUQ35DA== 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=1715964419; 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=4oRCtMAbvAVrOWQDv2uMZofx8iadoJfA86BColKX2BU=; b=mS16pW5SBDzBRxDSZt6Wijs4jVwGJiu3BHSpPd6J/WJCHsZDtXosxyQYpTLuizyZ8APSZ+ kF1KvCHIkiGWVZVnFRCaK3B7TLNgB5X6Tnkt+ICXZ/rfqZ8HkOIbjr5Axk3S4BdVJZ94Qi X+I4+z5LBYgDnyIFrHkesCNwxN3wsDR393B+5OvnpsEb9DtUEk2/tzvMSTHjry4VtqcC1b N50mKAWAbj/+aABQ1HvfjvxTdpxbaz513nOg3a/WockZaGqVWMUjL+FcIGcOc4hokvH9TM ffxBVD6k+qoY+kDvPcG/5IP5hGBV5RQfS2vV5Vl5vSvXjMV3h/mcT/BHxKwMUA== 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 4VgtCl3x75zq7t; Fri, 17 May 2024 16:46:59 +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 44HGkx0i016375; Fri, 17 May 2024 16:46:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44HGkxS4016372; Fri, 17 May 2024 16:46:59 GMT (envelope-from git) Date: Fri, 17 May 2024 16:46:59 GMT Message-Id: <202405171646.44HGkxS4016372@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marko Zec Subject: git: 19bd24caa4c8 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 19bd24caa4c8c76ddf138b3a1598a21c8c5c3291 Auto-Submitted: auto-generated The branch main has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=19bd24caa4c8c76ddf138b3a1598a21c8c5c3291 commit 19bd24caa4c8c76ddf138b3a1598a21c8c5c3291 Author: Marko Zec AuthorDate: 2024-05-17 16:36:21 +0000 Commit: Marko Zec CommitDate: 2024-05-17 16:46:41 +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 --- 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);