]> Gentwo Git Trees - linux/.git/commitdiff
net: page_pool: sanitise allocation order
authorPavel Begunkov <asml.silence@gmail.com>
Sun, 30 Nov 2025 23:35:17 +0000 (23:35 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 2 Dec 2025 19:08:39 +0000 (11:08 -0800)
We're going to give more control over rx buffer sizes to user space, and
since we can't always rely on driver validation, let's sanitise it in
page_pool_init() as well. Note that we only need to reject over
MAX_PAGE_ORDER allocations for normal page pools, as current memory
providers don't need to use the buddy allocator and must check the order
on init.i

Suggested-by: Stanislav Fomichev <stfomichev@gmail.com>
Reviewed-by: Mina Almasry <almasrymina@google.com>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://patch.msgid.link/77ad83c1aec66cbd00e7b3952f74bc3b7a988150.1764542851.git.asml.silence@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/page_pool.c

index a085fd199ff012ae6574df7d62186bb12e7205d4..265a729431bb7d719726a3eed81f709af2e24f9b 100644 (file)
@@ -301,6 +301,9 @@ static int page_pool_init(struct page_pool *pool,
                }
 
                static_branch_inc(&page_pool_mem_providers);
+       } else if (pool->p.order > MAX_PAGE_ORDER) {
+               err = -EINVAL;
+               goto free_ptr_ring;
        }
 
        return 0;