From nobody Wed Dec 18 13:46:52 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 4YCw2j00Rrz5hN09; Wed, 18 Dec 2024 13:46:52 +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 4YCw2h6YSdz4DDc; Wed, 18 Dec 2024 13:46:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734529612; 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=ZXlUdglifj8TI/hcX7mKKnL0RjgnxWjQfz3TEinfd2I=; b=TDLjI3eMoOGr+AfVSX35Es7Bm5228pwemK1zSgBqc/abEJMJLrpacz/Z4r5DN3xMiJhkVT ACOjXP1MSCTI6WohWSsdKNiukn8mXmQk2flxTH+BsKzWlP5Ke1/taPYtCsNv/KSKVTMYEG BGyItCKnYOZa4yEumadp7hsMAqbtvxqBlEhNGU1kQsHSEooF1ompYN6xfjM2kK69X5ic9B qRD37fZT7eNmvCKv/f5NYBZLAdBG9spreJpyAYtg+iIn5KcCJcNrnKJPOwOuN2IUqJK18S bqlgH/byGmYli0767p79/BC6mtCpOu1Yf8o8ipZFel05d8/kjpeCoQBe4It42A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734529612; 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=ZXlUdglifj8TI/hcX7mKKnL0RjgnxWjQfz3TEinfd2I=; b=GHegCv+wToGSIGSsfGMiyWzsI7BFWLodbCl7HOIfeX4E5Tla/aQZX/mfiolQ6Lo4+U7hU8 mqNbRpjvpuomCtRM7HLWVODyEIjREKX/Xvus1otfEgCWXnCcMnsQP26RE+FJ5BurQvjKvo wA68uOLNLbA66nvDGFeMspxI/XPd9/U4EtLJrs6WGXSycKDRNxTrATGZD07B6V9GsCbkR6 tfEYCARAkEZBTUfUYTs5sQIkaek8qVm2oxrvZZWPet+cEs/gvH5NSOEUF65I2gY1TVUfik lbIjxcdCqsZS6xh+nnTLn0fQntt1AaAD6i+1qQy7dOtmfawwtZwV350yto0S9w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734529612; a=rsa-sha256; cv=none; b=YV9GMMwlOSmbpI7GXJ4UPH5sHDF0MLKX+bPYZB5f8TSdVuN4ZrS8yh3skoEnF51GJ/U7oE TUhgDZPE/q6bpMp2olTAXAE1cfl5ZW4asbCWzUBk4mjp827iP9iGcx0cXG1YeeiLVRRDg/ CrFMTxUVw0J9zj0kceTxo/xGinilxOIA5SlMHDcik43XaLFJaJTXbK8L+B2RkM5nHGLUbO 7g6IPXw9CDpODAO/Ww9Gs5oDrhiGzSG/2mk3CdOwXqgdKcSsMhbCVa/8+uuvGz1V5pEZcP vjZW+/2WOjjHMYR8xjwyocgkf/AuUZ91NcSFGS1mgjvWnW9GZ6H5UY/Fa13rnA== 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 4YCw2h53pmz19QN; Wed, 18 Dec 2024 13:46:52 +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 4BIDkqHP019204; Wed, 18 Dec 2024 13:46:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BIDkqfl019201; Wed, 18 Dec 2024 13:46:52 GMT (envelope-from git) Date: Wed, 18 Dec 2024 13:46:52 GMT Message-Id: <202412181346.4BIDkqfl019201@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: 0c5701ff8fdf - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 0c5701ff8fdf9103446f605fcab29608f4715338 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0c5701ff8fdf9103446f605fcab29608f4715338 commit 0c5701ff8fdf9103446f605fcab29608f4715338 Author: Tobias Heider AuthorDate: 2024-12-04 01:13:41 +0000 Commit: Mark Johnston CommitDate: 2024-12-18 13:43:42 +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 dcb542b22ad8..017105e78f2b 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); }