lkml.org 
[lkml]   [2021]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH 36/43] x86: kmsan: sync metadata pages on page fault
    From
    KMSAN assumes shadow and origin pages for every allocated page are
    accessible. For pages between [VMALLOC_START, VMALLOC_END] those metadata
    pages start at KMSAN_VMALLOC_SHADOW_START and
    KMSAN_VMALLOC_ORIGIN_START, therefore we must sync a bigger memory
    region.

    Signed-off-by: Alexander Potapenko <glider@google.com>

    ---

    Link: https://linux-review.googlesource.com/id/Ia5bd541e54f1ecc11b86666c3ec87c62ac0bdfb8
    ---
    arch/x86/mm/fault.c | 22 +++++++++++++++++++++-
    1 file changed, 21 insertions(+), 1 deletion(-)

    diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
    index 4bfed53e210ec..abed0aedf00d2 100644
    --- a/arch/x86/mm/fault.c
    +++ b/arch/x86/mm/fault.c
    @@ -260,7 +260,7 @@ static noinline int vmalloc_fault(unsigned long address)
    }
    NOKPROBE_SYMBOL(vmalloc_fault);

    -void arch_sync_kernel_mappings(unsigned long start, unsigned long end)
    +void __arch_sync_kernel_mappings(unsigned long start, unsigned long end)
    {
    unsigned long addr;

    @@ -284,6 +284,26 @@ void arch_sync_kernel_mappings(unsigned long start, unsigned long end)
    }
    }

    +void arch_sync_kernel_mappings(unsigned long start, unsigned long end)
    +{
    + __arch_sync_kernel_mappings(start, end);
    + /*
    + * KMSAN maintains two additional metadata page mappings for the
    + * [VMALLOC_START, VMALLOC_END) range. These mappings start at
    + * KMSAN_VMALLOC_SHADOW_START and KMSAN_VMALLOC_ORIGIN_START and
    + * have to be synced together with the vmalloc memory mapping.
    + */
    + if (IS_ENABLED(CONFIG_KMSAN) &&
    + start >= VMALLOC_START && end < VMALLOC_END) {
    + __arch_sync_kernel_mappings(
    + start - VMALLOC_START + KMSAN_VMALLOC_SHADOW_START,
    + end - VMALLOC_START + KMSAN_VMALLOC_SHADOW_START);
    + __arch_sync_kernel_mappings(
    + start - VMALLOC_START + KMSAN_VMALLOC_ORIGIN_START,
    + end - VMALLOC_START + KMSAN_VMALLOC_ORIGIN_START);
    + }
    +}
    +
    static bool low_pfn(unsigned long pfn)
    {
    return pfn < max_low_pfn;
    --
    2.34.1.173.g76aa8bc2d0-goog
    \
     
     \ /
      Last update: 2021-12-14 17:25    [W:4.075 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site