Re: [PATCH] netfs: Fix netfs_page_mkwrite() to check folio->mapping is valid

From: David Howells
Date: Mon Jun 24 2024 - 18:40:56 EST


Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:

> > 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've tried to. generic/247 can trigger it, but the race happens rarely.

> I'd expect it to throw some VM assertions.

I didn't see any.

I guess VM_FAULT_LOCKED is not universally handled by the caller and that I
should unlock the folio myself instead.

David