]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
arm64/kprobes: set VM_FLUSH_RESET_PERMS on kprobe instruction pages
authorArd Biesheuvel <ard.biesheuvel@arm.com>
Thu, 23 May 2019 10:22:55 +0000 (11:22 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Mon, 24 Jun 2019 17:10:39 +0000 (18:10 +0100)
In order to avoid transient inconsistencies where freed code pages
are remapped writable while stale TLB entries still exist on other
cores, mark the kprobes text pages with the VM_FLUSH_RESET_PERMS
attribute. This instructs the core vmalloc code not to defer the
TLB flush when this region is unmapped and returned to the page
allocator.

Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/probes/kprobes.c

index 88ce502c8e6f145431cb5971009641b079387f03..bd5dfffca272c69dc2ccd4d7aa9f0f61aab5ceaa 100644 (file)
@@ -122,8 +122,10 @@ void *alloc_insn_page(void)
        void *page;
 
        page = vmalloc_exec(PAGE_SIZE);
-       if (page)
+       if (page) {
                set_memory_ro((unsigned long)page, 1);
+               set_vm_flush_reset_perms(page);
+       }
 
        return page;
 }