From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 327282139D2; Thu, 12 Dec 2024 16:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734020718; cv=none; b=OxNjpAsgl8FqnLvmoyPFIFdL1mLcWs/2t5LcCX4KnFh/j0IFT+ND5GBj8nNXeEiwaGjXKs8iG4eCA4JTWq1NbKWuQq5BKyj+KOTpQVuANp/fLz//mkTTt0R0CRL2gzxX/jZyMyTzp5yKITmhhimho4LKGbqBlPkjIlWHeGYPVzM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734020718; c=relaxed/simple; bh=FQyipcMVMXuV0BYCXJNyWfIYyNgoKWesfK2d81d/4ZQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s4SA6+PwCfGHozNCLEOn/7WN5w16Bn+uP70latcjvsyJyGo2uzccmQ1aQmTipvI67HrZytCCXye6/IXAqg67Ru8O5Pyg5gLgcERCrcsJ/RdVwCAHyeTVlm4eJ/9+FGfv3O6nnBYShQUO1rJKEAznfskOQPITCUof2PpVRqsbsU4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HuDrFzr7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="HuDrFzr7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 750B4C4CECE; Thu, 12 Dec 2024 16:25:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734020718; bh=FQyipcMVMXuV0BYCXJNyWfIYyNgoKWesfK2d81d/4ZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HuDrFzr7SAFT2FzVF/wHwAp9M1FbrVSnY5vvrswG6oumIZT6F4fR3IfS3f32sJafi bR28+OiHCoL/dH9cbsPevHyItrD+wuUMfuRKx6wEb5IQIo+LQTMm0hdKPiwpbDspFH odp6NM7v6Tb1creSc6wU0IlUymMmr/PdKw6DTEOU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shuang Li , Xin Long , Cong Wang , "David S. Miller" , Sasha Levin Subject: [PATCH 6.1 541/772] net: sched: fix erspan_opt settings in cls_flower Date: Thu, 12 Dec 2024 15:58:06 +0100 Message-ID: <20241212144412.322500349@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241212144349.797589255@linuxfoundation.org> References: <20241212144349.797589255@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xin Long [ Upstream commit 292207809486d99c78068d3f459cbbbffde88415 ] When matching erspan_opt in cls_flower, only the (version, dir, hwid) fields are relevant. However, in fl_set_erspan_opt() it initializes all bits of erspan_opt and its mask to 1. This inadvertently requires packets to match not only the (version, dir, hwid) fields but also the other fields that are unexpectedly set to 1. This patch resolves the issue by ensuring that only the (version, dir, hwid) fields are configured in fl_set_erspan_opt(), leaving the other fields to 0 in erspan_opt. Fixes: 79b1011cb33d ("net: sched: allow flower to match erspan options") Reported-by: Shuang Li Signed-off-by: Xin Long Reviewed-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sched/cls_flower.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 10e6ec0f94981..b4a7952c5d7da 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -1279,7 +1279,6 @@ static int fl_set_erspan_opt(const struct nlattr *nla, struct fl_flow_key *key, int err; md = (struct erspan_metadata *)&key->enc_opts.data[key->enc_opts.len]; - memset(md, 0xff, sizeof(*md)); md->version = 1; if (!depth) @@ -1308,9 +1307,9 @@ static int fl_set_erspan_opt(const struct nlattr *nla, struct fl_flow_key *key, NL_SET_ERR_MSG(extack, "Missing tunnel key erspan option index"); return -EINVAL; } + memset(&md->u.index, 0xff, sizeof(md->u.index)); if (tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX]) { nla = tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX]; - memset(&md->u, 0x00, sizeof(md->u)); md->u.index = nla_get_be32(nla); } } else if (md->version == 2) { @@ -1319,10 +1318,12 @@ static int fl_set_erspan_opt(const struct nlattr *nla, struct fl_flow_key *key, NL_SET_ERR_MSG(extack, "Missing tunnel key erspan option dir or hwid"); return -EINVAL; } + md->u.md2.dir = 1; if (tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR]) { nla = tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR]; md->u.md2.dir = nla_get_u8(nla); } + set_hwid(&md->u.md2, 0xff); if (tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_HWID]) { nla = tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_HWID]; set_hwid(&md->u.md2, nla_get_u8(nla)); -- 2.43.0