From nobody Wed Dec 04 18:35:20 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 4Y3R604khNz5g1Gc; Wed, 04 Dec 2024 18:35:20 +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 4Y3R6046NWz4vLH; Wed, 4 Dec 2024 18:35:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733337320; 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=gHX6cz+MeknVyZ3pfXjfzdvr7lSBurUoqIdg8EqvL7E=; b=cdbUx/7kMwl73U35i4g/0ntyRP+rG6Lj5xi1KZFR/DIe47GHKyXq3K0HTt6Ht979TR91uf FGJ6uvMF17/yBVpm0GB289r6/MRguLpQ56KmZY6DN/hELaMWqckKhgI6oMPRbvfQHNxSvT NK4tTTWA0XSzlSQKyn3DhITRRp669QKXoNERSnr+R1RdPVfNR1aFFOG+4zvr0nHYqzowYx FHgmfSqLR4rBxqhzldfZ8QJzmQ8kXXulrAUnTwN/p4AHJ/a4CLJPCAJClHKqB/4yTGmJuz hXiau67BN855UQ5PCxHdetHpPa0+CC/j9AUA/+UziBPH/I8/c4VDlES3dik8rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733337320; 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=gHX6cz+MeknVyZ3pfXjfzdvr7lSBurUoqIdg8EqvL7E=; b=KBeX1KwTxJEcCqVgBlPuiS2c/yce+owGpm0QcL13djY0YNFfmiWrbghBD0SXg8PxnTNDbm s7VJ4+4+KG+B5hSohhksAxRxAivgIQgaKrcYVRtD4CygS6G4L1OoM0jYO/zeHnI70cgtCo 6+qB6C1IbUjL6gZfCs/BkPOmph7hcABA8hzojStUyLunyraejjOc/7ONb2NeDzoE7+ms3x Utolv+YZvHR1wl1CgCnoom54Woaiom8WOX2/C+uDnqBYfgz5ACxJUoMk7n+uhgUEuR47Nd vlQQc4pmYR/h36aA94QM8cRokrwy1A+OT4KOyRPlBgkd0YgDpKf9XqgwC3CklA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733337320; a=rsa-sha256; cv=none; b=HsYfEU8EBZSraCK5TlhdSLCM/65hHQ4xUKZ149VJL52ZLTJ94YuaC6Fxc01r861p3CVQPT yHRap3q6WEUIphW7sC2ZJwN4MzAvFD3Heqifoc68XTGcchGPlyFxQCGFsCmc1aR1VYOvct UvggLJYTgkTyXINyrOPAGnNRMePCFKtnYmLtKExVB1lgXFV5US1LvpkDCq/QxRGiiJncjl +I02VQPHekYk/n3S418uICrcsogpN8PZwTky7HnF0OFsACt2T3P0u7qXlfWs6fV77pkc6b r/yccNeaxdDwtpJqiqceB/sYWbjn+3XyizeSeDxCDUzpq//lTHxnja2De3/yYQ== 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 4Y3R603kdQzJK1; Wed, 4 Dec 2024 18:35:20 +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 4B4IZKge078177; Wed, 4 Dec 2024 18:35:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B4IZKV3078174; Wed, 4 Dec 2024 18:35:20 GMT (envelope-from git) Date: Wed, 4 Dec 2024 18:35:20 GMT Message-Id: <202412041835.4B4IZKV3078174@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 0dab21248bc9 - main - pfkey: Fix some checks in kdebug_sadb() 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0dab21248bc9fab09e92b0c037303c921ebb1b8d Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0dab21248bc9fab09e92b0c037303c921ebb1b8d commit 0dab21248bc9fab09e92b0c037303c921ebb1b8d Author: Tobias Heider AuthorDate: 2024-12-04 01:13:41 +0000 Commit: Mark Johnston CommitDate: 2024-12-04 16:22:50 +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 --- 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 ead5fe80115b..69310baeb4c5 100644 --- a/sys/netipsec/key_debug.c +++ b/sys/netipsec/key_debug.c @@ -191,11 +191,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; @@ -262,7 +263,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); }