]> git.ipfire.org Git - thirdparty/linux.git/commit
packet: use consistent hard_header_len in TX_RING send path
authorQihang Tang <q.h.hack.winter@gmail.com>
Wed, 5 Aug 2026 12:57:29 +0000 (20:57 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 6 Aug 2026 16:27:21 +0000 (09:27 -0700)
commit21b5953e7494c16a42e6cd8cf110e18d13ae4a6b
tree97419de8a99d62dfc355e27d91fd00879b05b069
parent03390aa32e669cc4ecd7d34108e2e1afc13d689d
packet: use consistent hard_header_len in TX_RING send path

tpacket_snd() reads dev->hard_header_len independently for skb
allocation and header construction in tpacket_fill_skb(). Concurrent
netdevice reconfiguration can therefore make the reserved headroom
smaller than the amount later pushed, or make copylen - hard_header_len
negative.

Snapshot hard_header_len once before processing ring frames and use it
for the frame limit, headroom allocation, copy length, and skb
construction. Pass the snapshot to tpacket_fill_skb().

The separate SOCK_DGRAM consistency problem between hard_header_len and
header_ops->create is not addressed here.

Fixes: 69e3c75f4d54 ("net: TX_RING and packet mmap")
Cc: stable@vger.kernel.org
Signed-off-by: Qihang Tang <q.h.hack.winter@gmail.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20260805125729.19220-4-q.h.hack.winter@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/packet/af_packet.c