linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Ahelenia Ziemiańska" <nabijaczleweli@nabijaczleweli.xyz>
To: Matthew Wilcox <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Hugh Dickins <hughd@google.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	 linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tmpfs: enforce the immutable flag on open files
Date: Sat, 6 Dec 2025 16:15:21 +0100	[thread overview]
Message-ID: <7xukn5ime27nvcxxvmddmh7bqc5uoyd7ytrph2ubyhoushhp7x@tarta.nabijaczleweli.xyz> (raw)
In-Reply-To: <aTQnFQIc3ylSci1u@casper.infradead.org>

[-- Attachment #1: Type: text/plain, Size: 1234 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2025-12-06 15:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-06 12:03 Ahelenia Ziemiańska
2025-12-06 12:52 ` Matthew Wilcox
2025-12-06 15:15   ` Ahelenia Ziemiańska [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7xukn5ime27nvcxxvmddmh7bqc5uoyd7ytrph2ubyhoushhp7x@tarta.nabijaczleweli.xyz \
    --to=nabijaczleweli@nabijaczleweli.xyz \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=hughd@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox