[RFC v2 01/24] net: page_pool: sanitise allocation order
From: Pavel Begunkov
Date: Fri Aug 08 2025 - 10:53:57 EST
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.
Suggested-by: Stanislav Fomichev <stfomichev@xxxxxxxxx>
Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx>
---
net/core/page_pool.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 05e2e22a8f7c..f1373756cd0f 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -303,6 +303,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;
--
2.49.0