Re: [PATCH mm-hotfixes] mm/vma: remove __vma_check_mmap_hook()
From: Andrew Morton
Date: Tue Apr 14 2026 - 01:17:46 EST
On Mon, 13 Apr 2026 11:57:13 +0100 Lorenzo Stoakes <ljs@xxxxxxxxxx> wrote:
> Commit c50ca15dd496 ("mm: add vm_ops->mapped hook") introduced
> __vma_check_mmap_hook() in order to assert that a driver doesn't
> incorrectly implement both an f_op->mmap() and a vm_ops->mapped hook, the
> latter of which would not ultimately get invoked.
>
> However, this did not correctly account for stacked drivers (or drivers
> that otherwise use the compatibility layer) which might recursively call
> an mmap_prepare hook via the compatibility layer.
>
> Thus the nested mmap_prepare() invocation might result in a VMA which has
> vm_ops->mapped set with an overlaying mmap() hook, causing the
> __vma_check_mmap_hook() to fail in vfs_mmap(), wrongly failing the
> operation.
>
> This patch resolves this by simply removing the check, as we can't be
> certain that an mmap() hook doesn't at some point invoke the compatibility
> layer, and it's not worth trying to track it.
Cool, thanks.
> Fixes: c50ca15dd496 ("mm: add vm_ops->mapped hook")
That's presently in flight mm.git->Linus, So I'll include this fix in
next week's second batch of MM updates into Linus.
> c50ca15dd496 is in mm-stable, so thought best to do as fix-patch? Will
> leave a small bisection hazard (unfortunately) so putting this as close as
> possible to the patch it fixes would be ideal.
Yep, I did that.