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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b677e859-abad-46b7-8dce-59152d29ea59@redhat.com>
Date: Thu, 4 Sep 2025 08:33:26 +0200
From: David Hildenbrand <david@...hat.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
 Stephen Rothwell <sfr@...b.auug.org.au>
Cc: Max Kellermann <max.kellermann@...os.com>,
 Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
 Linux Next Mailing List <linux-next@...r.kernel.org>,
 Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
 Vlastimil Babka <vbabka@...e.cz>, Mike Rapoport <rppt@...nel.org>,
 Matthew Wilcox <willy@...radead.org>
Subject: Re: linux-next: build warning after merge of the mm-unstable tree

On 04.09.25 04:59, Andrew Morton wrote:
> On Thu, 4 Sep 2025 12:14:38 +1000 Stephen Rothwell <sfr@...b.auug.org.au> wrote:
> 
>> After merging the mm-unstable tree, today's linux-next build (arm
>> multi_v7_defconfig) produced this warning:
>>
>> In file included from include/linux/highmem.h:14,
>>                   from include/linux/bvec.h:10,
>>                   from include/linux/blk_types.h:10,
>>                   from include/linux/writeback.h:13,
>>                   from include/linux/memcontrol.h:23,
>>                   from include/linux/swap.h:9,
>>                   from include/linux/suspend.h:5,
>>                   from arch/arm/mach-highbank/pm.c:9:
>> include/linux/highmem-internal.h: In function 'kmap_local_folio':
>> include/linux/highmem-internal.h:86:46: warning: passing argument 1 of 'folio_page' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
>>     86 |         const struct page *page = folio_page(folio, offset / PAGE_SIZE);
>>        |                                              ^~~~~
>> In file included from include/linux/mmzone.h:23,
>>                   from include/linux/swap.h:7:
>> include/linux/page-flags.h:319:53: note: expected 'struct folio *' but argument is of type 'const struct folio *'
>>    319 | static inline struct page *folio_page(struct folio *folio, unsigned long n)
> 

Hm, why did we not detect that in mm-new?
> 
> Yeah, thanks, folio_page() is a problem.  I'll do the below nasty for
> now, but nasty.
> 
> --- a/include/linux/page-flags.h~mm-constify-highmem-related-functions-for-improved-const-correctness-fix
> +++ a/include/linux/page-flags.h
> @@ -316,9 +316,9 @@ static __always_inline unsigned long _co
>    * check that the page number lies within @folio; the caller is presumed
>    * to have a reference to the page.
>    */
> -static inline struct page *folio_page(struct folio *folio, unsigned long n)
> +static inline struct page *folio_page(const struct folio *folio, unsigned long n)
>   {
> -	return &folio->page + n;
> +	return (struct page *)(&folio->page + n);
>   }
>   
>   static __always_inline int PageTail(const struct page *page)
> _

I think the problem  appears when nth_page() removal is paired with const-correctness.


Not a fan of going back to a plain macro either. Likely we can handle it similar to page_folio() and
perform the cast cleanly:


diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index faf17ca211b4f..dc67fe08e77c8 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -307,6 +307,12 @@ static __always_inline unsigned long _compound_head(const struct page *page)
         const struct page *:    (const struct folio *)_compound_head(p), \
         struct page *:          (struct folio *)_compound_head(p)))
  
+static inline const struct page *_folio_page(const struct folio *folio,
+               unsigned long n)
+{
+       return &folio->page + n;
+}
+
  /**
   * folio_page - Return a page from a folio.
   * @folio: The folio.
@@ -316,10 +322,9 @@ static __always_inline unsigned long _compound_head(const struct page *page)
   * check that the page number lies within @folio; the caller is presumed
   * to have a reference to the page.
   */
-static inline struct page *folio_page(struct folio *folio, unsigned long n)
-{
-       return &folio->page + n;
-}
+#define folio_page(f, p)       (_Generic((f),                          \
+       const struct folio *:   (const struct page *)_folio_page(f, p), \
+       struct folio *:         (struct page *)_folio_page(f, p)))
  
  static __always_inline int PageTail(const struct page *page)
  {


-- 
Cheers

David / dhildenb


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ