Re: [PATCH v3 2/5] mm/mseal: update madvise() logic

From: David Hildenbrand
Date: Fri Jul 25 2025 - 06:15:09 EST


So - we explicitly disallow FOLL_FORCE write override for CoW file-backed
mappings.

Obviously if FOLL_FORCE is not set, then we're ALSO not allowed to get past a
FOLL_WRITE and !VM_WRITE situation.



Hmm maybe I'll soften on this anon_vma idea then. Maybe it is a 'cheap fix' to
rule out the _usual_ cases.

Yeah, something to evaluate.

I'm thinking more and more we're probably actually safe with !vma->anon_vma ||
!(vma->vm_flags & VM_MAYWRITE).

I think there are possible races, the question is how much you care about
them.

Yes I was just wrong. Please just disregard.

I mean racing with MADV_POPULATE_WRITE seems a niche thing to worry about, and
so what if you did, it's writing a... copy of the underlying file-backed folios
no?

MADV_POPULATE_WRITE does not apply. It's only racing with FOLL_FORCE, like debugger access.

Again, a race one probably shouldn't worry about in the context of mseal.

--
Cheers,

David / dhildenb