[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <57e2e227-e464-bd7f-f69e-573a772cd4c5@google.com>
Date: Tue, 9 Dec 2025 21:59:16 -0800 (PST)
From: Hugh Dickins <hughd@...gle.com>
To: Ahelenia Ziemiańska <nabijaczleweli@...ijaczleweli.xyz>
cc: Hugh Dickins <hughd@...gle.com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Matthew Wilcox <willy@...radead.org>,
Christian Brauner <brauner@...nel.org>, Theodore Ts'o <tytso@....edu>,
linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] tmpfs: enforce the immutable flag on open files
On Tue, 9 Dec 2025, Ahelenia Ziemiańska wrote:
> On Mon, Dec 08, 2025 at 08:14:44PM -0800, Hugh Dickins wrote:
> > On Mon, 8 Dec 2025, Ahelenia Ziemiańska wrote:
> > > This useful behaviour is implemented for most filesystems,
> > > and wants to be implemented for every filesystem, quoth ref:
> > > There is general agreement that we should standardize all file systems
> > > to prevent modifications even for files that were opened at the time
> > > the immutable flag is set. Eventually, a change to enforce this at
> > > the VFS layer should be landing in mainline.
> > >
> > > References: commit 02b016ca7f99 ("ext4: enforce the immutable flag on
> > > open files")
> > > Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@...ijaczleweli.xyz>
> > Sorry: thanks, but no thanks.
> >
> > Supporting page_mkwrite() comes at a cost (an additional fault on first
> > write to a folio in a shared mmap). It's important for space allocation
> > (and more) in the case of persistent writeback filesystems, but unwelcome
> > overhead in the case of tmpfs (and ramfs and hugetlbfs - others?).
>
> Yeah, from the way page_mkwrite() was implemented it looked like
> enough of a pessimisation to be significant, and with how common
> an operation this is, I kinda expected this result.
>
> (I was also gonna post the same for ramfs,
> but it doesn't support FS_IOC_SETFLAGS attributes at all.)
>
> > tmpfs has always preferred not to support page_mkwrite(), and just fail
> > fstests generic/080: we shall not slow down to change that, without a
> > much stronger justification than "useful behaviour" which we've got
> > along well enough without.
>
> How do we feel about just the VFS half of this,
> i.e. open(WR)/chattr +i/write() = -EPERM?
> That shouldn't have a performance impact.
I don't think tmpfs should implement half of the ext4 behaviour (at
write time) and not the other half (at page_mkwrite time): it would
leave IMMUTABLE on tmpfs as neither guaranteeing immutabiity, nor
behaving in the way IMMUTABLE was traditionally supported.
I do think it's surprisingly asymmetic, that IMMUTABLE should forbid
opening for write, but holding open for write should not forbid
setting IMMUTABLE. But that's the traditional behaviour, which
surprised you, and which those ext4 mods improve upon for ext4.
But I couldn't find any filesystem other than ext4 and f2fs
implementing it that way. If the VFS and other filesystems agreed
to implement the stricter IMMUTABLE (I imagine relying on i_writecount),
then tmpfs would probably be glad to participate; but not go its own way.
Hugh
Powered by blists - more mailing lists