From nobody Thu Apr 18 13:37:17 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 4VKzNF33Kkz5Gt7q; Thu, 18 Apr 2024 13:37:17 +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 4VKzNF2Wbmz4KlH; Thu, 18 Apr 2024 13:37:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713447437; 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=NL2caFVu6op1hZtqe0tAZI6j2NHDDDbcqpDK1SHnIrY=; b=UakXXgd7GBZmTGaHaCVkFhsOx7nd4yob6BZnAmQLsnBqsvZAP/nIHomSSqX2lSC3QNSdvA Ca0y3C78MsGXm96Qq0jAp8dO0iR9SZ5lK24ay2KrURuOVxjgDMdXQhyYWfhcJXWWoP9kKk wIaIm4PrHiTaCm02fIDW/OJirDQWls82MA8EA8Kc/ssMFCh0J/dVU4D9XtHw6coKJWGsS1 StqMgZyREgB/EPAEmU5hMYu4T/m0Ul0I43vuxMhcGxcsxDqK9eBSbjBMu/iQcVqbenu86T 7kK3uUFxe5oxast9CH4Z3/+uMumbe1doscG7WsbN9fg1Ji6cCOdmdLnWL1iIvw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713447437; a=rsa-sha256; cv=none; b=GVk63AZ+CP14pAip0yHS9mXR+MD0JwJr7uYUSHo5MB8H5swHojLevjyX4kpqnFPJgAzUNw UNYv9AorBY32vuIXWR1kBdZOnxeqlYTBxqCvAdkKKxIc2HsPbxq56yXDyfSZHUyPCM0xCW FaVQPfoKJBYYLDWH+/dp5KRlOZpBs1SuthN39wL0+F3/HaVwsQTsAJGTNEJJWpGRjPE07s K2lZSY8afR1k9oYe4JoCxfue06Sem+KHFexenEfQAyF7rry+aaeziLedT/xp854FQViU+Y qE2KtSPAvUqUAlp4Tqn07kmBRJlNyKrkDQhAMjK8lOcd+OoFKb1tkbPUxYQfXg== 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=1713447437; 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=NL2caFVu6op1hZtqe0tAZI6j2NHDDDbcqpDK1SHnIrY=; b=o0eTIwyjywdxoTibyuNv+4tRX0Wq2erlmB3t8RGWBVF8CPBB5z/58tBKHsjaJIH0OYEY+P kfmF+f8ohJOfWUWt9o54r+caV+oh/kLHtmh3ePi3XSPg8yopGLwKwyN7SNPk3cONRGBYSq oYMwDRwEEVdRGdM2c7q9PtAav7v7MZmJUUvfkVTCAVpoaD2NQbxVooptuW0b2ubddyBZRy EauRJc3WhJS+0wZjCI/juN0pvW49SaXdmR/AZNtw3ueXw+xXD86imxfzLLqmIVs4houJwl AKnUpWO+BqXcpDpYQ26daYOFdKeigYNi8xYu6cVOA2fyH0eRnLdT89oiiJKPbA== 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 4VKzNF272wz1BbF; Thu, 18 Apr 2024 13:37:17 +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 43IDbH55041600; Thu, 18 Apr 2024 13:37:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43IDbHtW041597; Thu, 18 Apr 2024 13:37:17 GMT (envelope-from git) Date: Thu, 18 Apr 2024 13:37:17 GMT Message-Id: <202404181337.43IDbHtW041597@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: bf0700716a2e - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: bf0700716a2e04464311e0b585b947d7d3e825b9 Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=bf0700716a2e04464311e0b585b947d7d3e825b9 commit bf0700716a2e04464311e0b585b947d7d3e825b9 Author: Kristof Provost AuthorDate: 2024-04-01 09:42:14 +0000 Commit: Kristof Provost CommitDate: 2024-04-18 07:41:28 +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 dc1cd039f5b0..cb1c3f3828fa 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((ndo, "[|pfsync]")); else pfsync_print(ndo, hdr, bp + sizeof(struct pfsync_header),