[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2c4a2655-2e0d-4c16-82e6-2d9d33d5a276@huawei.com>
Date: Mon, 26 May 2025 22:27:10 +0800
From: "dongchenchen (A)" <dongchenchen2@...wei.com>
To: Yunsheng Lin <linyunsheng@...wei.com>, <hawk@...nel.org>,
<ilias.apalodimas@...aro.org>, <davem@...emloft.net>, <edumazet@...gle.com>,
<kuba@...nel.org>, <pabeni@...hat.com>, <horms@...nel.org>,
<almasrymina@...gle.com>
CC: <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<zhangchangzhong@...wei.com>,
<syzbot+204a4382fcb3311f3858@...kaller.appspotmail.com>
Subject: Re: [PATCH net] page_pool: Fix use-after-free in
page_pool_recycle_in_ring
> On 2025/5/23 14:45, Dong Chenchen wrote:
>
>>
>> static bool page_pool_recycle_in_ring(struct page_pool *pool, netmem_ref netmem)
>> {
>> + bool in_softirq;
>> int ret;
> int -> bool?
Thanks for your review!
v2 will fix it.
>> /* BH protection not needed if current is softirq */
>> - if (in_softirq())
>> - ret = ptr_ring_produce(&pool->ring, (__force void *)netmem);
>> - else
>> - ret = ptr_ring_produce_bh(&pool->ring, (__force void *)netmem);
>> -
>> - if (!ret) {
>> + in_softirq = page_pool_producer_lock(pool);
>> + ret = !__ptr_ring_produce(&pool->ring, (__force void *)netmem);
>> + if (ret)
>> recycle_stat_inc(pool, ring);
>> - return true;
>> - }
>> + page_pool_producer_unlock(pool, in_softirq);
>>
>> - return false;
>> + return ret;
>> }
>>
>> /* Only allow direct recycling in special circumstances, into the
>> @@ -1091,10 +1088,14 @@ static void page_pool_scrub(struct page_pool *pool)
>>
>> static int page_pool_release(struct page_pool *pool)
>> {
>> + bool in_softirq;
>> int inflight;
>>
>> page_pool_scrub(pool);
>> inflight = page_pool_inflight(pool, true);
>> + /* Acquire producer lock to make sure producers have exited. */
>> + in_softirq = page_pool_producer_lock(pool);
>> + page_pool_producer_unlock(pool, in_softirq);
> Is a compiler barrier needed to ensure compiler doesn't optimize away
> the above code?
All the code logic of this function accesses the pool. Do we need to
add a compiler barrier for it?
Best Regards,
Dong Chenchen
>> if (!inflight)
>> __page_pool_destroy(pool);
>>
Powered by blists - more mailing lists