summaryrefslogtreecommitdiff
path: root/scripts/basic
diff options
context:
space:
mode:
authorKyle Zeng <kylebot@openai.com>2026-10-28 19:14:50 +0100
committerJakub Kicinski <kuba@kernel.org>2026-10-29 08:58:08 -0700
commitdc4dd12f80e499dc034710cd8195489abcf0b059 (patch)
tree259c00e1fd0aeb560456768838656a2f3a181cc6 /scripts/basic
parent59e72644a7e697fdaf3494e8df8af9ab2b2ba31d (diff)
downloadlinux-dc4dd12f80e499dc034710cd8195489abcf0b059.tar.gz
linux-dc4dd12f80e499dc034710cd8195489abcf0b059.zip
net/packet: check TX_RING fragments before memory accounting
tpacket_fill_skb() adds the full non-linear payload length to skb->truesize and sk_wmem_alloc before checking MAX_SKB_FRAGS. With PACKET_VNET_HDR, userspace can submit a ring-sized frame even when it greatly exceeds the device MTU. A near-INT_MAX frame can saturate sk_wmem_alloc before the fragment loop rejects it. A subsequent refcount_add(0x40000001) can temporarily turn REFCOUNT_SATURATED into 1. A concurrent TX completion can then drop that apparent last reference and free the still-live packet socket before refcount_warn_saturate() restores the counter. Check that the remaining payload fits in MAX_SKB_FRAGS pages before accounting it. Include the initial page offset in the calculation, and move the existing -EFAULT handling out of the fragment loop. This preserves the accepted packet sizes and error code while preventing an invalid frame from injecting an oversized byte charge. Fixes: 69e3c75f4d54 ("net: TX_RING and packet mmap") Cc: stable@vger.kernel.org Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com> Signed-off-by: Kyle Zeng <kylebot@openai.com> [edumazet: use net_warn_ratelimited() instead of pr_err(), add a Fixes: tag] Signed-off-by: Eric Dumazet <edumazet@kernel.org> Reviewed-by: Willem de Bruijn <willemb@google.com> Link: https://patch.msgid.link/20261028181450.2221013-1-edumazet@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'scripts/basic')
0 files changed, 0 insertions, 0 deletions