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

From: David Hildenbrand (Arm)

Date: Thu Nov 19 2026 - 15:16:23 EST


On 11/19/26 21:05, Dave Hansen wrote:
> On 11/14/26 17:01, Andrew Morton wrote:
>> 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.
>
> This is a fun one.
>
> I almost wonder if we want to go one step further and disallow GUPs with
> FOLL_WRITE on these PTEs. There should be precious few reasons for
> devices to be writing to shadow stack pages.
>
> Isn't this a bigger issue than HMM? Should the fix be in HMM?

I think we discussed this excessively after I raised it and it's even partially
documented in the relevant commit messages.

--
Cheers,

David