* [PATCH net v1] net: page_pool: fix use-after-free in page_pool_recycle_ring_bulk()
@ 2026-09-25 14:41 Mina Almasry
2026-09-26 17:00 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Mina Almasry @ 2026-09-25 14:41 UTC (permalink / raw)
To: Alexander Lobakin, Jakub Kicinski,
Toke Høiland-Jørgensen, netdev, linux-kernel
Cc: Mina Almasry, Jesper Dangaard Brouer, Ilias Apalodimas,
David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman,
Kaifeng Wang, Dong Chenchen
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.
Fixes: fcc680a647ba7 ("page_pool: allow mixing PPs within one bulk")
Link: https://lore.kernel.org/r/179028939171.2160803.706522228583664641@kernel.org
Cc: Kaifeng Wang <kaifengw@google.com>
Cc: Dong Chenchen <dongchenchen2@huawei.com>
Assisted-by: LLM
Signed-off-by: Mina Almasry <almasrymina@google.com>
---
net/core/page_pool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 08d7f35cf6089..d7c88c0b67e53 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -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
--
2.56.0.rc1.315.gc6ed9934b7-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH net v1] net: page_pool: fix use-after-free in page_pool_recycle_ring_bulk()
2026-09-25 14:41 [PATCH net v1] net: page_pool: fix use-after-free in page_pool_recycle_ring_bulk() Mina Almasry
@ 2026-09-26 17:00 ` Simon Horman
0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2026-09-26 17:00 UTC (permalink / raw)
To: Mina Almasry
Cc: Alexander Lobakin, Jakub Kicinski,
Toke Høiland-Jørgensen, netdev, linux-kernel,
Jesper Dangaard Brouer, Ilias Apalodimas, David S. Miller,
Eric Dumazet, Paolo Abeni, Kaifeng Wang, Dong Chenchen
On Fri, Sep 25, 2026 at 02:41:11PM +0000, Mina Almasry 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 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.
>
> Fixes: fcc680a647ba7 ("page_pool: allow mixing PPs within one bulk")
> Link: https://lore.kernel.org/r/179028939171.2160803.706522228583664641@kernel.org
> Cc: Kaifeng Wang <kaifengw@google.com>
> Cc: Dong Chenchen <dongchenchen2@huawei.com>
> Assisted-by: LLM
> Signed-off-by: Mina Almasry <almasrymina@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-26 17:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25 14:41 [PATCH net v1] net: page_pool: fix use-after-free in page_pool_recycle_ring_bulk() Mina Almasry
2026-09-26 17:00 ` Simon Horman
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®