From nobody Thu Apr 18 13:37:05 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 4VKzN13MX9z5Gt0v; Thu, 18 Apr 2024 13:37:05 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VKzN12nXfz4KdB; Thu, 18 Apr 2024 13:37:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713447425; 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=2sGrEGmkOE7eG9MIgj21edlg6dsCFSakn2JgWcGogKk=; b=Vd3gu+2FXCt03mWdpHN7C+YrQ2HAxoVgAic9r/UyeDYAkrF5yRgkXdFxJHB0FAXsghiIVm 3HF3pErvIBmCzoHpPFasadd5Eo+kLVkj+C3jqsUjVBV/1HGnsZMcpCAR1Bxy4FRsyV7Twm nr2lLEM2Jx2pCfprRyPSQgxlMLXBohLG5rmSqbgKYNbgSgF+KyW6HSmQRQHm59wCwFnUeo yM/686CMrbL/wDI5F0NvYTJaZfsoMrBZ3onSgNn0R7SRYsVthVMUicORa7L6IsGnHONL1B JTItgBBHF01qWotKhrXwGYOG6yxZ5zjC58X6usoHRRt1Hw5a/tKMzs6Sgjkecg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713447425; a=rsa-sha256; cv=none; b=uwoXmeJJ42pNAR36hl0ee9tHg85qa6E6PpR2N+7kLvGa5WR9xHL2O+/0y0smABGozpJUNL U58RTKZy5m98nsJInQXqeXsk98wKFMvbCRd6FpiWMnk3J81cmozfJHbaWehe0j6RFx0UAb S8iqVP4ovkMNC+FvFhyRWuFTnyUzM6W3czBDAvfevBzH8MSrT0dYv6yEo9aZxyMpnpC5Qy n1E62k6JStcpAqHtkGCrxEdH9QyCGLKpbQEo6iD4a0h/ixmLkXSDPEm+jEHsWgcBo7d4O3 w2BQMl5JRFrOVWUGYsqxMqC2X5ibi63jT0umaWGUmCOKxhVLbwiuigfhqJn8jg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713447425; 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=2sGrEGmkOE7eG9MIgj21edlg6dsCFSakn2JgWcGogKk=; b=W8I0QyFTtfvh5eGpn+KISvuvPKpbQ9G57jmkJ2ASw5eF9jF9C5J5NUnCb78SJSFbQUsNvw KotcosRbWtOSzXcATK5Zvsyy4RU88/CvmywBcfZxJBMSylQF2pVUIoxa82vDh/9cII5pSr 7CL6H2p/c45PvV8y4WMKTeHr9lyxdwfUdjM0BEHs5CUM1buwDRqoF/BkF6MYQvuLKdFpHk smsM1q7P/9sfdF9hD8co/vLR5bCLX+CJbWMhkLbqZGRiVoPZ0drnhFIY1//M+gYCmDj08v UTZ+BpPD+mDVx1R2WSN+YxUasOYYZxqS09R1fiwz8NB1WcCvL3UmSYxHjplGGA== 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 4VKzN12Gj8z1B2v; Thu, 18 Apr 2024 13:37:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43IDb55b041440; Thu, 18 Apr 2024 13:37:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43IDb5Kl041437; Thu, 18 Apr 2024 13:37:05 GMT (envelope-from git) Date: Thu, 18 Apr 2024 13:37:05 GMT Message-Id: <202404181337.43IDb5Kl041437@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: dc16f5fe1422 - stable/14 - tcpdump: cope with incorrect packet lengths 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: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: dc16f5fe14226da84ea4e77b04d31efa5c5f6853 Auto-Submitted: auto-generated The branch stable/14 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=dc16f5fe14226da84ea4e77b04d31efa5c5f6853 commit dc16f5fe14226da84ea4e77b04d31efa5c5f6853 Author: Kristof Provost AuthorDate: 2024-04-01 09:42:14 +0000 Commit: Kristof Provost CommitDate: 2024-04-18 13:35:52 +0000 tcpdump: cope with incorrect packet lengths It's possible for the capture buffer to be smaller than indicated by the header length. However, pfsync_print() only took the header length into account. As a result we could read outside of the buffer. Check that we have at least the expected amount of data before we start parsing. PR: 278034 MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D44580 (cherry picked from commit 4848eb3af2a91b133c4b70cb9b71dd92ffec7f46) --- contrib/tcpdump/print-pfsync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/tcpdump/print-pfsync.c b/contrib/tcpdump/print-pfsync.c index 5710e36ded6c..6bf9abaf3903 100644 --- a/contrib/tcpdump/print-pfsync.c +++ b/contrib/tcpdump/print-pfsync.c @@ -86,7 +86,7 @@ pfsync_ip_print(netdissect_options *ndo , const u_char *bp, u_int len) { struct pfsync_header *hdr = (struct pfsync_header *)bp; - if (len < PFSYNC_HDRLEN) + if (len < PFSYNC_HDRLEN || !ND_TTEST_LEN(bp, len)) ND_PRINT("[|pfsync]"); else pfsync_print(ndo, hdr, bp + sizeof(struct pfsync_header),