All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: wei.fang@oss.nxp.com
Cc: bpf@vger.kernel.org, Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH net 2/2] net: tap: fix skb->protocol not updated after VLAN network header adjustment
Date: Thu, 06 Aug 2026 10:49:58 +0000	[thread overview]
Message-ID: <20260806104959.3B0D61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805105314.3882595-3-wei.fang@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Incomplete fix: `skb->protocol` is not updated after `network_header` adjustment in `tap_get_user()`.
--

--- Patch [2]: [PATCH net 2/2] net: tap: fix skb->protocol not updated after VLAN network header adjustment ---
commit 6866d2a8bbb104d45013a4b8fcd7c1800086ae28
Author: Wei Fang <wei.fang@nxp.com>

net: tap: fix skb->protocol not updated after VLAN network header adjustment

This commit fixes an issue in tap_get_user_xdp() where skb->protocol was not
updated after advancing the network header past the VLAN tag. It sets the
protocol to the inner EtherType to keep skb->protocol and network_header
consistent for subsequent processing.

> diff --git a/drivers/net/tap.c b/drivers/net/tap.c
> index fae115915c8ef..afcc4919bd042 100644
> --- a/drivers/net/tap.c
> +++ b/drivers/net/tap.c
> @@ -1081,9 +1081,15 @@ static int tap_get_user_xdp(struct tap_queue *q, struct xdp_buff *xdp)
>  	}
>  
>  	/* Move network header to the right position for VLAN tagged packets */
> -	if (eth_type_vlan(skb->protocol) &&
> -	    vlan_get_protocol_and_depth(skb, skb->protocol, &depth) != 0)
> -		skb_set_network_header(skb, depth);
> +	if (eth_type_vlan(skb->protocol)) {
> +		__be16 proto = vlan_get_protocol_and_depth(skb, skb->protocol,
> +							   &depth);
> +
> +		if (proto != 0) {
> +			skb_set_network_header(skb, depth);
> +			skb->protocol = proto;
> +		}
> +	}

[Severity: High]
This isn't a bug introduced by this patch, but does tap_get_user() also need
this same fix for non-XDP transmission paths?

Looking at tap_get_user() in drivers/net/tap.c, it contains the identical
logic that was patched here:

drivers/net/tap.c:tap_get_user() {
    ...
    /* Move network header to the right position for VLAN tagged packets */
    if (eth_type_vlan(skb->protocol) &&
        vlan_get_protocol_and_depth(skb, skb->protocol, &depth) != 0)
        skb_set_network_header(skb, depth);
    ...
}

Without updating skb->protocol here as well, will TC egress and eBPF programs
still read skb->protocol as ETH_P_8021Q while network_header points to the
inner IP header?

If a user or guest VM writes a VLAN-tagged packet to a TAP file descriptor
using standard (non-XDP) I/O, could this allow them to craft an IP header
that causes traffic classification and security policies to misinterpret the
packet?

>  
>  	rcu_read_lock();
>  	tap = rcu_dereference(q->tap);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260805105314.3882595-1-wei.fang@oss.nxp.com?part=2

      parent reply	other threads:[~2026-08-06 10:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05 10:53 [PATCH net 0/2] net: fix skb->protocol not updated after VLAN network header adjustment wei.fang
2026-08-05 10:53 ` [PATCH net 1/2] net: packet: " wei.fang
2026-08-06 10:49   ` sashiko-bot
2026-08-05 10:53 ` [PATCH net 2/2] net: tap: " wei.fang
2026-08-05 12:48   ` Willem de Bruijn
2026-08-06  2:10     ` Wei Fang
2026-08-06 10:06       ` Wei Fang
2026-08-06 14:12         ` Willem de Bruijn
2026-08-07  2:21           ` Wei Fang
2026-08-06 10:49   ` sashiko-bot [this message]

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=20260806104959.3B0D61F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wei.fang@oss.nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.