From nobody Thu Nov 21 20:55:34 2024 X-Original-To: dev-commits-src-main@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 4XvVqp70kqz5dZT6; Thu, 21 Nov 2024 20:55:34 +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 4XvVqp6BSXz4t0L; Thu, 21 Nov 2024 20:55:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732222534; 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=U2yGNW0mRaeW+5h/MoYxMoZ/oy0Y7hhfiVO0PX2jDrw=; b=vd3lz1T2aIRB0AZDSgSz3IRi+xoybxe46QzEjinEATzR1tHYmeBoD3qazyopo8xCjZkZ4h H2DLHbYXR9okqm/wJuVE4WgLaY37w9yfZ1fze4QRd6NztGnfQLkQAFMvQj0KQm71LBqVKz GalbyokXI9GZ7bFdARdLFKdL4t6FJZ15AY+xseMn5x9aOsilmDWFDM9ihS0Ixr9FvA9XBJ 7gj5+0wNV+Sjsp+K62hCe44zuieKpDGUsdItOEZzMBQNhcTf3rlGMD58RVR76FmYxcjLRB 41BX/59YNSJpm9Mr7CsZMbr1UZ0IO0VNKh0MHY0CmZtHUMsVSDLygYREQEL7Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732222534; 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=U2yGNW0mRaeW+5h/MoYxMoZ/oy0Y7hhfiVO0PX2jDrw=; b=N8p6r6Tbi3Lfn4Zo25R7pasamIzOq5eDZsf1oCbBziBhWZhTY8VQt5zKQb4cqegnAL28xN StIHFaH5iqLcImHcrTS4NOpJFfyrN6LjE5HEG+WnUx7IqrDD2hSkzIV2EZn+H9LOk/4tE6 1S6MaVB22LyXy41r6OJID0au5cNnZtOD2FeUfwT1M/kZAnPX6d54QSxtFKYaENPIYHe+q0 q3cEerCjbJKfZvIteWbJa4CSP3RlbKHZ7mF5Eg4H4oCJQABcKDZOYPTgHTUq/0dIfJVCfK YT0UhetnG6aFVvL2rRTBvSvnJWLRQZM0Z2r+TphrbSqDIJ8oTCxQFgm9OYkyzA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732222534; a=rsa-sha256; cv=none; b=Uhp9xGDBEK8hqyDWSWgqlsnTUqgef01CbTIj0eWkhOmdE4+AMG+32K1PQoaNXEpk2Yhhrc LDjzK7RTtYq201pcfup9Htw6SrzmQmN13tPLDNpq8e0AhSR/WLup4OyHm/ZiGLNpEfruQz RY/MjQz4FlpOhacU6ccE9disICbd1mD9xKR5hoR6+jpfLI8QY+rkSJw0TY1ByAno6MbKCl mav43unsZ7f2XjMG+plkXG/62TV97BpuyyJpDRWSRpork3eVeBbfnNyTDgF8zzDiPnLFB3 dGI/Ejd3pWlJiSmzm2LOXmUTk7xAq2TApYw7s8PstiFV8ixFID6PoGWTBN7chg== 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 4XvVqp5N4rzw4h; Thu, 21 Nov 2024 20:55:34 +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 4ALKtYc0037341; Thu, 21 Nov 2024 20:55:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4ALKtYK1037338; Thu, 21 Nov 2024 20:55:34 GMT (envelope-from git) Date: Thu, 21 Nov 2024 20:55:34 GMT Message-Id: <202411212055.4ALKtYK1037338@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: ae4f39464c61 - main - ng_parse: disallow negative length for malloc List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: ae4f39464c61182c2bdfd3cc61594f8707b3daf0 Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=ae4f39464c61182c2bdfd3cc61594f8707b3daf0 commit ae4f39464c61182c2bdfd3cc61594f8707b3daf0 Author: Ed Maste AuthorDate: 2022-11-01 14:01:29 +0000 Commit: Ed Maste CommitDate: 2024-11-21 20:53:04 +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 --- 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;