From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: netdev@vger.kernel.org
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
elder@kernel.org, Willem de Bruijn <willemb@google.com>
Subject: [PATCH net-next 2/6] net: remove header_ops->validate and dev_validate_header()
Date: Tue, 24 Nov 2026 12:05:40 -0500 [thread overview]
Message-ID: <20261124170551.1874487-3-willemdebruijn.kernel@gmail.com> (raw)
In-Reply-To: <20261124170551.1874487-1-willemdebruijn.kernel@gmail.com>
From: Willem de Bruijn <willemb@google.com>
header_ops->validate was added in commit 2793a23aacbd ("net: validate
variable length ll headers") for AX.25, its only implementation. AX.25
was removed in commit dd8d4bc28ad7 ("net: remove ax25 and amateur radio
(hamradio) subsystem"), and the CAP_SYS_RAWIO bypass in
dev_validate_header() was removed in commit 3b9a324e646d ("net: remove
CAP_SYS_RAWIO zero-padding in dev_validate_header").
With both gone, dev_validate_header() only checks
len >= dev->hard_header_len. Remove header_ops->validate and
dev_validate_header(), and replace the only callers in af_packet with
direct checks against the already snapshotted hard_header_len.
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
include/linux/netdevice.h | 16 ----------------
net/packet/af_packet.c | 7 +++----
2 files changed, 3 insertions(+), 20 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 694b6d29f680..930899a7a577 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -326,7 +326,6 @@ struct header_ops {
void (*cache_update)(struct hh_cache *hh,
const struct net_device *dev,
const unsigned char *haddr);
- bool (*validate)(const char *ll_header, unsigned int len);
__be16 (*parse_protocol)(const struct sk_buff *skb);
};
@@ -3587,21 +3586,6 @@ static inline __be16 dev_parse_header_protocol(const struct sk_buff *skb)
return dev->header_ops->parse_protocol(skb);
}
-/* ll_header must have at least hard_header_len allocated */
-static inline bool dev_validate_header(const struct net_device *dev,
- char *ll_header, int len)
-{
- if (likely(len >= dev->hard_header_len))
- return true;
- if (len < dev->min_header_len)
- return false;
-
- if (dev->header_ops && dev->header_ops->validate)
- return dev->header_ops->validate(ll_header, len);
-
- return false;
-}
-
static inline bool dev_has_header(const struct net_device *dev)
{
return dev->header_ops && dev->header_ops->create;
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 96c5216a9d6b..230b16742346 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) {
err = -EINVAL;
goto out_unlock;
}
@@ -2644,7 +2644,7 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
err = skb_store_bits(skb, 0, data, hdrlen);
if (unlikely(err))
return err;
- if (!dev_validate_header(dev, skb->data, hdrlen))
+ if (hdrlen < hard_header_len)
return -EINVAL;
data += hdrlen;
@@ -3115,8 +3115,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
if (err)
goto out_free;
- if ((sock->type == SOCK_RAW &&
- !dev_validate_header(dev, skb->data, len)) || !skb->len) {
+ if ((sock->type == SOCK_RAW && len < hard_header_len) || !skb->len) {
err = -EINVAL;
goto out_free;
}
--
2.56.1.839.g22a8290db9-goog
next prev parent reply other threads:[~2026-11-24 17:05 UTC|newest]
Thread overview: 7+ 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:05 ` Willem de Bruijn [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-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-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=20261124170551.1874487-3-willemdebruijn.kernel@gmail.com \
--to=willemdebruijn.kernel@gmail.com \
--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 \
/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