From patchwork Sun Jul 18 19:36:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 479780 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 995F0C636CA for ; Sun, 18 Jul 2021 19:37:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7EA86600D1 for ; Sun, 18 Jul 2021 19:37:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233038AbhGRTkB (ORCPT ); Sun, 18 Jul 2021 15:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232416AbhGRTjx (ORCPT ); Sun, 18 Jul 2021 15:39:53 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D52ECC061765 for ; Sun, 18 Jul 2021 12:36:54 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id h6-20020a17090a6486b029017613554465so816463pjj.4 for ; Sun, 18 Jul 2021 12:36:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vkuPQlfLc8x6m8zemIE7YniMiEv3qfl1KwaOIkRSJac=; b=MsaS+phnrIUh27uFuqlS4O97N2q1gIZ1/csDCAtWDV1mXR8dMDfmxprmiTfGDND/gc Uh8/2TBB4ghMhNcworHlSmJMOhbsvECJJjdAS+ZsdxnWEItbwajfWd4lGzZnnHrpXwUn br4vNR56Wlxq1MO/2/JMflgq8ygtwJwTc6d8g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vkuPQlfLc8x6m8zemIE7YniMiEv3qfl1KwaOIkRSJac=; b=llte6x3PC8vf2XCJXAHD+J4ayUAmxBfaecmarihEwp2jH9gEY12UMj4hfRN3ZZCwzZ eQsa5AvbbrAOXbfplpOAwV4m/jBjIVNM+I/4+kZ9JYWv1VLMxgmxS1+PXWgLRSkZ/Jt9 yPZ5pZfKr7ChILCWCwbO3ZTQsbIiFhTuBVjolj8ZfhzUgdY0qj8zsKrROwQ3ireZrdRZ sJQFwSD1X3fzvOgaUQ9tXxR0tt6CNEKCU8+eC9QzmUZt7bVlW3wmh5t9OvQNQuT/kbHa 8lS4p7bE2N7VZkrI4GtgDK+VDY529lGKYiJ6VxuoSVujYlM8k1qbOJog1ghgi+0kv3mM Y9cA== X-Gm-Message-State: AOAM533Yu9FgAfCAwgywzohd9H/m8jPxDZW544laH2EuL26tYhqlyhAi 2zHYfHxjZ2etTElnqhzmldo4xmmrnc/pAods X-Google-Smtp-Source: ABdhPJz4gqzETibe1Dk2xFZzIRs4TzMZAjuwW5gq+bVdYAETNQUjNirrteD4fOvkL9XIKtM3IF35cA== X-Received: by 2002:a17:902:c402:b029:12b:5175:1ddd with SMTP id k2-20020a170902c402b029012b51751dddmr16566268plk.67.1626637014108; Sun, 18 Jul 2021 12:36:54 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 22sm16743648pfo.80.2021.07.18.12.36.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Jul 2021 12:36:53 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, gospo@broadcom.com Subject: [PATCH net 6/9] bnxt_en: Validate vlan protocol ID on RX packets Date: Sun, 18 Jul 2021 15:36:30 -0400 Message-Id: <1626636993-31926-7-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1626636993-31926-1-git-send-email-michael.chan@broadcom.com> References: <1626636993-31926-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Only pass supported VLAN protocol IDs for stripped VLAN tags to the stack. The stack will hit WARN() if the protocol ID is unsupported. Existing firmware sets up the chip to strip 0x8100, 0x88a8, 0x9100. Only the 1st two protocols are supported by the kernel. Fixes: a196e96bb68f ("bnxt_en: clean up VLAN feature bit handling") Reviewed-by: Somnath Kotur Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index f2f1136fd492..169f093e01de 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -1671,11 +1671,16 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, if ((tpa_info->flags2 & RX_CMP_FLAGS2_META_FORMAT_VLAN) && (skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)) { - u16 vlan_proto = tpa_info->metadata >> - RX_CMP_FLAGS2_METADATA_TPID_SFT; + __be16 vlan_proto = htons(tpa_info->metadata >> + RX_CMP_FLAGS2_METADATA_TPID_SFT); u16 vtag = tpa_info->metadata & RX_CMP_FLAGS2_METADATA_TCI_MASK; - __vlan_hwaccel_put_tag(skb, htons(vlan_proto), vtag); + if (eth_type_vlan(vlan_proto)) { + __vlan_hwaccel_put_tag(skb, vlan_proto, vtag); + } else { + dev_kfree_skb(skb); + return NULL; + } } skb_checksum_none_assert(skb); @@ -1897,9 +1902,15 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, (skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)) { u32 meta_data = le32_to_cpu(rxcmp1->rx_cmp_meta_data); u16 vtag = meta_data & RX_CMP_FLAGS2_METADATA_TCI_MASK; - u16 vlan_proto = meta_data >> RX_CMP_FLAGS2_METADATA_TPID_SFT; + __be16 vlan_proto = htons(meta_data >> + RX_CMP_FLAGS2_METADATA_TPID_SFT); - __vlan_hwaccel_put_tag(skb, htons(vlan_proto), vtag); + if (eth_type_vlan(vlan_proto)) { + __vlan_hwaccel_put_tag(skb, vlan_proto, vtag); + } else { + dev_kfree_skb(skb); + goto next_rx; + } } skb_checksum_none_assert(skb);