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: <aA7PbiXv92WiTy8T@casper.infradead.org>
Date: Mon, 28 Apr 2025 01:44:30 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Kairui Song <kasong@...cent.com>
Cc: linux-mm@...ck.org, Andrew Morton <akpm@...ux-foundation.org>,
	David Hildenbrand <david@...hat.com>,
	Hugh Dickins <hughd@...gle.com>, Chris Li <chrisl@...nel.org>,
	Yosry Ahmed <yosryahmed@...gle.com>,
	"Huang, Ying" <ying.huang@...ux.alibaba.com>,
	Nhat Pham <nphamcs@...il.com>, Johannes Weiner <hannes@...xchg.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/6] filemap: do not use folio_contains for swap cache
 folios

On Mon, Apr 28, 2025 at 02:59:06AM +0800, Kairui Song wrote:
> For filemap and truncate, folio_contains is only used for sanity checks
> to verify the folio index matches the expected lookup/invalidation target.
> The swap cache does not utilize filemap or truncate helpers in ways that
> would trigger these checks, as it mostly implements its own cache management.
> 
> Shmem won't interact with these sanity checks either unless thing went
> wrong, it would directly trigger a BUG, because swap cache index are
> unrelated to shmem index, and would almost certainly mismatch (unless
> on collide).

It does happen though.  If shmem is writing the folio to swap at the
same time that the file containing the folio is being truncated, we
can hit this.

> - * Context: The caller should have the page locked in order to prevent
> - * (eg) shmem from moving the page between the page cache and swap cache
> - * and changing its index in the middle of the operation.
> + * Context: The caller should ensure folio->index is stable and it's
> + * not added to the swap cache.

I do think we need to keep the part about the folio being locked.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ