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 2/6] net: remove header_ops->validate and dev_validate_header()
Date: Wed, 25 Nov 2026 20:06:11 +0000 [thread overview]
Message-ID: <179563717146.3135.13828888789756005056@kernel.org> (raw)
In-Reply-To: <20261124170551.1874487-3-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 (1)
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] In packet_sendmsg_spkt() (net/packet/af_packet.c), the
SOCK_PACKET send path now checks the packet length against the wrong…
Pre-existing issues:
- [Low] Baseline decision: false (kept only because
requires_validation=true).
--
net: remove header_ops->validate and dev_validate_header()
This patch removes header_ops->validate and dev_validate_header(). Their
only user, AX.25, has been removed, and so has the CAP_SYS_RAWIO bypass.
The three af_packet callers now compare directly against the snapshotted
hard_header_len.
> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index 96c5216a9d6b4..230b16742346c 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c
> @@ -2060,7 +2060,7 @@ static int packet_sendmsg_spkt(struct socket *sock, struct msghdr *msg,
> goto retry;
> }
>
> - if (!dev_validate_header(dev, skb->data, len) || !skb->len) {
> + if (len < hard_header_len || !skb->len) {
[Severity: Medium]
Is this check still the same as the old one when the lookup after the retry
returns a different net_device?
packet_sendmsg_spkt() looks up the device by name twice: once before the
skb is allocated, and again after goto retry. hard_header_len is only
read on the first pass:
/* Keep the allocation-time header length across retry. */
if (!skb)
hard_header_len = READ_ONCE(dev->hard_header_len);
The old dev_validate_header(dev, skb->data, len) read dev->hard_header_len
from the device found on the retry. That is the device passed to
dev_queue_xmit(). The new check uses the value from the first device.
Between the two lookups the RCU lock is dropped, and the code sleeps in
sock_wmalloc() and memcpy_from_msg(). User space can stall that copy with
a userfaultfd or FUSE backed buffer. Meanwhile the name can move to
another device: netif_change_name() allows renames while the device is
IFF_UP, the device can be deleted and recreated, or the name can become an
altname on another device.
Take a name that first resolves to a tun device (hard_header_len 0) and
then to a veth device (hard_header_len 14). A 1 byte frame now passes
len < hard_header_len, where the old code returned -EINVAL. Can that frame
then reach dev_queue_xmit() on the veth? If so, eth_type_trans() on the
peer would read eth->h_proto from skb->data past skb->len.
CAP_NET_RAW in a network namespace the user owns is enough to reach this.
packet_snd() and tpacket_fill_skb() have a weaker version of this. They
no longer see hard_header_len grow on the same device (for example
through a bonding type change) during the sleeping allocation and copy.
tpacket_fill_skb() also uses a single value for the whole tpacket_snd()
batch. In those two paths the old live check could also go stale right
after it ran.
The commit message describes these as "direct checks against the already
snapshotted hard_header_len". For packet_sendmsg_spkt(), though, the
snapshot comes from a device that may not be the one sent on.
Later in the series, "packet: validate TX header length before skb
allocation" moves this check into the first-pass if (!skb) block. If I
read it right, the device found on the retry is still never checked at the
end of the series.
[Severity: Low]
This is a pre-existing issue, but with this check the short-header branch
in the allocation path of packet_sendmsg_spkt() looks like dead code:
if (hhlen) {
skb->data -= hhlen;
skb->tail -= hhlen;
if (len < hhlen)
skb_reset_network_header(skb);
}
hhlen is either 0 or hard_header_len. Any skb that takes the len < hhlen
branch is therefore rejected by the len < hard_header_len check after the
retry. The branch already had no effect on sent packets once AX.25 was
removed.
"packet: validate TX header length before skb allocation" removes it later
in the series.
> err = -EINVAL;
> goto out_unlock;
> }
[ ... ]
--
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 [this message]
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
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=179563717146.3135.13828888789756005056@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