From: Matthew Wilcox <willy@infradead.org>
To: David Howells <dhowells@redhat.com>
Cc: Christian Brauner <christian@brauner.io>,
Jeff Layton <jlayton@kernel.org>,
netfs@lists.linux.dev, v9fs@lists.linux.dev,
linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] netfs: Fix netfs_page_mkwrite() to check folio->mapping is valid
Date: Mon, 24 Jun 2024 16:30:35 +0100 [thread overview]
Message-ID: <ZnmRGyuSZKtmJVhG@casper.infradead.org> (raw)
In-Reply-To: <614257.1719228181@warthog.procyon.org.uk>
On Mon, Jun 24, 2024 at 12:23:01PM +0100, David Howells wrote:
> @@ -508,6 +509,10 @@ vm_fault_t netfs_page_mkwrite(struct vm_fault *vmf, struct netfs_group *netfs_gr
>
> if (folio_lock_killable(folio) < 0)
> goto out;
> + if (folio->mapping != mapping) {
> + ret = VM_FAULT_NOPAGE | VM_FAULT_LOCKED;
> + goto out;
> + }
Have you tested this? I'd expect it to throw some VM assertions.
ret = vmf->vma->vm_ops->page_mkwrite(vmf);
/* Restore original flags so that caller is not surprised */
vmf->flags = old_flags;
if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))
return ret;
...
if (unlikely(!tmp || (tmp &
(VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) {
folio_put(folio);
return tmp;
}
So you locked the folio, then called folio_put() without unlocking it.
Usually the VM complains noisily if you free a locked folio.
next prev parent reply other threads:[~2024-06-24 15:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 11:23 [PATCH] netfs: Fix netfs_page_mkwrite() to check folio->mapping is valid David Howells
2024-06-24 15:30 ` Matthew Wilcox [this message]
2024-06-24 22:40 ` David Howells
2024-06-25 12:29 ` [PATCH v2] " David Howells
2024-06-25 14:54 ` Jeff Layton
2024-06-26 12:19 ` Christian Brauner
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=ZnmRGyuSZKtmJVhG@casper.infradead.org \
--to=willy@infradead.org \
--cc=christian@brauner.io \
--cc=dhowells@redhat.com \
--cc=jlayton@kernel.org \
--cc=linux-afs@lists.infradead.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=netfs@lists.linux.dev \
--cc=v9fs@lists.linux.dev \
/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;
as well as URLs for NNTP newsgroup(s).