From: netdev-bot+sashiko@kernel.org
To: willemdebruijn.kernel@gmail.com
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, elder@kernel.org,
willemb@google.com
Subject: Re: [PATCH net-next 5/6] packet: use Ethernet header length in vlan_get_tci()
Date: Wed, 25 Nov 2026 20:06:13 +0000 [thread overview]
Message-ID: <179563717371.3135.6098889691813253582@kernel.org> (raw)
In-Reply-To: <20261124170551.1874487-6-willemdebruijn.kernel@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] packet_recvmsg() (net/packet/af_packet.c:3616-3621) now passes
PACKET_SKB_CB(skb)->sa.ll.sll_hatype to vlan_get_tci() and sets…
--
packet: use Ethernet header length in vlan_get_tci()
This changes vlan_get_tci() to take a device type instead of a device.
For ARPHRD_ETHER and ARPHRD_LOOPBACK devices it now reads the outer VLAN
header at ETH_HLEN, instead of using dev->min_header_len.
packet_recvmsg() now passes the queued sll_hatype instead of looking up
the device by ifindex under RCU.
> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index bf0ad6d5c1e38..b169d3e11b174 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c
[ ... ]
> @@ -3626,19 +3615,10 @@ static int packet_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
> aux.tp_status |= TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
> } else if (unlikely(sock->type == SOCK_DGRAM && eth_type_vlan(skb->protocol))) {
> struct sockaddr_ll *sll = &PACKET_SKB_CB(skb)->sa.ll;
> - struct net_device *dev;
>
> - rcu_read_lock();
> - dev = dev_get_by_index_rcu(sock_net(sk), sll->sll_ifindex);
> - if (dev) {
> - aux.tp_vlan_tci = vlan_get_tci(skb, dev);
> - aux.tp_vlan_tpid = ntohs(skb->protocol);
> - aux.tp_status |= TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
> - } else {
> - aux.tp_vlan_tci = 0;
> - aux.tp_vlan_tpid = 0;
> - }
> - rcu_read_unlock();
> + aux.tp_vlan_tci = vlan_get_tci(skb, sll->sll_hatype);
> + aux.tp_vlan_tpid = ntohs(skb->protocol);
> + aux.tp_status |= TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID;
[Severity: Medium]
Is sll_hatype always filled in for skbs on sk_receive_queue?
For TPACKET_V1/V2 rings, tpacket_rcv() queues a TP_STATUS_COPY skb. Its
sockaddr_ll is zeroed, and sll_hatype and sll_ifindex are never set
afterwards:
net/packet/af_packet.c:tpacket_rcv() {
...
if (copy_skb) {
memset(&PACKET_SKB_CB(copy_skb)->sa.ll, 0,
sizeof(PACKET_SKB_CB(copy_skb)->sa.ll));
skb_set_owner_r(copy_skb, sk);
}
...
__skb_queue_tail(&sk->sk_receive_queue, copy_skb);
...
}
As far as I can see, only packet_rcv() sets sll_hatype in the cb.
For such a copy_skb, sll_hatype is 0, so vlan_get_tci() hits the new
check and returns 0:
if (type != ARPHRD_ETHER && type != ARPHRD_LOOPBACK)
return 0;
The auxdata cmsg would then report tp_vlan_tci 0 with
TP_STATUS_VLAN_VALID set. That happens even when the frame came from an
Ethernet device and carries a real in-band 802.1Q/AD tag.
Before this patch, dev_get_by_index_rcu() failed for sll_ifindex 0, so
the VLAN fields and flags were left clear.
The TPACKET_V2 ring frame for the same packet still calls
vlan_get_tci(skb, dev->type) in tpacket_rcv() and reports the real TCI.
The ring header and the recvmsg() auxdata would then disagree.
One way to reach this is a SOCK_DGRAM socket with a V1/V2 RX ring and
both PACKET_COPY_THRESH and PACKET_AUXDATA set. It then has to receive an
in-band VLAN frame larger than tp_frame_size.
The commit message says:
- packet_recvmsg() previously omitted the VLAN fields if the device
had been unregistered since the packet was queued. It now fills
them from the queued skb.
This assumes the cb always holds the real hatype.
Would it make sense to set PACKET_SKB_CB(copy_skb)->sa.ll.sll_hatype to
dev->type in tpacket_rcv()? Another option is to leave
TP_STATUS_VLAN_VALID clear when the hatype is not Ethernet or loopback.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124170551.1874487-1-willemdebruijn.kernel%40gmail.com
next prev parent reply other threads:[~2026-11-25 20:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 17:05 [PATCH net-next 0/6] net: remove dev_validate_header() and net_device::min_header_len Willem de Bruijn
2026-11-24 17:05 ` [PATCH net-next 1/6] net: ipa: remove ethernet-specific artifacts from modem netdev setup Willem de Bruijn
2026-11-24 17:57 ` Alex Elder
2026-11-24 17:05 ` [PATCH net-next 2/6] net: remove header_ops->validate and dev_validate_header() Willem de Bruijn
2026-11-25 20:06 ` netdev-bot+sashiko
2026-11-24 17:05 ` [PATCH net-next 3/6] packet: validate TX header length before skb allocation Willem de Bruijn
2026-11-25 20:06 ` netdev-bot+sashiko
2026-11-24 17:05 ` [PATCH net-next 4/6] packet: reset network header on all headerless devices Willem de Bruijn
2026-11-24 17:05 ` [PATCH net-next 5/6] packet: use Ethernet header length in vlan_get_tci() Willem de Bruijn
2026-11-25 20:06 ` netdev-bot+sashiko [this message]
2026-11-24 17:05 ` [PATCH net-next 6/6] net: remove unused net_device::min_header_len Willem de Bruijn
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=179563717371.3135.6098889691813253582@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=elder@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
--cc=willemdebruijn.kernel@gmail.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