From nobody Wed Nov 22 13:49:20 2023 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 4Sb2fS4q6Hz51f6w; Wed, 22 Nov 2023 13:49:20 +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 4Sb2fS4Gcbz4NMc; Wed, 22 Nov 2023 13:49:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700660960; 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=r877dg+P0XyDZUtuVE6XXvGQeIYbRRvgX/U4VzBMpRc=; b=Gu3wwtVU29ubIcEONbrYx3cIRCY52vnnWcEQq7U0qI/3KIYCtI/bLDJdeJySGzfA+pSxyh pcZSNv7ZDcJYvzCJsFfuaT1IXRS5jCrHf9mKzlC116u2TVV7Dv2YaYIbSzOZe55VnvUSd1 yF6aSn+tF34i3IjevYdflbYAr5iGsP7lg070We5mGlCDuUXX0coq+XBlV/maIPc2mKFNkl 4eY0YwpajV/fqWQLcK1oQ3PzXKmrAJVjYzH/uyfjNcaZnaTIHv/bB4LHypIKVT452v542g lA+G1+hVuxPPd/tA5ZMLaExCji/IB+WA+bjyhUFTOH45t/UwnwRUfE7OuGd1iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700660960; 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=r877dg+P0XyDZUtuVE6XXvGQeIYbRRvgX/U4VzBMpRc=; b=kbVWdRa2TnMRn6zkCILX+7Sq3kJUhXeE23c7b/Vh8nI3gh/heDEawRFQ3DvzPjMAhEUziK eIjYKGa7tz3UwPk9O6co6hiduDsyuFDrPeMAj9BgJCCHNdQMIgBbjYkm7SYSldCCSQTpWU /BoURcOiVYulD0Y7/sGChFXwFFhj6PuUnMSL7AGeJ3OgTY3cO+ygZjWrVoNuUgrId/Eji6 B8hW8amQu0yf/2SC2FuzLzcgPWkdOrRkiHwAL0/MwuP+WuqaLFwQXoF/yk7Fh6x8buvr41 XpCtoXGkkTPVvaE1dCtYTABYxRnRVpS0j3OVOIE6ERMUHfsVDkN+tv5dnpC1ew== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700660960; a=rsa-sha256; cv=none; b=bR0FGmCijix8+kQ1jq2uhFqMLeLXD/szu1XtEqBixke4p7+vUfB4YftS+F1UW401gyHubN nbR5rnshr5Eil8RjObzjTricM5YXYPAemwXC/Zjj7UxOXM16WUABe4qVvwfWOStmmGNIfs vPlzmkcxZWt40OmWafjttUcR29uRPkOif7kGp0lyejFXf59j5G8NjNa1dzyIZ9JQn38Qoi 6rSWP1/dmpN6dbU3VCmgSKJmY7C+//1nEi9CTAR/L443qm0qph3DPKR1RGrTNVPv2hOTR0 JBTDS5x/YB04oVOgaXrF3zuYwsrhm7IeqodSyqon1XId+DZ/mW2kWsTo8G+5+g== 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 4Sb2fS3KBPz6BD; Wed, 22 Nov 2023 13:49:20 +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 3AMDnKHO068976; Wed, 22 Nov 2023 13:49:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AMDnKZk068973; Wed, 22 Nov 2023 13:49:20 GMT (envelope-from git) Date: Wed, 22 Nov 2023 13:49:20 GMT Message-Id: <202311221349.3AMDnKZk068973@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: b01cad6d3a85 - main - ip_mroute: handle V_mfchashtbl allocation failure 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b01cad6d3a8523101e7915809144f47e3045067f Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b01cad6d3a8523101e7915809144f47e3045067f commit b01cad6d3a8523101e7915809144f47e3045067f Author: Kristof Provost AuthorDate: 2023-11-22 13:44:03 +0000 Commit: Kristof Provost CommitDate: 2023-11-22 13:47:14 +0000 ip_mroute: handle V_mfchashtbl allocation failure We allocate V_mfchashtbl with HASH_NOWAIT (which maps to M_NOWAIT), so this allocation may fail. As we didn't handle that failure we could end up dereferencing a NULL pointer later (e.g. during X_ip_mrouter_done()). Do the obvious thing and fail out if we cannot allocate the table. See also: https://redmine.pfsense.org/issues/14917 Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netinet/ip_mroute.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index cda5f160e8fb..f789c6eed835 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -708,6 +708,10 @@ ip_mrouter_init(struct socket *so, int version) V_mfchashtbl = hashinit_flags(mfchashsize, M_MRTABLE, &V_mfchash, HASH_NOWAIT); + if (V_mfchashtbl == NULL) { + MRW_WUNLOCK(); + return (ENOMEM); + } /* Create upcall ring */ mtx_init(&V_bw_upcalls_ring_mtx, "mroute upcall buf_ring mtx", NULL, MTX_DEF);