lkml.org 
[lkml]   [2023]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v7 27/41] x86/mm: Warn if create Write=0,Dirty=1 with raw prot
On February 27, 2023 2:29:43 PM PST, Rick Edgecombe <rick.p.edgecombe@intel.com> wrote:
>When user shadow stack is use, Write=0,Dirty=1 is treated by the CPU as
>shadow stack memory. So for shadow stack memory this bit combination is
>valid, but when Dirty=1,Write=1 (conventionally writable) memory is being
>write protected, the kernel has been taught to transition the Dirty=1
>bit to SavedDirty=1, to avoid inadvertently creating shadow stack
>memory. It does this inside pte_wrprotect() because it knows the PTE is
>not intended to be a writable shadow stack entry, it is supposed to be
>write protected.
>
>However, when a PTE is created by a raw prot using mk_pte(), mk_pte()
>can't know whether to adjust Dirty=1 to SavedDirty=1. It can't
>distinguish between the caller intending to create a shadow stack PTE or
>needing the SavedDirty shift.
>
>The kernel has been updated to not do this, and so Write=0,Dirty=1
>memory should only be created by the pte_mkfoo() helpers. Add a warning
>to make sure no new mk_pte() start doing this.
>
>Tested-by: Pengfei Xu <pengfei.xu@intel.com>
>Tested-by: John Allen <john.allen@amd.com>
>Tested-by: Kees Cook <keescook@chromium.org>
>Acked-by: Mike Rapoport (IBM) <rppt@kernel.org>
>Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>

Reviewed-by: Kees Cook <keescook@chromium.org>


--
Kees Cook

\
 
 \ /
  Last update: 2023-03-27 00:37    [W:0.315 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site