mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v2 0/2] net: do not run out of frags in alloc_skb_with_frags()
@ 2026-11-10 16:24 Haishuang Yan
  2026-11-10 16:24 ` [PATCH net v2 1/2] " Haishuang Yan
  2026-11-10 16:24 ` [PATCH net v2 2/2] net: add a KUnit test for the alloc_skb_with_frags() tail split Haishuang Yan
  0 siblings, 2 replies; 6+ messages in thread
From: Haishuang Yan @ 2026-11-10 16:24 UTC (permalink / raw)
  To: netdev
  Cc: yanhaishuang, davem, edumazet, kuba, pabeni, horms, almasrymina,
	daniel, willemb, willemdebruijn.kernel, mst, jasowangio,
	eperezma, narcisav.kernel, linux-kernel

alloc_skb_with_frags() can fail with -ENOBUFS for a data_len that passed
its own size check: it splits the tail into one frag per bit set in its
page count, and when a high-order allocation fails it lowers the order
without checking that the frags left can still hold the rest. With
vhost-net + tun, a guest that sends a GSO packet above 64K can then make
the vhost worker retry that packet forever (100% CPU, device dead).
Patch 1 fixes both cases; patch 2 adds a KUnit test for the tail case.

The issues were found with the help of an AI coding assistant.

Changes in v2:
- Patch 1: also fix the fallback after a failed high-order allocation:
  only lower the order while the frags left can hold the rest, else
  retry the same order once with direct reclaim (reported by the netdev
  AI review of v1). Changelog and test notes updated, including fault
  injection results.
- Patch 1: reword the comment as suggested by Narcisa, and compute the
  page count with DIV_ROUND_UP() to keep the line within 80 columns.
- Patch 1: say in the changelog that this only fixes the frag accounting;
  larger frames failing in tun_alloc_skb() are a separate problem.
- Patch 2: skip the test instead of failing it when no order-3 page can
  be had, and name the fix by its subject. Dropped Narcisa's Reviewed-by
  since the test changed.

v1: https://lore.kernel.org/netdev/20261108100617.23840-1-yanhaishuang@cmss.chinamobile.com/

Haishuang Yan (2):
  net: do not run out of frags in alloc_skb_with_frags()
  net: add a KUnit test for the alloc_skb_with_frags() tail split

 net/core/net_test.c | 35 +++++++++++++++++++++++++++++++++++
 net/core/skbuff.c   | 30 ++++++++++++++++++++++++++++--
 2 files changed, 63 insertions(+), 2 deletions(-)


base-commit: a45dbf182137275f44ad7c8bc8acd23f7af6b2cf
-- 
2.43.0




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

end of thread, other threads:[~2026-11-14 14:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10 16:24 [PATCH net v2 0/2] net: do not run out of frags in alloc_skb_with_frags() Haishuang Yan
2026-11-10 16:24 ` [PATCH net v2 1/2] " Haishuang Yan
2026-11-10 17:18   ` Eric Dumazet
2026-11-14 14:45   ` netdev-bot+sashiko
2026-11-10 16:24 ` [PATCH net v2 2/2] net: add a KUnit test for the alloc_skb_with_frags() tail split Haishuang Yan
2026-11-14 14:45   ` netdev-bot+sashiko

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

all inboxes | Powered by JetHome®