* [PATCH net] tun: reject oversized skb head allocations
@ 2026-11-29 2:05 Zhao Gongyi
2026-11-29 2:08 ` netdev-bot+sinfo
0 siblings, 1 reply; 2+ messages in thread
From: Zhao Gongyi @ 2026-11-29 2:05 UTC (permalink / raw)
To: netdev
Cc: Zhao Gongyi, Willem de Bruijn, Jason Wang, Andrew Lunn,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Haishuang Yan, Narcisa Vasile, stable, linux-kernel
tun_alloc_skb() moves payload beyond the page-fragment capacity into
the linear head without checking the resulting allocation size.
If the head exceeds KMALLOC_MAX_SIZE, kmalloc_reserve() retries
without __GFP_NOWARN for tasks eligible for pfmemalloc reserves. This
can trigger a warning and panic when panic_on_warn is enabled:
WARNING: mm/slub.c:5459 at ___kmalloc_large_node+0x111/0x140
Call Trace:
kmalloc_reserve
__alloc_skb
alloc_skb_with_frags
sock_alloc_send_pskb
tun_get_user
tun_chr_write_iter
Reject requests whose aligned head, including headroom and
skb_shared_info, exceeds KMALLOC_MAX_SIZE with -EMSGSIZE before
allocation.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Link: https://lore.kernel.org/netdev/20261108180953.67715-1-yanhaishuang@cmss.chinamobile.com/
Cc: stable@vger.kernel.org
Cc: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Cc: Narcisa Vasile <narcisav.kernel@gmail.com>
Signed-off-by: Zhao Gongyi <zhaogongyi@bytedance.com>
---
Full W=1 builds on net (x86-64, GCC 12.2.0) passed under
allyesconfig and allmodconfig with CONFIG_WERROR=n. With WERROR=y,
baseline and patched builds failed on the same existing warnings.
No new diagnostics were observed after applying the patch.
TUN/TAP selftests had identical A/B results: TUN 7 pass / 84 fail /
12 xfail; TAP 0 pass / 3 fail. Geneve and interface setup failures
limit regression coverage.
drivers/net/tun.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index ae05b1e58..771c8bba8 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1570,6 +1570,9 @@ static struct sk_buff *tun_alloc_skb(struct tun_file *tfile,
if (len - linear > MAX_SKB_FRAGS * (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER))
linear = len - MAX_SKB_FRAGS * (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER);
+ if (unlikely(SKB_HEAD_ALIGN(prepad + linear) > KMALLOC_MAX_SIZE))
+ return ERR_PTR(-EMSGSIZE);
+
skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
&err, PAGE_ALLOC_COSTLY_ORDER);
if (!skb)
base-commit: 28a371228d4eb4857cc31eeb1a0d7d01e9c3ea2f
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH net] tun: reject oversized skb head allocations
2026-11-29 2:05 [PATCH net] tun: reject oversized skb head allocations Zhao Gongyi
@ 2026-11-29 2:08 ` netdev-bot+sinfo
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sinfo @ 2026-11-29 2:08 UTC (permalink / raw)
To: Zhao Gongyi
Cc: netdev, Willem de Bruijn, Jason Wang, Andrew Lunn,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Haishuang Yan, Narcisa Vasile, stable, linux-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-29 2:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-29 2:05 [PATCH net] tun: reject oversized skb head allocations Zhao Gongyi
2026-11-29 2:08 ` netdev-bot+sinfo
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®