diff mbox series

[v2] net: mhi: set skb mac header before entering RX path

Message ID 20240517211909.27874-1-faecknitz@hotsplots.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [v2] net: mhi: set skb mac header before entering RX path | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 920 this patch: 920
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 1 blamed authors not CCed: loic.poulain@linaro.org; 4 maintainers not CCed: pabeni@redhat.com kuba@kernel.org loic.poulain@linaro.org edumazet@google.com
netdev/build_clang success Errors and warnings before: 925 this patch: 925
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 925 this patch: 925
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-05-19--03-00 (tests: 1039)

Commit Message

Martin Fäcknitz May 17, 2024, 9:19 p.m. UTC
skb->mac_header must be set before passing the skb to the network stack,
because skb->mac_len is calculated from skb->mac_header in
__netif_receive_skb_core.

Some network stack components, like xfrm, are using skb->mac_len to
check for an existing MAC header, which doesn't exist in this case. This
leads to memory corruption.

Fixes: 7ffa7542eca6 ("net: mhi: Remove MBIM protocol")
Signed-off-by: Martin Fäcknitz <faecknitz@hotsplots.de>
---
v2: - add "Fixes" tag
    - CC maintainers

 drivers/net/mhi_net.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Paolo Abeni May 22, 2024, 8:36 a.m. UTC | #1
On Fri, 2024-05-17 at 23:19 +0200, Martin Fäcknitz wrote:
> skb->mac_header must be set before passing the skb to the network stack,
> because skb->mac_len is calculated from skb->mac_header in
> __netif_receive_skb_core.
> 
> Some network stack components, like xfrm, are using skb->mac_len to
> check for an existing MAC header, which doesn't exist in this case. This
> leads to memory corruption.
> 
> Fixes: 7ffa7542eca6 ("net: mhi: Remove MBIM protocol")

I'm possibly missing something, but the above tag looks incorrect:
AFAICS the mac header was not set even before such commit for the non
WWAN case.

Thanks,

Paolo
diff mbox series

Patch

diff --git a/drivers/net/mhi_net.c b/drivers/net/mhi_net.c
index ae169929a9d8..e432efddcb22 100644
--- a/drivers/net/mhi_net.c
+++ b/drivers/net/mhi_net.c
@@ -221,6 +221,8 @@  static void mhi_net_dl_callback(struct mhi_device *mhi_dev,
 			break;
 		}
 
+		skb_reset_mac_header(skb);
+
 		u64_stats_update_begin(&mhi_netdev->stats.rx_syncp);
 		u64_stats_inc(&mhi_netdev->stats.rx_packets);
 		u64_stats_add(&mhi_netdev->stats.rx_bytes, skb->len);