Netdev List
 help / color / mirror / Atom feed
* [PATCH net v6 0/3] net: fix hard_header_len races in packet send paths
@ 2026-08-05 12:57 Qihang
  2026-08-05 12:57 ` [PATCH net v6 1/3] net: remove CAP_SYS_RAWIO zero-padding in dev_validate_header Qihang
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Qihang @ 2026-08-05 12:57 UTC (permalink / raw)
  To: netdev
  Cc: willemdebruijn.kernel, willemb, daniel.zahka, davem, edumazet,
	kuba, pabeni, horms, stable, Qihang Tang

From: Qihang Tang <q.h.hack.winter@gmail.com>

The packet socket TX paths read dev->hard_header_len independently for
skb allocation and header construction. Concurrent netdevice
reconfiguration (e.g. bonding device type changes) can change this value
in between, leading to mismatched headroom and copy length, and in the
SOCK_RAW case to out-of-bounds writes.

Patch 1 removes the CAP_SYS_RAWIO zero-padding branch in
dev_validate_header(). That branch sizes a memset against the live
dev->hard_header_len while operating on an skb whose headroom was
allocated from an earlier hard_header_len read, so a concurrent increase
can write past the reserved buffer. Removing it first keeps the later
snapshot fixes bisect-safe: they do not replace an earlier skb_under_panic
with a silent overwrite.

Patches 2 and 3 snapshot hard_header_len once per send and use it
consistently for allocation and construction, in the non-ring and TX_RING
paths respectively. The separate SOCK_DGRAM consistency problem between
hard_header_len and header_ops->create remains out of scope, as noted in
the commit messages.

v5 -> v6:
- Fix Signed-off-by to use full name (DCO).
- Add patch 1: remove CAP_SYS_RAWIO zero-padding in dev_validate_header,
  before the snapshot fixes for per-commit safety. Suggested by Willem de
  Bruijn.
- Add Reviewed-by from Willem de Bruijn to the TX_RING patch (given on v5).

v5: https://lore.kernel.org/netdev/20260730082925.93759-1-q.h.hack.winter@gmail.com/

Qihang Tang (3):
  net: remove CAP_SYS_RAWIO zero-padding in dev_validate_header
  packet: use consistent hard_header_len in non-ring send paths
  packet: use consistent hard_header_len in TX_RING send path

 include/linux/netdevice.h | 11 ++++------
 net/packet/af_packet.c    | 45 +++++++++++++++++++++++----------------
 2 files changed, 31 insertions(+), 25 deletions(-)

-- 
2.50.1 (Apple Git-155)

^ permalink raw reply	[flat|nested] 9+ messages in thread
* [PATCH net v5 0/2] packet: use consistent hard_header_len in send paths
@ 2026-07-30  8:29 Qihang
  2026-08-04  9:00 ` [PATCH net v6 0/3] net: fix hard_header_len races in packet " Qihang
  0 siblings, 1 reply; 9+ messages in thread
From: Qihang @ 2026-07-30  8:29 UTC (permalink / raw)
  To: netdev
  Cc: willemdebruijn.kernel, daniel.zahka, davem, edumazet, kuba,
	pabeni, horms, stable, Qihang

AF_PACKET send paths read dev->hard_header_len at several stages of skb
allocation and construction. Concurrent netdevice reconfiguration can
make those reads inconsistent and cause skb headroom underflow.

Split the regular and TX_RING paths so each patch has one Fixes tag.
The separate SOCK_DGRAM consistency issue between hard_header_len and
header_ops->create remains outside this series.

Changes in v5:
- Drop the unnecessary per-frame copylen reset from patch 2.

Changes in v4:
- Use one hard_header_len snapshot throughout tpacket_snd(), including
  reserve and per-frame skb construction.
- Carry Willem's Reviewed-by on patch 1.

Link to v4: https://lore.kernel.org/netdev/20260729030122.21462-1-q.h.hack.winter@gmail.com/
Link to v3: https://lore.kernel.org/netdev/20260728031345.49562-1-q.h.hack.winter@gmail.com/

Qihang (2):
  packet: use consistent hard_header_len in non-ring send paths
  packet: use consistent hard_header_len in TX_RING send path

 include/linux/netdevice.h |  6 ++++--
 net/packet/af_packet.c    | 45 +++++++++++++++++++++++----------------
 2 files changed, 31 insertions(+), 20 deletions(-)

-- 
2.50.1 (Apple Git-155)

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-08-06 16:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05 12:57 [PATCH net v6 0/3] net: fix hard_header_len races in packet send paths Qihang
2026-08-05 12:57 ` [PATCH net v6 1/3] net: remove CAP_SYS_RAWIO zero-padding in dev_validate_header Qihang
2026-08-06  3:07   ` Willem de Bruijn
2026-08-05 12:57 ` [PATCH net v6 2/3] packet: use consistent hard_header_len in non-ring send paths Qihang
2026-08-05 12:57 ` [PATCH net v6 3/3] packet: use consistent hard_header_len in TX_RING send path Qihang
2026-08-06 16:50 ` [PATCH net v6 0/3] net: fix hard_header_len races in packet send paths patchwork-bot+netdevbpf
  -- strict thread matches above, loose matches on Subject: below --
2026-07-30  8:29 [PATCH net v5 0/2] packet: use consistent hard_header_len in " Qihang
2026-08-04  9:00 ` [PATCH net v6 0/3] net: fix hard_header_len races in packet " Qihang
2026-08-04  9:00   ` [PATCH net v6 1/3] net: remove CAP_SYS_RAWIO zero-padding in dev_validate_header Qihang
2026-08-04 12:16     ` Willem de Bruijn
2026-08-04 23:44       ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox