net: page_pool: fix use-after-free in page_pool_recycle_ring_bulk()
Subsystems (3)
PATCH 1/1 net: page_pool: fix use-after-free in page_pool_recycle_ring_bulk()
With CONFIG_PAGE_POOL_STATS=y, page_pool_recycle_ring_bulk() updates the recycle stats after dropping the producer lock. If it just recycled the last inflight netmems of a pool being destroyed, page_pool_release() can pass its producer-lock barrier and free the pool before recycle_stat_add() runs.
Commit fcc680a647ba7 ("page_pool: allow mixing PPs within one bulk") moved this stat update after the unlock. Commit 271683bb2cf32 ("page_pool: Fix use-after-free in page_pool_recycle_in_ring") later added the barrier, but only fixed page_pool_recycle_in_ring(). Move the update back under the lock.
--- net/core/page_pool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/page_pool.c +1 -1
@@ -951,8 +951,8 @@ static void page_pool_recycle_ring_bulk(struct page_pool *pool, } } -page_pool_producer_unlock (pool, in_softirq);recycle_stat_add (pool, ring, i); +page_pool_producer_unlock (pool, in_softirq);/* Hopefully all pages were returned into ptr_ring */ if (likely (i == bulk_len))
base-commit: 11536ee3d3e0b1bd35b6f3f8df55a6053eb0c71d
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
Quoted 12 lines · Mina Almasry
With
CONFIG_PAGE_POOL_STATS=y,page_pool_recycle_ring_bulk()updates the recycle stats after dropping the producer lock. If it just recycled the last inflight netmems of a pool being destroyed,page_pool_release()can pass its producer-lock barrier and free the pool beforerecycle_stat_add()runs.Commit
fcc680a647ba7("page_pool: allow mixing PPs within one bulk") moved this stat update after the unlock. Commit271683bb2cf32("page_pool: Fix use-after-free inpage_pool_recycle_in_ring") later added the barrier, but only fixedpage_pool_recycle_in_ring(). Move the update back under the lock.
Quoted 6 lines
Fixes fcc680a647ba7 ("page_pool: allow mixing PPs within one bulk")Cc Kaifeng Wang <[email protected]>Cc Dong Chenchen <[email protected]>Assisted-by LLMSigned-off-by Mina Almasry <[email protected]>
Quoted 12 lines · Mina Almasry
With
CONFIG_PAGE_POOL_STATS=y,page_pool_recycle_ring_bulk()updates the recycle stats after dropping the producer lock. If it just recycled the last inflight netmems of a pool being destroyed,page_pool_release()can pass its producer-lock barrier and free the pool beforerecycle_stat_add()runs.Commit
fcc680a647ba7("page_pool: allow mixing PPs within one bulk") moved this stat update after the unlock. Commit271683bb2cf32("page_pool: Fix use-after-free inpage_pool_recycle_in_ring") later added the barrier, but only fixedpage_pool_recycle_in_ring(). Move the update back under the lock.
Quoted 6 lines
Fixes fcc680a647ba7 ("page_pool: allow mixing PPs within one bulk")Cc Kaifeng Wang <[email protected]>Cc Dong Chenchen <[email protected]>Assisted-by LLMSigned-off-by Mina Almasry <[email protected]>
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 6 lines · On Fri, 25 Sep 2026 14:41:11 +0000 you wrote:
With
CONFIG_PAGE_POOL_STATS=y,page_pool_recycle_ring_bulk()updates the recycle stats after dropping the producer lock. If it just recycled the last inflight netmems of a pool being destroyed,page_pool_release()can pass its producer-lock barrier and free the pool beforerecycle_stat_add()runs.
Quoted 7 lines
Commit
fcc680a647ba7("page_pool: allow mixing PPs within one bulk") moved this stat update after the unlock. Commit271683bb2cf32("page_pool: Fix use-after-free inpage_pool_recycle_in_ring") later added the barrier, but only fixedpage_pool_recycle_in_ring(). Move the update back under the lock.[...]
Here is the summary with links:
- [net,v1] net: page_pool: fix use-after-free in page_pool_recycle_ring_bulk()
https://git.kernel.org/netdev/net/c/bdea4980182e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html