[PATCH net-next v6 0/8] fix two bugs related to page_pool
Yunsheng Lin
linyunsheng at huawei.com
Tue Jan 7 04:54:37 PST 2025
On 2025/1/7 7:51, Jakub Kicinski wrote:
> On Mon, 6 Jan 2025 21:01:08 +0800 Yunsheng Lin wrote:
>> This patchset fix a possible time window problem for page_pool and
>> the dma API misuse problem as mentioned in [1], and try to avoid the
>> overhead of the fixing using some optimization.
>>
>> From the below performance data, the overhead is not so obvious
>> due to performance variations for time_bench_page_pool01_fast_path()
>> and time_bench_page_pool02_ptr_ring, and there is about 20ns overhead
>> for time_bench_page_pool03_slow() for fixing the bug.
>
> This appears to make the selftest from the drivers/net target implode.
>
> [ 20.227775][ T218] BUG: KASAN: use-after-free in page_pool_item_uninit+0x100/0x130
>
> Running the ping.py tests should be enough to repro.
Thanks for reminding.
Something like below seems to fix the use-after-free bug, will enable more
DEBUG config when doing testing.
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -518,9 +518,13 @@ static void page_pool_items_unmap(struct page_pool *pool)
static void page_pool_item_uninit(struct page_pool *pool)
{
- struct page_pool_item_block *block;
+ while (!list_empty(&pool->item_blocks)) {
+ struct page_pool_item_block *block;
- list_for_each_entry(block, &pool->item_blocks, list) {
+ block = list_first_entry(&pool->item_blocks,
+ struct page_pool_item_block,
+ list);
+ list_del(&block->list);
WARN_ON(refcount_read(&block->ref));
put_page(virt_to_page(block));
}
More information about the linux-arm-kernel
mailing list