[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZnmRGyuSZKtmJVhG@casper.infradead.org>
Date: Mon, 24 Jun 2024 16:30:35 +0100
From: Matthew Wilcox <willy@...radead.org>
To: David Howells <dhowells@...hat.com>
Cc: Christian Brauner <christian@...uner.io>,
Jeff Layton <jlayton@...nel.org>, netfs@...ts.linux.dev,
v9fs@...ts.linux.dev, linux-afs@...ts.infradead.org,
linux-cifs@...r.kernel.org, linux-mm@...ck.org,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] netfs: Fix netfs_page_mkwrite() to check folio->mapping
is valid
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.
Powered by blists - more mailing lists