Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2148748iof; Tue, 7 Jun 2022 21:22:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUZopuR5x5xwk8m7KsARVl567BIbjMC8sevEyytO84rFt1vWHK5KwcHS/O+vu86kE7PhHA X-Received: by 2002:a17:90b:1c92:b0:1dd:10ff:8f13 with SMTP id oo18-20020a17090b1c9200b001dd10ff8f13mr69807634pjb.54.1654662155366; Tue, 07 Jun 2022 21:22:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654662155; cv=none; d=google.com; s=arc-20160816; b=vadk5jvOvuXyC6I07QKJGx2tg0wm1TFuX6b55Ul0+ThBkmD/6Xe8Gbc8uUlSsOs8Rl DbQkGV2qM/NSsNXE3s0fAMyQWIopBZxh4Tkyv39YrSTR5jXTYM5vYKlmtBfa4tq2Fddc jqri7+L2nO+8R63yNPFwUxgRcodE2AEKSrcHk4am98TeY+LEtn8iC5BCvU3fQfndLaEe W9WQzYAX59USOkkJs7m0XdI+b0qj2PQ3RKiReZyTm0qjPeX0FyxHQL5g2bzbaiHNKQZ5 6WHlT1STM78H9TLjc74DvJruM7sLyb6swCXbKvwQ/qgdPHhr0MNu6DS/Na03TpkL5xPR bTpQ== 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=Y8ccpYIsXokUdzLgE9yFd8+AMvE2UlaM6cNSwIiFQkE=; b=OvyFV6q5hwmmn6Gcq/FbWJlnejDoVEUWddUkedJJTfPzKwWig8ZduApXD7avbzO5Xn cFx0c2dHDjrI7GYdjVfLZssZBnz+elUdoEq+Ncejkie1Yx5ytjS+724tt191Ag8Icn5e RgnhajNcVf1rkaLJLQveweoa6rzHtJEkiBlM+1bNag+gtEuCcvx1nCwterieOAyHBLlS gUdblxge9zrMstL/mV2cwdc61z9kB4pBkzylUlXdt+JmPUnbOpCi7Nn5vjWJOLS6BUjI 65YgSZNiga0JHoQGscZZ2QmCyVWymrRCR/BCNaH38MdaJw/VwW67vop9oABQrN0fNEIb 8a4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=j4Q55Z7L; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z15-20020a170902cccf00b00163c52336fbsi10009615ple.369.2022.06.07.21.22.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:22:35 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=j4Q55Z7L; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 27CD0290BC4; Tue, 7 Jun 2022 21:11:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384467AbiFGWOZ (ORCPT + 99 others); Tue, 7 Jun 2022 18:14:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380017AbiFGVLX (ORCPT ); Tue, 7 Jun 2022 17:11:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C39D9131F19; Tue, 7 Jun 2022 11:52:55 -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 291D3B82182; Tue, 7 Jun 2022 18:52:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82772C385A5; Tue, 7 Jun 2022 18:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627972; bh=edmrEx74CLJEL2ZSmVTR+lC6JWHI26Po+D1lAUpwoPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j4Q55Z7L8Tw3J/7qB58IA4eiMBgcgrUKZOowfNQr0hyWpydyceiA/q5cB6ZG+91tA YJhET7idukzVIQRbJRX+vMJWAkqXY1C4KRiXL2Ul85jeJT/ywQvutO9tYwQPBQA3s0 M2jEgyU/sWdyg6Egxvj9CMekeNhNJz/FRRcCMwPw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Thibaut=20VAR=C3=88NE?= , Felix Fietkau , Sasha Levin Subject: [PATCH 5.18 161/879] mt76: fix encap offload ethernet type check Date: Tue, 7 Jun 2022 18:54:39 +0200 Message-Id: <20220607165007.379568253@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Felix Fietkau [ Upstream commit bc98e7fdd80d215b4b55eea001023231eb8ce12e ] The driver needs to check if the format is 802.2 vs 802.3 in order to set a tx descriptor flag. skb->protocol can't be used, since it may not be properly initialized for packets coming in from a packet socket. Fix misdetection by checking the ethertype from the skb data instead Reported-by: Thibaut VARĂˆNE Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 4 +++- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index a8df65cc115f..eaa31f5e0b00 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1017,6 +1017,7 @@ mt7915_mac_write_txwi_8023(struct mt7915_dev *dev, __le32 *txwi, u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; u8 fc_type, fc_stype; + u16 ethertype; bool wmm = false; u32 val; @@ -1030,7 +1031,8 @@ mt7915_mac_write_txwi_8023(struct mt7915_dev *dev, __le32 *txwi, val = FIELD_PREP(MT_TXD1_HDR_FORMAT, MT_HDR_FORMAT_802_3) | FIELD_PREP(MT_TXD1_TID, tid); - if (be16_to_cpu(skb->protocol) >= ETH_P_802_3_MIN) + ethertype = get_unaligned_be16(&skb->data[12]); + if (ethertype >= ETH_P_802_3_MIN) val |= MT_TXD1_ETH_802_3; txwi[1] |= cpu_to_le32(val); diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index f34070ca7bbe..c5350e7a11e6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -814,6 +814,7 @@ mt7921_mac_write_txwi_8023(struct mt7921_dev *dev, __le32 *txwi, { u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; u8 fc_type, fc_stype; + u16 ethertype; bool wmm = false; u32 val; @@ -827,7 +828,8 @@ mt7921_mac_write_txwi_8023(struct mt7921_dev *dev, __le32 *txwi, val = FIELD_PREP(MT_TXD1_HDR_FORMAT, MT_HDR_FORMAT_802_3) | FIELD_PREP(MT_TXD1_TID, tid); - if (be16_to_cpu(skb->protocol) >= ETH_P_802_3_MIN) + ethertype = get_unaligned_be16(&skb->data[12]); + if (ethertype >= ETH_P_802_3_MIN) val |= MT_TXD1_ETH_802_3; txwi[1] |= cpu_to_le32(val); -- 2.35.1