Re: [PATCH] mm/hmm: reject shadow-stack mappings

From: Andrew Morton

Date: Sat Nov 14 2026 - 20:01:45 EST


On Sat, 14 Nov 2026 20:00:05 -0400 Jason Gunthorpe <jgg@xxxxxxxxxx> wrote:

> On Fri, Nov 13, 2026 at 06:10:25PM -0800, Andrew Morton wrote:
>
> > How does this look for an altered changelog?
> >
> > : On x86, a shadow-stack PTE has its ordinary write bit clear. The CPU
> > : rejects ordinary stores to it, but pte_write() reports it writable because
> > : shadow-stack instructions can write it. HMM consequently sets
> > : HMM_PFN_WRITE, which Nouveau turns into ordinary GPU write permission. A
> > : process with GPU access can then overwrite its own shadow stack,
> > : potentially corrupting return addresses or bypassing that protection.
> > :
> > : Reject shadow-stack VMAs in hmm_vma_walk_test(), including read access. A
> > : requested fault returns -EFAULT; a snapshot records HMM_PFN_ERROR.
>
> Yes, but it is not just nouveau, RDMA user can do this too and
> that is far more common..

Thanks. This?

On x86, a shadow-stack PTE has its ordinary write bit clear. The CPU
rejects ordinary stores, but pte_write() reports it writable because
shadow-stack instructions can write it. HMM consequently sets
HMM_PFN_WRITE. Nouveau uses that flag for GPU write permission, and
RDMA on-demand paging can use it to grant device write permission to a
registered memory region. A device, or an RDMA peer with write access
to that region, can then overwrite the process's shadow stack,
potentially corrupting return addresses or bypassing that protection.

Reject shadow-stack VMAs in hmm_vma_walk_test(), including read access.
A requested fault returns -EFAULT; a snapshot records HMM_PFN_ERROR.