From nobody Thu Sep 4 13:01:12 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 4cHfk06760z65yqG; Thu, 04 Sep 2025 13:01:12 +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 4cHfk05S3Lz3MCl; Thu, 04 Sep 2025 13:01:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756990872; 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=oo4nmQ8GEEHwdMmUU0GF9jzDPhS7QEZLf1d+a8Okcrk=; b=tHt2ZF8D6hEo8JpcZ3UBEu1ggz4pctDi7Bs0DoAIYbhSm4FgdYwA4lmmi9MRmhS3Oa62Gt EQRNUQRVOgosQpBW8RgVmKEgHMM0txMOHajaCZ8S9BJFNiUH7kUO2SszglrAoRNJyvrRTs 43oNvux9SCKKDZ10k47/IkOQWnU8cxa6W3UsXf6HM20ZXAsvJJe18JoawNc9Y/1yAQq900 UHfvZtCIPqjZb+yXYCYz8GRm34XrFRMMUWW9m+g10e7faJNLwhjoGsRGb5WPkSZLnoIZPe vngZZyNWcMQ0gOL6dudvd9Auwzs1CkLnj4HUgEsSxkLGTRWt4bMircHteD7z7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756990872; 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=oo4nmQ8GEEHwdMmUU0GF9jzDPhS7QEZLf1d+a8Okcrk=; b=tmFar3qRy7Yr9D0VaO8JJMnlmd+JNHKZD6kyKVcQq1JT2gQdNNaRl0pOKdebDOLPAnAJhd gdhDA3TMIxRHLI9vUwQI+k4amWyCNZaZDqfq+bwidU6+Cr+QHWYTKbAhvuNorbz109d5Ly M73HrSCuoToPMCurdH9ZyR7qwU98l1EO5IE3ax9kOH6gpDrwUv0Jhm0nMw1G6s/9U4gShl 7ARWI56xeKMBVKcAyL+yzXbakyNmRx5ME8yjpCH/n4umdKyGxiKARyxhG4sep9MqbatxMg nEHqiLGOy0Pw72dKVPkmtWcPrgl4u5JqIkKvzWhapaI4vu+smzhpQkvv/8UOew== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1756990872; a=rsa-sha256; cv=none; b=K6xS509TCvqOeUH3+yMRA7jBh3rgzAfYkoPYcE+UuV2T7+SJUOopm2j4bdVS8aYpQE6CJW LEoE3IbWLsf78Z/2KKqOMHmFRfad53l1fwVgYIaTZ3OnQHaVgl8CC9ihkRIOBzc9Fn7hGa 4Mhjbpm1WnI9jOY9R10Iw7gJPvC2K+HALLjsN8nZkvXRxbcaRnqr6TedxsrbfnR/PhnwgK Tk6dI5ICCkltHotSKGJdvPweLfSMmCQYBHDGg1fhF0/FSzutvqsASIOnCtSNXg/43aGajV 8YaA/dIrlOmi80XxcJpiTUY2t6XNAF6G9FWWp3huPK+9xsj3F5r5E/DYa65oRA== 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 4cHfk04s9Hz13TF; Thu, 04 Sep 2025 13:01:12 +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 584D1CIi052283; Thu, 4 Sep 2025 13:01:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 584D1CPA052280; Thu, 4 Sep 2025 13:01:12 GMT (envelope-from git) Date: Thu, 4 Sep 2025 13:01:12 GMT Message-Id: <202509041301.584D1CPA052280@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: 4407e10fdc8b - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 4407e10fdc8b969775233d47c05559c2601b60f4 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=4407e10fdc8b969775233d47c05559c2601b60f4 commit 4407e10fdc8b969775233d47c05559c2601b60f4 Author: Ed Maste AuthorDate: 2025-08-25 14:25:13 +0000 Commit: Ed Maste CommitDate: 2025-09-04 12:08:51 +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) --- 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) {