netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Felix Fietkau" <nbd@nbd.name>,
	"Thibaut VARÈNE" <hacks+kernel@slashdirt.org>,
	"Sasha Levin" <sashal@kernel.org>,
	lorenzo@kernel.org, ryder.lee@mediatek.com, kvalo@kernel.org,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, matthias.bgg@gmail.com, Bo.Jiao@mediatek.com,
	sujuan.chen@mediatek.com, shayne.chen@mediatek.com,
	greearb@candelatech.com, sean.wang@mediatek.com,
	deren.wu@mediatek.com, xing.song@mediatek.com,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: [PATCH AUTOSEL 5.15 075/109] mt76: fix encap offload ethernet type check
Date: Mon, 30 May 2022 09:37:51 -0400	[thread overview]
Message-ID: <20220530133825.1933431-75-sashal@kernel.org> (raw)
In-Reply-To: <20220530133825.1933431-1-sashal@kernel.org>

From: Felix Fietkau <nbd@nbd.name>

[ 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 <hacks+kernel@slashdirt.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 7691292526e0..a8a0e6af51f8 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -799,6 +799,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;
 
@@ -812,7 +813,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 5024ddf07cbc..bef8d4a76ed9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
@@ -681,6 +681,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;
 
@@ -694,7 +695,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


  parent reply	other threads:[~2022-05-30 14:12 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220530133825.1933431-1-sashal@kernel.org>
2022-05-30 13:36 ` [PATCH AUTOSEL 5.15 004/109] selftests/bpf: Fix vfs_link kprobe definition Sasha Levin
2022-05-30 13:36 ` [PATCH AUTOSEL 5.15 005/109] selftests/bpf: Fix parsing of prog types in UAPI hdr for bpftool sync Sasha Levin
2022-05-30 13:36 ` [PATCH AUTOSEL 5.15 006/109] mwifiex: add mutex lock for call in mwifiex_dfs_chan_sw_work_queue Sasha Levin
2022-05-30 13:36 ` [PATCH AUTOSEL 5.15 007/109] b43legacy: Fix assigning negative value to unsigned variable Sasha Levin
2022-05-30 13:36 ` [PATCH AUTOSEL 5.15 008/109] b43: " Sasha Levin
2022-05-30 13:36 ` [PATCH AUTOSEL 5.15 009/109] ipw2x00: Fix potential NULL dereference in libipw_xmit() Sasha Levin
2022-05-30 13:36 ` [PATCH AUTOSEL 5.15 010/109] ipv6: fix locking issues with loops over idev->addr_list Sasha Levin
2022-05-30 13:36 ` [PATCH AUTOSEL 5.15 014/109] mac80211: minstrel_ht: fix where rate stats are stored (fixes debugfs output) Sasha Levin
2022-05-30 13:36 ` [PATCH AUTOSEL 5.15 019/109] sfc: ef10: Fix assigning negative value to unsigned variable Sasha Levin
2022-05-30 13:36 ` [PATCH AUTOSEL 5.15 021/109] rtw88: 8821c: fix debugfs rssi value Sasha Levin
2022-05-30 13:37 ` [PATCH AUTOSEL 5.15 031/109] ath9k: fix QCA9561 PA bias level Sasha Levin
2022-05-30 13:37 ` [PATCH AUTOSEL 5.15 043/109] ath11k: disable spectral scan during spectral deinit Sasha Levin
2022-05-30 13:37 ` [PATCH AUTOSEL 5.15 048/109] ath10k: skip ath10k_halt during suspend for driver state RESTARTING Sasha Levin
2022-05-30 13:37 ` [PATCH AUTOSEL 5.15 052/109] ipv6: Don't send rs packets to the interface of ARPHRD_TUNNEL Sasha Levin
2022-05-30 13:37 ` [PATCH AUTOSEL 5.15 053/109] net/mlx5: fs, delete the FTE when there are no rules attached to it Sasha Levin
2022-05-30 13:37 ` [PATCH AUTOSEL 5.15 055/109] mlxsw: spectrum_dcb: Do not warn about priority changes Sasha Levin
2022-05-30 13:37 ` [PATCH AUTOSEL 5.15 056/109] mlxsw: Treat LLDP packets as control Sasha Levin
2022-05-30 13:37 ` [PATCH AUTOSEL 5.15 064/109] net: remove two BUG() from skb_checksum_help() Sasha Levin
2022-05-30 13:37 ` [PATCH AUTOSEL 5.15 073/109] rtlwifi: Use pr_warn instead of WARN_ONCE Sasha Levin
2022-05-30 13:37 ` [PATCH AUTOSEL 5.15 074/109] mt76: mt7921: accept rx frames with non-standard VHT MCS10-11 Sasha Levin
2022-05-30 13:37 ` Sasha Levin [this message]
2022-05-30 13:37 ` [PATCH AUTOSEL 5.15 082/109] usbnet: Run unregister_netdev() before unbind() again Sasha Levin
2022-05-30 13:38 ` [PATCH AUTOSEL 5.15 090/109] net: phy: micrel: Allow probing without .driver_data Sasha Levin
2022-05-30 13:38 ` [PATCH AUTOSEL 5.15 097/109] can: mcp251xfd: silence clang's -Wunaligned-access warning Sasha Levin
2022-05-30 13:38 ` [PATCH AUTOSEL 5.15 099/109] net: ipa: ignore endianness if there is no header Sasha Levin
2022-05-30 13:38 ` [PATCH AUTOSEL 5.15 103/109] rxrpc: Return an error to sendmsg if call failed Sasha Levin
2022-05-30 13:38 ` [PATCH AUTOSEL 5.15 104/109] rxrpc, afs: Fix selection of abort codes Sasha Levin
2022-05-30 13:38 ` [PATCH AUTOSEL 5.15 105/109] afs: Adjust ACK interpretation to try and cope with NAT Sasha Levin
2022-05-30 13:38 ` [PATCH AUTOSEL 5.15 106/109] eth: tg3: silence the GCC 12 array-bounds warning Sasha Levin
2022-05-30 13:38 ` [PATCH AUTOSEL 5.15 108/109] selftests/bpf: fix btf_dump/btf_dump due to recent clang change Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220530133825.1933431-75-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=Bo.Jiao@mediatek.com \
    --cc=davem@davemloft.net \
    --cc=deren.wu@mediatek.com \
    --cc=edumazet@google.com \
    --cc=greearb@candelatech.com \
    --cc=hacks+kernel@slashdirt.org \
    --cc=kuba@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ryder.lee@mediatek.com \
    --cc=sean.wang@mediatek.com \
    --cc=shayne.chen@mediatek.com \
    --cc=stable@vger.kernel.org \
    --cc=sujuan.chen@mediatek.com \
    --cc=xing.song@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).