From nobody Wed Dec 18 14:16:08 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 4YCwhS5z0Wz5hPC9; Wed, 18 Dec 2024 14:16:08 +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 4YCwhS5JwQz4K21; Wed, 18 Dec 2024 14:16:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734531368; 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=2DECmXeXp6q3SFUJxWbhABxqsiPbOyVErUqL+Ow2KNM=; b=H7Yj8nrDcsYsyUTfHf7jZLP1rU+wCcKhmD0tVtEvjzurqJDYUdbyQGJpbEtCrjdjqij8lE LPbvnUGLZI8Yi2kQJqRA+OFq4HTUHubB0xErzul5WP0G9pfJJJ+S6VsI4zj5vALI+OX1ex tRv+HBpHL5muVh1vqVSB/YbmGF+wtZHyMRZ6FpXKdIfhMRM6NOBYinq51gMMV7Dj/Oq/BP gcAsooPmToLx0wDpvaahE0lYdRaib9RrXoPTAO7+KQ0Zgi98SwT3AOdQmU2rYKCJaeS44T FXHncWx618fMFfMBhfQw+Qdp0IUZE3MFGwtRIwjvuS+Nj2dT4qJwqwy9V4ijXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734531368; 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=2DECmXeXp6q3SFUJxWbhABxqsiPbOyVErUqL+Ow2KNM=; b=kRkPtu3PtEyYrCB454Ko4znf4z5LePp8nbWnt/GbMFpGepXqv+4Bm+SFYec1M3yJUvfm2Y fqnNer99ok8gjh1isUcrrzPLaNDls/03IT9rZPlefYYrqlLVMLSLZHPYx4PDrKARwacNxj 3zEXI7mawZQOIHwy/+dSfrLGVDbEZ0X1RIsEdQCS+oYE5u/gWDj0QGol9DmmqrvqjGeWST 1cECV1dnebx7OarUbYXUQORKPxMJLuNEoZoQMd/t+rkHHYeqfULJrOCXL1ShhEFDueH7IK 0t+Wez1/BUoSo/gEgFQSP9rGktMQ6mS+OWefiBCRwVlzRlw/WXWrAfoKhY/KoQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734531368; a=rsa-sha256; cv=none; b=a49f70NJZ7zGSNpePGGOaGNSdZlm6++pCAsatrY9vzCJ+RzMrErJYGZ/DINnY7xaB/OsZS IKW7euTs5Qt9ra3d+7f/YnihNy1/oT+KAyMmXIkPUBgvFiEHDR4+Mh7DMqYcuYFDfGOhKK IuRx6k1VUPTwFv3skbxeDVyhIV/aJr0LvHZD9HaztJgUaGv3WKMv5/B2GbnHQJyI7iupAw O0sVuYtAaLtC8EpX3Y6okiuTsjfCK0zD5D7B/V5fh6YhPXoVg7VHZPlxVodLdio3G1d544 glyl5qP6lJj88G09VLJygCBqqQop+Ptd92KykymBJWojewTlUIQwXnA01ctAlw== 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 4YCwhS4p7Gz1B0j; Wed, 18 Dec 2024 14:16:08 +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 4BIEG8wZ075636; Wed, 18 Dec 2024 14:16:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BIEG8Vc075633; Wed, 18 Dec 2024 14:16:08 GMT (envelope-from git) Date: Wed, 18 Dec 2024 14:16:08 GMT Message-Id: <202412181416.4BIEG8Vc075633@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 11c7eb30cc9b - stable/13 - pfkey: Fix some checks in kdebug_sadb() 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 11c7eb30cc9b38d199c4686ad00071a678a1fc58 Auto-Submitted: auto-generated The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=11c7eb30cc9b38d199c4686ad00071a678a1fc58 commit 11c7eb30cc9b38d199c4686ad00071a678a1fc58 Author: Tobias Heider AuthorDate: 2024-12-04 01:13:41 +0000 Commit: Mark Johnston CommitDate: 2024-12-18 14:15:46 +0000 pfkey: Fix some checks in kdebug_sadb() Besides not doing any sufficient check that the length of a parsed message is not bigger than the actual allocated buffer, kdebug_sadb() incorrectly compares ext->sadb_ext_len, the extension payload size in 8 byte chunks, with tlen, which is the full message payload size in bytes. This should compare PFKEY_UNUNIT64(ext->sadb_ext_len) with tlen instead. PR: 277456 MFC after: 2 weeks (cherry picked from commit 0dab21248bc9fab09e92b0c037303c921ebb1b8d) --- sys/netipsec/key_debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/netipsec/key_debug.c b/sys/netipsec/key_debug.c index ab4def455ac9..ef511f25411c 100644 --- a/sys/netipsec/key_debug.c +++ b/sys/netipsec/key_debug.c @@ -189,11 +189,12 @@ kdebug_sadb(struct sadb_msg *base) ext->sadb_ext_len, ext->sadb_ext_type, kdebug_sadb_exttype(ext->sadb_ext_type)); - if (ext->sadb_ext_len == 0) { + extlen = PFKEY_UNUNIT64(ext->sadb_ext_len); + if (extlen == 0) { printf("%s: invalid ext_len=0 was passed.\n", __func__); return; } - if (ext->sadb_ext_len > tlen) { + if (extlen > tlen) { printf("%s: ext_len too big (%u > %u).\n", __func__, ext->sadb_ext_len, tlen); return; @@ -257,7 +258,6 @@ kdebug_sadb(struct sadb_msg *base) return; } - extlen = PFKEY_UNUNIT64(ext->sadb_ext_len); tlen -= extlen; ext = (struct sadb_ext *)((caddr_t)ext + extlen); }