lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <db996d5b-056e-4331-b141-11aede7d7dde@gmail.com>
Date: Sat, 12 Jul 2025 13:16:54 +0100
From: Pavel Begunkov <asml.silence@...il.com>
To: Byungchul Park <byungchul@...com>, Mina Almasry <almasrymina@...gle.com>
Cc: willy@...radead.org, netdev@...r.kernel.org,
 linux-kernel@...r.kernel.org, linux-mm@...ck.org, kernel_team@...ynix.com,
 kuba@...nel.org, ilias.apalodimas@...aro.org, harry.yoo@...cle.com,
 hawk@...nel.org, akpm@...ux-foundation.org, davem@...emloft.net,
 john.fastabend@...il.com, andrew+netdev@...n.ch, toke@...hat.com,
 tariqt@...dia.com, edumazet@...gle.com, pabeni@...hat.com,
 saeedm@...dia.com, leon@...nel.org, ast@...nel.org, daniel@...earbox.net,
 david@...hat.com, lorenzo.stoakes@...cle.com, Liam.Howlett@...cle.com,
 vbabka@...e.cz, rppt@...nel.org, surenb@...gle.com, mhocko@...e.com,
 horms@...nel.org, linux-rdma@...r.kernel.org, bpf@...r.kernel.org,
 vishal.moola@...il.com, hannes@...xchg.org, ziy@...dia.com,
 jackmanb@...gle.com
Subject: Re: [PATCH net-next v9 2/8] netmem: introduce utility APIs to use
 struct netmem_desc

On 7/11/25 02:02, Byungchul Park wrote:
> On Thu, Jul 10, 2025 at 11:11:51AM -0700, Mina Almasry wrote:
...>>> +#define nmdesc_to_page(nmdesc)         (_Generic((nmdesc),             \
>>> +       const struct netmem_desc * :    (const struct page *)(nmdesc),  \
>>> +       struct netmem_desc * :          (struct page *)(nmdesc)))
>>> +
>>> +static inline struct netmem_desc *page_to_nmdesc(struct page *page)
>>> +{
>>> +       VM_BUG_ON_PAGE(PageTail(page), page);
>>> +       return (struct netmem_desc *)page;
>>> +}
>>> +
>>
>> It's not safe to cast a page to netmem_desc, without first checking if
>> it's a pp page or not, otherwise you may be casting random non-pp
>> pages to netmem_desc...

I'd suggest to rename it to sth like pp_page_to_nmdesc() and add:

DEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(page));

...

> Agree, but page_to_nmdesc() will be used in page_pool_page_is_pp() to
> check if it's a pp page or not:
> 
>     static inline bool page_pool_page_is_pp(struct page *page)
>     {
> 	struct netmem_desc *desc = page_to_nmdesc(page);
> 
> 	return (desc->pp_magic & PP_MAGIC_MASK) == PP_SIGNATURE;
>     }
> 
> Hm.. maybe, it'd be better to resore the original code and remove this
> page_to_nmdesc() helper.  FYI, the original code was:
> 
>     static inline bool page_pool_page_is_pp(struct page *page)
>     {
> 	struct netmem_desc *desc = (struct netmem_desc *)page;
> 
> 	return (desc->pp_magic & PP_MAGIC_MASK) == PP_SIGNATURE;
>     }

... And use this version. It's supposed to be temporary anyway.
It'd be great to add a build check that the page still has space
to alias with for now.

-- 
Pavel Begunkov


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ