Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2829165pxv; Mon, 12 Jul 2021 02:59:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8e7ZL3wcTQstskqpOvbAK8FulpRyDkhh/FvTvso1KvmTPOHze0M5kwVJ3g1eQKP6P9W2D X-Received: by 2002:a02:a891:: with SMTP id l17mr41587275jam.144.1626083961942; Mon, 12 Jul 2021 02:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626083961; cv=none; d=google.com; s=arc-20160816; b=k/zm7ScKK9b/Q5xNtfJ/dDiN3UAi7YkshZ63i4hDDSv+pQKk9KNLD6FQLwf/g2osl9 iJeAnW1FWbfw1+YqJt1LyZvjeKLIHqd40YFBqesQiPugV8XAd3cfc4OQ77OW2uEgehce wQq6VaWZ5d9EvMSziLez2LnkzLyU5/cD1+qspm+RphcWY7vXrrzeq06igIsFMD83flhY 8DnM+kKMEglIp3G9G77o82hlpjh2llXWXHfFuBhPdreRrRQb1i7BuLoSBY7j5+0pIaZB 1zhPPljxiz/FozwMkJil7KEVG3v+dxjF51R/tVQh7ie3EVZoe+g8H2JT4856dKtcqrqI vmjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MLpqKkAylS/cIDVA93DEmEF4NfkfFYhH332r1k++Mi8=; b=yDgH6H6gcvl7lchyOl5Pqpn2x2p0YALRHHRMrmkZJJ1v/svhEwG+oIkofYzJTknNXP 8RDWrGrF+lYwIe3zw8tKX/9bQDi8lzy7DADl2TCTByJYZj9/sBi14w/pQHyOWXXA2CJO 97ADEojoE1gXnWRcdPGTfC8LGQle/722ZKypYOKA/e5lgJbMwIompsfRKogWlDakm5XC cijVMhjJ0qWrMsDpXpChN7ahcVA5dRLJJXxn471MWPEvMgsmeuimvlGudZ1HytH4Dj4X iuJcM+BW207RSmox1inVq9aL5MmVJuTGDRN5BftsE9YRafFBZ7DVRxoeDL7QXiF86pq0 WRgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oq8si7rW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i13si18554067ilm.156.2021.07.12.02.59.10; Mon, 12 Jul 2021 02:59:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oq8si7rW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243027AbhGLHEX (ORCPT + 99 others); Mon, 12 Jul 2021 03:04:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:41894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238084AbhGLGqx (ORCPT ); Mon, 12 Jul 2021 02:46:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F41CF6128E; Mon, 12 Jul 2021 06:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626072156; bh=5RBP4naidKyQUpt3TyGxsn7mo6o5fz5Qv0pQJM67Sd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oq8si7rWkX6p9V6T9KVjBoMa3YccL5t5h0snui7L/XCMWj0B/6vZKyqHSA/jqiiEa M/2H20DyCVoqAJA/ct9hqRblHNcFtACl/S/Fldl/iGkSOXbCSycI3nBjKCoCdo1dWG n3HKrbRyZgiS6zOULptYK3Z3ZPlicxNqsp3jH9oY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.10 376/593] netfilter: nf_tables_offload: check FLOW_DISSECTOR_KEY_BASIC in VLAN transfer logic Date: Mon, 12 Jul 2021 08:08:56 +0200 Message-Id: <20210712060928.209744794@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pablo Neira Ayuso [ Upstream commit ea45fdf82cc90430bb7c280e5e53821e833782c5 ] The VLAN transfer logic should actually check for FLOW_DISSECTOR_KEY_BASIC, not FLOW_DISSECTOR_KEY_CONTROL. Moreover, do not fallback to case 2) .n_proto is set to 802.1q or 802.1ad, if FLOW_DISSECTOR_KEY_BASIC is unset. Fixes: 783003f3bb8a ("netfilter: nftables_offload: special ethertype handling for VLAN") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_tables_offload.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c index 2b00f7f47693..9ce776175214 100644 --- a/net/netfilter/nf_tables_offload.c +++ b/net/netfilter/nf_tables_offload.c @@ -54,15 +54,10 @@ static void nft_flow_rule_transfer_vlan(struct nft_offload_ctx *ctx, struct nft_flow_rule *flow) { struct nft_flow_match *match = &flow->match; - struct nft_offload_ethertype ethertype; - - if (match->dissector.used_keys & BIT(FLOW_DISSECTOR_KEY_CONTROL) && - match->key.basic.n_proto != htons(ETH_P_8021Q) && - match->key.basic.n_proto != htons(ETH_P_8021AD)) - return; - - ethertype.value = match->key.basic.n_proto; - ethertype.mask = match->mask.basic.n_proto; + struct nft_offload_ethertype ethertype = { + .value = match->key.basic.n_proto, + .mask = match->mask.basic.n_proto, + }; if (match->dissector.used_keys & BIT(FLOW_DISSECTOR_KEY_VLAN) && (match->key.vlan.vlan_tpid == htons(ETH_P_8021Q) || @@ -76,7 +71,9 @@ static void nft_flow_rule_transfer_vlan(struct nft_offload_ctx *ctx, match->dissector.offset[FLOW_DISSECTOR_KEY_CVLAN] = offsetof(struct nft_flow_key, cvlan); match->dissector.used_keys |= BIT(FLOW_DISSECTOR_KEY_CVLAN); - } else { + } else if (match->dissector.used_keys & BIT(FLOW_DISSECTOR_KEY_BASIC) && + (match->key.basic.n_proto == htons(ETH_P_8021Q) || + match->key.basic.n_proto == htons(ETH_P_8021AD))) { match->key.basic.n_proto = match->key.vlan.vlan_tpid; match->mask.basic.n_proto = match->mask.vlan.vlan_tpid; match->key.vlan.vlan_tpid = ethertype.value; -- 2.30.2