]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: allow alloc_skb_with_frags() to use MAX_SKB_FRAGS
authorJason Baron <jbaron@akamai.com>
Mon, 22 Sep 2025 19:19:57 +0000 (15:19 -0400)
committerJakub Kicinski <kuba@kernel.org>
Tue, 23 Sep 2025 23:51:26 +0000 (16:51 -0700)
Currently, alloc_skb_with_frags() will only fill (MAX_SKB_FRAGS - 1)
slots. I think it should use all MAX_SKB_FRAGS slots, as callers of
alloc_skb_with_frags() will size their allocation of frags based
on MAX_SKB_FRAGS.

This issue was discovered via a test patch that sets 'order' to 0
in alloc_skb_with_frags(), which effectively tests/simulates high
fragmentation. In this case sendmsg() on unix sockets will fail every
time for large allocations. If the PAGE_SIZE is 4K, then data_len will
request 68K or 17 pages, but alloc_skb_with_frags() can only allocate
64K in this case or 16 pages.

Fixes: 09c2c90705bb ("net: allow alloc_skb_with_frags() to allocate bigger packets")
Signed-off-by: Jason Baron <jbaron@akamai.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20250922191957.2855612-1-jbaron@akamai.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/skbuff.c

index ee0274417948e0eb121792a400a0455884c92e56..1c0279b9cb9f48bf87dc625db9a894f4f6969424 100644 (file)
@@ -6667,7 +6667,7 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len,
                return NULL;
 
        while (data_len) {
-               if (nr_frags == MAX_SKB_FRAGS - 1)
+               if (nr_frags == MAX_SKB_FRAGS)
                        goto failure;
                while (order && PAGE_ALIGN(data_len) < (PAGE_SIZE << order))
                        order--;