[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7xukn5ime27nvcxxvmddmh7bqc5uoyd7ytrph2ubyhoushhp7x@tarta.nabijaczleweli.xyz>
Date: Sat, 6 Dec 2025 16:15:21 +0100
From:
Ahelenia Ziemiańska <nabijaczleweli@...ijaczleweli.xyz>
To: Matthew Wilcox <willy@...radead.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Hugh Dickins <hughd@...gle.com>, Baolin Wang <baolin.wang@...ux.alibaba.com>,
linux-fsdevel@...r.kernel.org, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tmpfs: enforce the immutable flag on open files
On Sat, Dec 06, 2025 at 12:52:37PM +0000, Matthew Wilcox wrote:
> On Sat, Dec 06, 2025 at 01:03:35PM +0100, Ahelenia Ziemiańska wrote:
> > diff --git a/mm/filemap.c b/mm/filemap.c
> > index ebd75684cb0a..0b0d5cfbcd44 100644
> > --- a/mm/filemap.c
> > +++ b/mm/filemap.c
> > @@ -3945,12 +3945,18 @@ EXPORT_SYMBOL(filemap_map_pages);
> >
> > vm_fault_t filemap_page_mkwrite(struct vm_fault *vmf)
> > {
> > - struct address_space *mapping = vmf->vma->vm_file->f_mapping;
> > + struct file *file = vmf->vma->vm_file;
> > + struct address_space *mapping = file->f_mapping;
> > struct folio *folio = page_folio(vmf->page);
> > vm_fault_t ret = VM_FAULT_LOCKED;
> >
> > + if (unlikely(IS_IMMUTABLE(file_inode(file)))) {
> > + ret = VM_FAULT_SIGBUS;
> > + goto out;
> I don't believe you tested this code path. It contains a rather obvious
> bug.
You're right, I tested this on ext4 twice and didn't realise;
this ought just be return VM_FAULT_SIGBUS;.
But even this doesn't work, because shmem{,_anon}_vm_ops
don't have a page_mkwrite callback at all,
much less it being filemap_page_mkwrite().
I'm not sure how I concluded that they do.
Adding a shmem_page_mkwrite() works for the mmap case.
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists