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: <66dac672-88f8-4101-9a66-382cd3794756@redhat.com>
Date: Wed, 27 Aug 2025 11:38:53 +0200
From: David Hildenbrand <david@...hat.com>
To: Max Kellermann <max.kellermann@...os.com>, akpm@...ux-foundation.org,
 lorenzo.stoakes@...cle.com, ziy@...dia.com, baolin.wang@...ux.alibaba.com,
 Liam.Howlett@...cle.com, npache@...hat.com, ryan.roberts@....com,
 dev.jain@....com, baohua@...nel.org, shikemeng@...weicloud.com,
 kasong@...cent.com, nphamcs@...il.com, bhe@...hat.com, chrisl@...nel.org,
 linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] mm/swap: add BUG_ON(folio==NULL) to folios_put_refs()

On 27.08.25 01:16, Max Kellermann wrote:
> It is not legal to have NULL pointers in a folio_batch.
> 
> However, the Ceph code does exactly this, and a refactoring patch gone
> wrong has exposed this to folios_put_refs(), see
> https://lore.kernel.org/ceph-devel/aK4v548CId5GIKG1@swift.blarg.de/
> 
> I believe this should Oops instead of crashing due to NULL pointer
> reference (guarded by is_huge_zero_folio(), which may silently hide
> the bug).
> 
> Signed-off-by: Max Kellermann <max.kellermann@...os.com>
> ---
>   mm/swap.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/mm/swap.c b/mm/swap.c
> index 3632dd061beb..07ccda00e7ee 100644
> --- a/mm/swap.c
> +++ b/mm/swap.c
> @@ -952,6 +952,7 @@ void folios_put_refs(struct folio_batch *folios, unsigned int *refs)
>   	for (i = 0, j = 0; i < folios->nr; i++) {
>   		struct folio *folio = folios->folios[i];
>   		unsigned int nr_refs = refs ? refs[i] : 1;
> +		BUG_ON(folio == NULL);

We shouldn't be adding such checks into each and every function that 
expects a valid folio.

The is_huge_zero_folio() is special because it does not crash 
immediately when the function is abused.

So we don't want this (and in particular not a BUG_ON).

-- 
Cheers

David / dhildenb


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ