From nobody Mon Dec 02 21:10:46 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 4Y2GfH0rQCz5gRfd; Mon, 02 Dec 2024 21:10:47 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y2GfH02PDz42GP; Mon, 2 Dec 2024 21:10:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733173847; 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=rNkj8SdmgCHs077FJVUEaFY5qMcQJJ3ArvxOHyFHMPs=; b=Uzg3JAVgFnVyb/ND6mActi+hDego6lG405QPXUBiY2/zj9hJ9w9VAa/kULgqy/ZLEP0U3G XZ2M8X4Pf60dk7XEkqGmLiByw4onTA6HgB8qccUS8IGrR2fb8y3PFWpJyfPTYEcQWO8jv4 XJu3UWqSqyj95YogKozToh36spq3XIFlTpV3Yf3dpi8IIqCRBl5Jep+99pljBVnBD5Z/um TYT9PJWid/E9lB98OhnWFJ0RhjghZJxCb6RfQmNldJ7XhB1X8isP44zaMz+MeHz21otCBc CsAI9lrrF7Low8HoAurmrNkXm+LNhVXrM/wKXO2PFVtX1rKP1OT2L0wdg0TZQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733173847; 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=rNkj8SdmgCHs077FJVUEaFY5qMcQJJ3ArvxOHyFHMPs=; b=uOrFeTq6slg9XQNYxA810c93NCl0HSNJrTW90/BLpVS3LxBfeVrjVDspirQqhVe8jbd1Pc 66Nwo6gSXVEW214wgOx346CRO8pIOe1WykGD1nw95j4xGY3e+dlJxIIVmU8ioVszlrTxLh HuXGjztdN1QcwAOcri4DkQU+tVPqTHtf8oTlbH+S2CUv4skExHqFdlbOgxi/dk5C2+XE9L l7Ua0Y+K79nLnhKutPY5TgeIacZGp22JxyUdV9SgW0AJY9Zy6Gl2hdM9M5DDhJaAIVHCVV /nU7aoUaL14DMBPkxb3OssQHfyLL+eJBWu5kGipKWoWfy7aDkuteG4U+OO256g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733173847; a=rsa-sha256; cv=none; b=ll/29zSEP5QWLGQVMwAHR+r+xk1IxQU5hmx9a3k+lxdsz9jVeqz6XtTM5I061QoNZ+td7M 6BoTMwBFaAF6PrBqvMJKwOx0+alyapCKv8F4Nw4zIWYaVtArerSHILPylHj8d0oBPr0/va lxsKEklCosb0x2GU0TWxFwlQOrxp0rGdg1Y5rrvN/pTckdelbKiySr6A9G5pASXgrbhDMf NLTAYg+EVsprMjShKO9YtGB9Pl3WZNRSOuLfWYy4Qb7OY2Ub1wj6lspxjFxbAyCCgCVv17 ElJIHIzc8PO/NpT+14ldso7L8R+LCQleUxSqFcA6RjkjVb/lSZajuQQKwNlthA== 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 4Y2GfG6m8lztF9; Mon, 2 Dec 2024 21:10:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4B2LAkVO002630; Mon, 2 Dec 2024 21:10:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B2LAkFf002627; Mon, 2 Dec 2024 21:10:46 GMT (envelope-from git) Date: Mon, 2 Dec 2024 21:10:46 GMT Message-Id: <202412022110.4B2LAkFf002627@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 0e0329c6dbab - stable/14 - ng_parse: disallow negative length for malloc 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: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 0e0329c6dbabc12f5ab08bb63929a2ba6d506084 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=0e0329c6dbabc12f5ab08bb63929a2ba6d506084 commit 0e0329c6dbabc12f5ab08bb63929a2ba6d506084 Author: Ed Maste AuthorDate: 2022-11-01 14:01:29 +0000 Commit: Ed Maste CommitDate: 2024-12-02 21:10:31 +0000 ng_parse: disallow negative length for malloc This is an interim robustness improvement; further improvements as described in the PR and/or Phabricator review are still needed. PR: 267334 Reported by: Robert Morris Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D37229 (cherry picked from commit ae4f39464c61182c2bdfd3cc61594f8707b3daf0) --- sys/netgraph/ng_parse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/netgraph/ng_parse.c b/sys/netgraph/ng_parse.c index e11070274484..1a1d9d8b3064 100644 --- a/sys/netgraph/ng_parse.c +++ b/sys/netgraph/ng_parse.c @@ -1207,6 +1207,8 @@ ng_parse_composite(const struct ng_parse_type *type, const char *s, int align, len, blen, error = 0; /* Initialize */ + if (num < 0) + return (EINVAL); foff = malloc(num * sizeof(*foff), M_NETGRAPH_PARSE, M_NOWAIT | M_ZERO); if (foff == NULL) { error = ENOMEM;