[PATCH mm-hotfixes-unstable] mm: Pass page directly instead of using folio_page

Lorenzo Stoakes lorenzo.stoakes at oracle.com
Wed Aug 6 10:23:30 PDT 2025


On Wed, Aug 06, 2025 at 10:49:46PM +0530, Dev Jain wrote:
>
> On 06/08/25 10:10 pm, Lorenzo Stoakes wrote:
> > On Wed, Aug 06, 2025 at 08:26:11PM +0530, Dev Jain wrote:
> > > In commit_anon_folio_batch(), we iterate over all pages pointed to by the
> > > PTE batch. Therefore we need to know the first page of the batch;
> > > currently we derive that via folio_page(folio, 0), but, that takes us
> > > to the first (head) page of the folio instead - our PTE batch may lie
> > > in the middle of the folio, leading to incorrectness.
> > >
> > > Bite the bullet and throw away the micro-optimization of reusing the
> > > folio in favour of code simplicity. Derive the page and the folio in
> > > change_pte_range, and pass the page too to commit_anon_folio_batch to
> > > fix the aforementioned issue.
> > >
> > > Reported-by: syzbot+57bcc752f0df8bb1365c at syzkaller.appspotmail.com
> > > Fixes: cac1db8c3aad ("mm: optimize mprotect() by PTE batching")
> > > Signed-off-by: Dev Jain <dev.jain at arm.com>
> > This looks reasonable, fixes the problem and compiles/works on my machine so:
> >
> > Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes at oracle.com>
>
> Thanks.
>
> >
> > This badly needs refactoring as 13 parameters being passed to a function is
>
> Which function are you talking about?

Misread, 9, but it's still silly. mprotect in general needs rework. I may submit
a patch for this at some point...

Anyway let's just get this hotfix in asap.

>
> > ridiculous, but we can do that later.
> >
> > Let's get this in as a hotfix asap.



More information about the linux-arm-kernel mailing list