From nobody Sat Dec 31 12:43:29 2022 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 4Nkhcx3S31z2nNqg; Sat, 31 Dec 2022 12:43:29 +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 4Nkhcx2RW7z4Nm8; Sat, 31 Dec 2022 12:43:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672490609; 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=PzM32Bj6BunRwjDKDaLLR/GnYRZhHGuKWn3mZyOme40=; b=yuz3Xl9Ri/LTFdgnkN2PSUCX+M/9zM+isVc/8IGMBd/XtxU66cvzqBVzS1YrkQtGZHCrGl l89YTNULpJiuH+TCU3QKLd994onWgAAz1VPu18LwVHIp/qmJ36OM9a/8+hjTjH/2Ew+pHq OWqQZX4k+moH1SoJV0WlcjIZJjd5JNWOzqkn9WAJN1AkC12afq/ryQtL8NytGVpaWYenSG htjGukJ8Do5ENkkv9UIYAUjCHqZO3XR1JeSQrfLpnrI0Hwajy4m12ckJbSwAFigw67UorP j8QMZsVti03HIrlXyvyZMmNsU00d/qW/dgg7zNnMxh+8SnsO/uztGovWwynR4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672490609; 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=PzM32Bj6BunRwjDKDaLLR/GnYRZhHGuKWn3mZyOme40=; b=uougAjRzA1uTRJrFgSiXI+9b+/qzSU/BrbEM1XKjwKYnLmeyjWqLBhwYHJKL1JafLr9qUX Bt1KK+hL5It3OkBNthxQxp5dWTYv/nRunbaMYuWydmEUHRvvWQ6GqYRhGNL5OacPStmXHH t6k85vJyPoHnAC1ULgvG0qElF1ZqraEA21RVcxA0SncSPMFRwQZxsSU26HeKvQef4hMpSy KPP8lJXqlOnpeYsVwqLr6U3O3Og4WmYsVHSiP0herzVf8t1WqBJznN8b7ocgQkMPpikqEQ dljMCQQMzJDijBDRLg7SEaTOJzUh5auhI76jLWzMspM5eA+aI4gVF5126Gau5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1672490609; a=rsa-sha256; cv=none; b=HZH4Q/9GzJCfpYQL0esUggKdlFbQRz8AgmfrfoWrB/EizPogtHY/pPMMc9MIMv+cHRwTGc rz/lVog6dlVjCkDpPOS26S00khFZgWAKKK0NT5Sf1LyZWzHkx5e+2bn13tIPXB5wIHYXdU T4SKt2MSpPpSJtcQn3UiE6gS+mQF+0xd/GXWNIiQPhyjtQFYut1THLN+XDydNf40rUB2Rc pe8xAz7QKNa3nIzm+djdJ+YtRK5oxLZQcU0Vqc8dEvN6ZyRXrhsf8WjblFNoOooSSE2nkv sLMgZWV6bd2FpTbz8Yz8HTDH22i51ohvZao1974Mpx/dKwa3Fr0L6cJ4ZbtYwQ== 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 4Nkhcx1ShFzpgT; Sat, 31 Dec 2022 12:43:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2BVChTGJ097610; Sat, 31 Dec 2022 12:43:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BVChTuB097609; Sat, 31 Dec 2022 12:43:29 GMT (envelope-from git) Date: Sat, 31 Dec 2022 12:43:29 GMT Message-Id: <202212311243.2BVChTuB097609@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vincenzo Maffione Subject: git: a95578c87cd0 - stable/12 - nemtap: lb app: Validate ihl field when hashing packet 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: a95578c87cd082683281e68528251bcedb9ba4be Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=a95578c87cd082683281e68528251bcedb9ba4be commit a95578c87cd082683281e68528251bcedb9ba4be Author: Vincenzo Maffione AuthorDate: 2021-09-26 13:44:51 +0000 Commit: Vincenzo Maffione CommitDate: 2022-12-31 12:41:42 +0000 nemtap: lb app: Validate ihl field when hashing packet MFC after: 1 week (cherry picked from commit f7cef43aa9a357582a703c75dafa4a44c1b2f28c) --- tools/tools/netmap/pkt_hash.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/tools/netmap/pkt_hash.c b/tools/tools/netmap/pkt_hash.c index 3071935e11ef..eb9704fd2058 100644 --- a/tools/tools/netmap/pkt_hash.c +++ b/tools/tools/netmap/pkt_hash.c @@ -150,7 +150,9 @@ decode_ip_n_hash(const struct ip *iph, uint8_t hash_split, uint8_t seed) { uint32_t rc = 0; - if (hash_split == 2) { + if (iph->ip_hl < 5 || iph->ip_hl * 4 > iph->ip_len) { + rc = 0; + } else if (hash_split == 2) { rc = sym_hash_fn(ntohl(iph->ip_src.s_addr), ntohl(iph->ip_dst.s_addr), ntohs(0xFFFD) + seed,