Thread (115 messages) 115 messages, 12 authors, 2023-03-01

Re: [PATCH v6 20/41] x86/mm: Teach pte_mkwrite() about stack memory

From: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
Date: 2023-02-20 22:52:38
Also in: linux-arch, linux-doc, linux-mm, lkml

On Sun, 2023-02-19 at 12:41 -0800, Kees Cook wrote:
On Sat, Feb 18, 2023 at 01:14:12PM -0800, Rick Edgecombe wrote:
quoted
If a VMA has the VM_SHADOW_STACK flag, it is shadow stack memory.
So
when it is made writable with pte_mkwrite(), it should create
shadow
stack memory, not conventionally writable memory. Now that
pte_mkwrite()
takes a VMA, and places where shadow stack memory might be created
pass
one, pte_mkwrite() can know when it should do this.

So make pte_mkwrite() create shadow stack memory when the VMA has
the
VM_SHADOW_STACK flag. Do the same thing for pmd_mkwrite().

This requires referencing VM_SHADOW_STACK in these functions, which
are
currently defined in pgtable.h, however mm.h (where VM_SHADOW_STACK
is
located) can't be pulled in without causing problems for files that
reference pgtable.h. So also move pte/pmd_mkwrite() into pgtable.c,
where
they can safely reference VM_SHADOW_STACK.

Tested-by: Pengfei Xu <redacted>
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Is there any realistic performance impact from making these not
inline
now?
Hmm, I can't say definitively. I would think in write protecting
operations, the big cost would not be the PTE setters. For mapping
things read-only from the beginning (user text, etc), I'm not sure. I
guess it gives the compiler less flexibility, but also gives it the
option to have one copy and so less text size overall for the kernel.

Are there any specific microbenchmarks we could run?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help