From nobody Thu Sep 4 13:05:42 2025 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 4cHfqC30vMz66000; Thu, 04 Sep 2025 13:05:43 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cHfqC0gl3z3NJc; Thu, 04 Sep 2025 13:05:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756991143; 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=sXD+hjY4dvsov8OleZdFHKiZ+nqw4L1r/JmhgkRLmxM=; b=yAtAn+7GBH8qgV1BJQmmza7XMtpcC7bt4CLxXeHWZQ67TpBP5DKW4Mo1azKREPniI9RT/F qt3BoIXaCvBEMk7GUw8cpM8wp5Z0rWEZCeEEqJdok6EUHsYEF9WpQP6sirXxcGXao5zqqk ovgY14oNFy6ECVRlAaBp+IufZ1H0Q5/g7t24PBxxAXV7gMabBrr0w9knfNayv5nao3AS8x xwLPQnIxQZONq7uYsqPh9lMfkWHgduaDFa6/ORgrm0x2KDrsMaKTstKMgXdJaZApG+3gYB NwBdwAChTAGWIcpSdQjssy2xWvYsKvWtsYuNyGd5hWMQsljoarPqI+gPziPB8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756991143; 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=sXD+hjY4dvsov8OleZdFHKiZ+nqw4L1r/JmhgkRLmxM=; b=eCCMdzh8Kt+Rb2IBhuPb31hg6//NILF2YQqgBFW35t9Jlzm1EQ02grMztKxeZs43QoC/Vl VVXGE9mfYFm9bLTDa0cRtf/MY1jbIa8lrhbE3hP8C84USlNMaH0wF4ajQ++hX1azI2AH5G 5TedpD6M62gc/jr3KZ5T5rhX3UEZnEU0i7nfc7uXIWpaGNVK0xeI9atjeL14VpnL/ZhkxM Eedris0+A8+bLgRvJg4W32EjYG9ghQ2aFWYWTDcTHbWeuUVHyGWmxjuDV8EFWEC7mdOl6C hW7xwTb6SgNGW4GJ8PLggFbgrPFKhrN2xrCGMqo7O/p1H2zjfDKDY8M9HvPKbQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1756991143; a=rsa-sha256; cv=none; b=mSjmVvMHi4Rpb2cbzdgggprIbtD518I1soQMBQyET/ETYyWcmwlPTgtKjNnsc3LEOPmoUy R5vwb44cLAx2dowwzD3nFSHiuZFl8UjftHCLLUUbrrHZzf7M5UWljd+likiN/pegnQyskC 3Nno8+x4miBqlTpcacBXiS8oc6GXE8RRZZGJjXfq0GqmcsM5ZMJM3qTu3mXAZUBk2hqBR7 /BE7rXCp5sTmax1xhTNZMgpAfeuj9w2LMskX5JvKEAI/LbROIQEYgPumawRltlxqvP0SGM HjSmBwgcI4KOwN0YNif1/JEgwMOru99psA1EYJfZcIikq5ci+zy0y241d47y/g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cHfqC09NPz13cZ; Thu, 04 Sep 2025 13:05:43 +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 584D5gYe055867; Thu, 4 Sep 2025 13:05:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 584D5gx2055864; Thu, 4 Sep 2025 13:05:42 GMT (envelope-from git) Date: Thu, 4 Sep 2025 13:05:42 GMT Message-Id: <202509041305.584D5gx2055864@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: e3af3a23c155 - stable/13 - ng_parse: Add upper bound to avoid possible overflow 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/13 X-Git-Reftype: branch X-Git-Commit: e3af3a23c155d85275c6e32f2fe943468f252ba3 Auto-Submitted: auto-generated The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=e3af3a23c155d85275c6e32f2fe943468f252ba3 commit e3af3a23c155d85275c6e32f2fe943468f252ba3 Author: Ed Maste AuthorDate: 2025-08-25 14:25:13 +0000 Commit: Ed Maste CommitDate: 2025-09-04 13:05:30 +0000 ng_parse: Add upper bound to avoid possible overflow Also move num initialization for clarity. We still need to check num in ng_unparse_composite (reported by des@ in D52151) but this is another incremental improvement in netgraph input validation. Reviewed by: des PR: 267334 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52151 (cherry picked from commit 375527545c85362f14070d35575f9bcd7092f4b9) (cherry picked from commit 4407e10fdc8b969775233d47c05559c2601b60f4) --- sys/netgraph/ng_parse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netgraph/ng_parse.c b/sys/netgraph/ng_parse.c index 1a1d9d8b3064..1f322a31975f 100644 --- a/sys/netgraph/ng_parse.c +++ b/sys/netgraph/ng_parse.c @@ -1200,14 +1200,14 @@ ng_parse_composite(const struct ng_parse_type *type, const char *s, int *off, const u_char *const start, u_char *const buf, int *buflen, const enum comptype ctype) { - const int num = ng_get_composite_len(type, start, buf, ctype); int nextIndex = 0; /* next implicit array index */ u_int index; /* field or element index */ int *foff; /* field value offsets in string */ int align, len, blen, error = 0; /* Initialize */ - if (num < 0) + const int num = ng_get_composite_len(type, start, buf, ctype); + if (num < 0 || num > INT_MAX / sizeof(*foff)) return (EINVAL); foff = malloc(num * sizeof(*foff), M_NETGRAPH_PARSE, M_NOWAIT | M_ZERO); if (foff == NULL) {