[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <lv74va34dbeyacenvdzulfudgsvntuu2u7jutpjjysfl42kkro@vvkzmctnilnp>
Date: Thu, 23 Oct 2025 11:35:06 +0100
From: Kiryl Shutsemau <kirill@...temov.name>
To: Dave Chinner <david@...morbit.com>, Jan Kara <jack@...e.cz>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
David Hildenbrand <david@...hat.com>, Hugh Dickins <hughd@...gle.com>,
Matthew Wilcox <willy@...radead.org>, Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>, Vlastimil Babka <vbabka@...e.cz>,
Mike Rapoport <rppt@...nel.org>, Suren Baghdasaryan <surenb@...gle.com>,
Michal Hocko <mhocko@...e.com>, Rik van Riel <riel@...riel.com>,
Harry Yoo <harry.yoo@...cle.com>, Johannes Weiner <hannes@...xchg.org>,
Shakeel Butt <shakeel.butt@...ux.dev>, Baolin Wang <baolin.wang@...ux.alibaba.com>,
"Darrick J. Wong" <djwong@...nel.org>, linux-mm@...ck.org, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [RFC, PATCH 0/2] Large folios vs. SIGBUS semantics
On Tue, Oct 21, 2025 at 07:16:33AM +0100, Kiryl Shutsemau wrote:
> On Tue, Oct 21, 2025 at 10:28:02AM +1100, Dave Chinner wrote:
> > In critical paths like truncate, correctness and safety come first.
> > Performance is only a secondary consideration. The overlap of
> > mmap() and truncate() is an area where we have had many, many bugs
> > and, at minimum, the current POSIX behaviour largely shields us from
> > serious stale data exposure events when those bugs (inevitably)
> > occur.
>
> How do you prevent writes via GUP racing with truncate()?
>
> Something like this:
>
> CPU0 CPU1
> fd = open("file")
> p = mmap(fd)
> whatever_syscall(p)
> get_user_pages(p, &page)
> truncate("file");
> <write to page>
> put_page(page);
>
> The GUP can pin a page in the middle of a large folio well beyond the
> truncation point. The folio will not be split on truncation due to the
> elevated pin.
>
> I don't think this issue can be fundamentally fixed as long as we allow
> GUP for file-backed memory.
>
> If the filesystem side cannot handle a non-zeroed tail of a large folio,
> this SIGBUS semantics only hides the issue instead of addressing it.
>
> And the race above does not seem to be far-fetched to me.
Any comments?
Jan, I remember you worked a lot on making GUP semantics sanish for file
pages. Any clues if I imagine a problem here?
--
Kiryl Shutsemau / Kirill A. Shutemov
Powered by blists - more mailing lists