Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: "Gregory Price (Meta)" <gourry@gourry.net>,
	Jason Gunthorpe <jgg@nvidia.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	kernel-team@meta.com, leon@kernel.org, akpm@linux-foundation.org,
	kas@kernel.org, dave.hansen@linux.intel.com, bp@alien8.de,
	rppt@kernel.org, stable@vger.kernel.org,
	"Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Subject: Re: [PATCH] mm/hmm: reject shadow-stack mappings
Date: Sat, 14 Nov 2026 12:11:49 +0100	[thread overview]
Message-ID: <2fc85df3-cffc-4786-a7a8-0f0a6347fd59@kernel.org> (raw)
In-Reply-To: <179464112539.482102.8723246686117488051.b4-reply@b4>

On 11/14/26 08:25, Gregory Price (Meta) wrote:
> On 2026-11-13 20:20 -0400, Jason Gunthorpe wrote:
>> On Fri, Nov 13, 2026 at 03:41:33PM -0500, Gregory Price (Meta) wrote:
>>>
>>> Some of the context is here:
>>> https://lore.kernel.org/all/20261111-mason-migrate-et-al-fixes-v1-10-3d2454362e8d@kernel.org/
>>>
>>> We had a similar issue with migration, but this should handle the DMA
>>> case as well.
>>>
>>> It's "technically writable" but the kernel is supposed to prevent that.
>>
>> Bah, it's not writable at all. The CPU PTE has write disabled and
>> someone thought it was a good idea to make pte_write() return true
>> because the CPU allows writes through a special instruction on this
>> special PTE? So now all the places like this think its writable, when
>> it really isn't.
>>
> 
> I completely missed this, that will teach me to trust pte_write() I
> guess... what a bizarre design choice.  I'm sure there's "reasons".
> 
>> You could also fix this by having something like pte_real_write() or
>> whatever that doesn't lie about the write bit in the PTE :|
>>
> 
> or rename pte_write() to pte_fake_write() instead and restore
> pte_write() to its former truthful glory

It's writable by the hardware, that's what matters to core-mm, for example, when
it comes to things like fork(), mproetect() etc.

*nobody* besides selected core-mm code should ever write to random PTEs. They
shouldn't ever even care about pte_write().

We have GUP for that, which takes care of that oddity properly when deciding
whether we can *actually* write to a mapped page.

Well, and we have HMM that reimplements part of GUP in ugly ways (sorry) that we
missed.

-- 
Cheers,

David

      reply	other threads:[~2026-11-14 11:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 19:55 [PATCH] mm/hmm: reject shadow-stack mappings Gregory Price (Meta)
2026-11-13 19:57 ` Lorenzo Stoakes (ARM)
2026-11-13 20:15   ` Gregory Price (Meta)
2026-11-13 20:03 ` David Hildenbrand (Arm)
2026-11-13 20:42   ` Gregory Price (Meta)
2026-11-13 21:19     ` David Hildenbrand (Arm)
2026-11-13 20:03 ` Jason Gunthorpe
2026-11-13 20:41   ` Gregory Price (Meta)
2026-11-14  0:20     ` Jason Gunthorpe
2026-11-14  2:10       ` Andrew Morton
2026-11-14  7:25       ` Gregory Price (Meta)
2026-11-14 11:11         ` David Hildenbrand (Arm) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2fc85df3-cffc-4786-a7a8-0f0a6347fd59@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=gourry@gourry.net \
    --cc=jgg@nvidia.com \
    --cc=kas@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=rppt@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox