Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3885387rwi; Sat, 22 Oct 2022 01:32:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7D+2fu6DtVoFcOqF8lgoBuwN6oH7xXBAy+EBZU+aOx92hlMGKq9MRNM8B+c66Ds1vnmLTc X-Received: by 2002:a17:907:7f25:b0:78d:e85e:fe12 with SMTP id qf37-20020a1709077f2500b0078de85efe12mr19224641ejc.553.1666427568285; Sat, 22 Oct 2022 01:32:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427568; cv=none; d=google.com; s=arc-20160816; b=s5ZrA0S7QGMEWhU7xUG+n671VQvKDBjNBCdcuiyGH8v+OGyZMDU4hUxfLIvjP7YZSD grne4RCWMl2ICylFDf1K2JdZ1Enjgf9EqNbbAdZOAYoVNM1pE1w6IJEBimxUZJfVsDh2 6s0wXWlhFEElYKDMXZi4wFPmL++alZG7Xkqy9wsCjHo/PzX5kzvOdn7RfYGFTL9ejzRQ qcQ8f/1V4GcxBl4ujovt7sE0lHe7k+5wUQmbwoJMnOx+x9h0t/gg5movDkBOrraTM0n4 FNv8Sf51NILN1g6n+d/UXiJ8APXPi78uyFU3b9//XNwIMbFvUa2ahCobbYL1Q72oit1p eP1A== 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=Bvxej/lvKFn6NJWJBgeNiVG/Jbo9SQ0H95FOpaNbiVI=; b=cOHxQAqHdlfr1qqj2U8TotG8JzpS5QOIxQFuKwwi2tNByQ6ewL6ecxTtJ8LAy/gzTm F1VZGI5ZCDej9rmio8QqrYhV9hvJsroaX60o8HfAN4GfxUeezJsIZB7m/D14niSsgYRf jvRPSBWrVc04gGLA45FWlRyMfwvainRCQ7IbxcKr+3WXpfGFYTqdlwP7KivdMmO6QVd6 xKTxqVTqTvQpRNZMMwx7F6DAb5CnqXHnBSEw/BKoFFrm4Pk3mscddkTxlqNH0dIlijv/ ztArgzE7+XtEYfVd+lKQNX+Yjslcupk5343qlYpwYCRTGgpJ5ClUxKyNmT1h8Tvi/EIT zx4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yauzaur7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv19-20020a17090760d300b0078d83fb6672si23980288ejc.118.2022.10.22.01.32.23; Sat, 22 Oct 2022 01:32:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yauzaur7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232070AbiJVHx4 (ORCPT + 99 others); Sat, 22 Oct 2022 03:53:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231976AbiJVHvs (ORCPT ); Sat, 22 Oct 2022 03:51:48 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C65842C6E9D; Sat, 22 Oct 2022 00:46:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3186CB82E19; Sat, 22 Oct 2022 07:45:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E939C433C1; Sat, 22 Oct 2022 07:45:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424742; bh=/RIb42wHw1L9PcyyDmOwf1FOxZOlDFzTAebjEtF6xrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yauzaur7HEp3lYwooJuMt0aNocmn6yzuz/KQ/yCrWsIx98dAL2ASJLDFqVgkHMxMI LcBPUBbLzvdFg2Gnc2DTx0s5xRddmirzwUH07018Xfia3anfpkELFKoJzXbhWcy3/o WNuFEAUn3Dq/jkxejiDemWs8TwJReUhOdyDuWlFM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qingqing Yang , Boris Sukholitko , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.19 258/717] flow_dissector: Do not count vlan tags inside tunnel payload Date: Sat, 22 Oct 2022 09:22:17 +0200 Message-Id: <20221022072500.377801790@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qingqing Yang [ Upstream commit 9f87eb4246994e32a4e4ea88476b20ab3b412840 ] We've met the problem that when there is a vlan tag inside GRE encapsulation, the match of num_of_vlans fails. It is caused by the vlan tag inside GRE payload has been counted into num_of_vlans, which is not expected. One example packet is like this: Ethernet II, Src: Broadcom_68:56:07 (00:10:18:68:56:07) Dst: Broadcom_68:56:08 (00:10:18:68:56:08) 802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 100 Internet Protocol Version 4, Src: 192.168.1.4, Dst: 192.168.1.200 Generic Routing Encapsulation (Transparent Ethernet bridging) Ethernet II, Src: Broadcom_68:58:07 (00:10:18:68:58:07) Dst: Broadcom_68:58:08 (00:10:18:68:58:08) 802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 200 ... It should match the (num_of_vlans 1) rule, but it matches the (num_of_vlans 2) rule. The vlan tags inside the GRE or other tunnel encapsulated payload should not be taken into num_of_vlans. The fix is to stop counting the vlan number when the encapsulation bit is set. Fixes: 34951fcf26c5 ("flow_dissector: Add number of vlan tags dissector") Signed-off-by: Qingqing Yang Reviewed-by: Boris Sukholitko Link: https://lore.kernel.org/r/20220919074808.136640-1-qingqing.yang@broadcom.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/core/flow_dissector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index bcba61ef5b37..ac6360433003 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -1168,8 +1168,8 @@ bool __skb_flow_dissect(const struct net *net, nhoff += sizeof(*vlan); } - if (dissector_uses_key(flow_dissector, - FLOW_DISSECTOR_KEY_NUM_OF_VLANS)) { + if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_NUM_OF_VLANS) && + !(key_control->flags & FLOW_DIS_ENCAPSULATION)) { struct flow_dissector_key_num_of_vlans *key_nvs; key_nvs = skb_flow_dissector_target(flow_dissector, -- 2.35.1