arm64: wire up VM_FLUSH_RESET_PERMS
Subsystems (5)
cover arm64: wire up VM_FLUSH_RESET_PERMS
Wire up the code introduced in v5.2 to manage the permissions of executable vmalloc regions (and their linear aliases) more strictly.
One of the things that came up in the internal discussion is whether non-x86 architectures have any benefit at all from the lazy vunmap feature, and whether it would perhaps be better to implement eager vunmap instead.
Ard Biesheuvel (4):
arm64: module: create module allocations without exec permissions arm64/mm: wire up CONFIG_ARCH_HAS_SET_DIRECT_MAP arm64/kprobes: set VM_FLUSH_RESET_PERMS on kprobe instruction pages
arm64: bpf: do not allocate executable memory
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cacheflush.h | 3 ++ arch/arm64/kernel/module.c | 4 +- arch/arm64/kernel/probes/kprobes.c | 4 +- arch/arm64/mm/pageattr.c | 48 ++++++++++++++++---- arch/arm64/net/bpf_jit_comp.c | 2 +- mm/vmalloc.c | 11 ----- 7 files changed, 50 insertions(+), 23 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/4 arm64: module: create module allocations without exec permissions
Now that the core code manages the executable permissions of code regions of modules explicitly, it is no longer necessary to create the module vmalloc regions with RWX permissions, and we can create them with RW- permissions instead, which is preferred from a security perspective.
--- arch/arm64/kernel/module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/module.c +2 -2
@@ -41,7 +41,7 @@ void *module_alloc(unsigned long size) p =__vmalloc_node_range (size,MODULE_ALIGN , module_alloc_base, module_alloc_base +MODULES_VSIZE , - gfp_mask,PAGE_KERNEL_EXEC ,0 , + gfp_mask,PAGE_KERNEL ,0 ,NUMA_NO_NODE ,__builtin_return_address (0 )); if (!p && IS_ENABLED(CONFIG_ARM64_MODULE_PLTS) &&
@@ -57,7 +57,7 @@ void *module_alloc(unsigned long size)*/ p =__vmalloc_node_range (size,MODULE_ALIGN , module_alloc_base, module_alloc_base +SZ_4G ,GFP_KERNEL , -PAGE_KERNEL_EXEC ,0 ,NUMA_NO_NODE , +PAGE_KERNEL ,0 ,NUMA_NO_NODE ,__builtin_return_address (0 ));if (p && (kasan_module_alloc (p, size) <0 )) {
Signature · 1 line
2.17.1
Re: [PATCH 1/4] arm64: module: create module allocations without exec permissions
Quoted 2 lines · Ard Biesheuvel
Now that the core code manages the executable permissions of code regions of modules explicitly, it is no longer necessary to create
I guess the permission transition for various module sections happen through module_enable_[ro|nx]() after allocating via module_alloc().
Quoted 3 lines
the module vmalloc regions with RWX permissions, and we can create them with RW- permissions instead, which is preferred from a security perspective.
Makes sense. Will this be followed in all architectures now ?
Quoted 21 lines
Signed-off-by Ard Biesheuvel <[email protected]>--- arch/arm64/kernel/module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm64/kernel/module.c +1
-1@@ -41,7 +41,7 @@ void *module_alloc(unsigned long size) p =__vmalloc_node_range (size,MODULE_ALIGN , module_alloc_base, module_alloc_base +MODULES_VSIZE , - gfp_mask,PAGE_KERNEL_EXEC ,0 , + gfp_mask,PAGE_KERNEL ,0 ,NUMA_NO_NODE ,__builtin_return_address (0 )); if (!p && IS_ENABLED(CONFIG_ARM64_MODULE_PLTS) &&
arch/arm64/kernel/module.c void *module_alloc(unsigned long size) · line 63
Quoted 8 lines
arch/arm64/kernel/module.c +1
-1@@ -57,7 +57,7 @@ void *module_alloc(unsigned long size)*/ p =__vmalloc_node_range (size,MODULE_ALIGN , module_alloc_base, module_alloc_base +SZ_4G ,GFP_KERNEL , -PAGE_KERNEL_EXEC ,0 ,NUMA_NO_NODE , +PAGE_KERNEL ,0 ,NUMA_NO_NODE ,__builtin_return_address (0 ));if (p && (kasan_module_alloc (p, size) <0 )) {
Which just makes sure that PTE_PXN never gets dropped while creating these mappings.
Re: [PATCH 1/4] arm64: module: create module allocations without exec permissions
Quoted 9 lines · Anshuman Khandual
Quoted 2 lines · Ard Biesheuvel
Now that the core code manages the executable permissions of code regions of modules explicitly, it is no longer necessary to create
I guess the permission transition for various module sections happen through module_enable_[ro|nx]() after allocating via
module_alloc().
Indeed.
Quoted 6 lines
Quoted 3 lines
the module vmalloc regions with RWX permissions, and we can create them with RW- permissions instead, which is preferred from a security perspective.
Makes sense. Will this be followed in all architectures now ?
I am not sure if every architecture implements module_enable_[ro|nx](), but if they do, they should probably apply this change as well.
Quoted 27 lines
Quoted 27 lines
Signed-off-by Ard Biesheuvel <[email protected]>--- arch/arm64/kernel/module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm64/kernel/module.c +2
-2@@ -41,7 +41,7 @@ void *module_alloc(unsigned long size) p =__vmalloc_node_range (size,MODULE_ALIGN , module_alloc_base, module_alloc_base +MODULES_VSIZE , - gfp_mask,PAGE_KERNEL_EXEC ,0 , + gfp_mask,PAGE_KERNEL ,0 ,NUMA_NO_NODE ,__builtin_return_address (0 )); if (!p && IS_ENABLED(CONFIG_ARM64_MODULE_PLTS) &&@@ -57,7 +57,7 @@ void *module_alloc(unsigned long size)*/ p =__vmalloc_node_range (size,MODULE_ALIGN , module_alloc_base, module_alloc_base +SZ_4G ,GFP_KERNEL , -PAGE_KERNEL_EXEC ,0 ,NUMA_NO_NODE , +PAGE_KERNEL ,0 ,NUMA_NO_NODE ,__builtin_return_address (0 ));
Quoted 6 lines
arch/arm64/kernel/module.c void *module_alloc(unsigned long size) · line 63
Quoted 2 lines
arch/arm64/kernel/module.c +0
-0if (p && (kasan_module_alloc (p, size) <0 )) {Which just makes sure that
PTE_PXNnever gets dropped while creating these mappings.
Not sure what you mean. Is there a question here?
PATCH 2/4 arm64/mm: wire up CONFIG_ARCH_HAS_SET_DIRECT_MAP
In reply to Ard BiesheuvelWire up the special helper functions to manipulate aliases of vmalloc regions in the linear map.
--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cacheflush.h | 3 ++ arch/arm64/mm/pageattr.c | 48 ++++++++++++++++---- mm/vmalloc.c | 11 ----- 4 files changed, 44 insertions(+), 19 deletions(-)
arch/arm64/Kconfig +1 -0
@@ -26,6 +26,7 @@ config ARM64 select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SETUP_DMA_OPS + select ARCH_HAS_SET_DIRECT_MAP select ARCH_HAS_SET_MEMORY select ARCH_HAS_STRICT_KERNEL_RWX select ARCH_HAS_STRICT_MODULE_RWX
arch/arm64/include/asm/cacheflush.h +3 -0
@@ -187,4 +187,7 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end)int set_memory_valid (unsigned long addr,int numpages,int enable); +int set_direct_map_invalid_noflush (struct page *page); +int set_direct_map_default_noflush (struct page *page); +#endif
arch/arm64/mm/pageattr.c +40 -8
68 lines not on this page · raw message
mm/vmalloc.c +0 -11
@@ -2128,17 +2128,6 @@ static void vm_remove_mappings(struct vm_struct *area, int deallocate_pages)int flush_reset = area->flags &VM_FLUSH_RESET_PERMS ;int i; -/* -* The below block can be removed when all architectures that have -* direct map permissions also have set_direct_map_() implementations. -* This is concerned with resetting the direct map any an vm alias with -* execute permissions, without leaving a RW+X window. -*/ -if (flush_reset && !IS_ENABLED (CONFIG_ARCH_HAS_SET_DIRECT_MAP )) { -set_memory_nx (addr, area->nr_pages); -set_memory_rw (addr, area->nr_pages); - } -remove_vm_area (area->addr);/* If this is not VM_FLUSH_RESET_PERMS memory, no need for the below. */
Signature · 1 line
2.17.1
Re: [PATCH 2/4] arm64/mm: wire up CONFIG_ARCH_HAS_SET_DIRECT_MAP
Quoted 2 lines · Ard Biesheuvel
Wire up the special helper functions to manipulate aliases of vmalloc regions in the linear map.
IMHO the commit message here could be bit more descriptive because of the amount of changes this patch brings in.
Quoted 41 lines
Signed-off-by Ard Biesheuvel <[email protected]>--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cacheflush.h | 3 ++ arch/arm64/mm/pageattr.c | 48 ++++++++++++++++---- mm/vmalloc.c | 11 ----- 4 files changed, 44 insertions(+), 19 deletions(-)arch/arm64/Kconfig +1
-0@@ -26,6 +26,7 @@ config ARM64 select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SETUP_DMA_OPS + select ARCH_HAS_SET_DIRECT_MAP select ARCH_HAS_SET_MEMORY select ARCH_HAS_STRICT_KERNEL_RWX select ARCH_HAS_STRICT_MODULE_RWXarch/arm64/include/asm/cacheflush.h +3
-0@@ -187,4 +187,7 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end)int set_memory_valid (unsigned long addr,int numpages,int enable); +int set_direct_map_invalid_noflush (struct page *page); +int set_direct_map_default_noflush (struct page *page); +#endif arch/arm64/mm/pageattr.c +0
-0@@ -159,17 +159,48 @@ int set_memory_valid(unsigned long addr, int numpages, int enable) __pgprot(PTE_VALID)); }
arch/arm64/mm/pageattr.c int set_memory_valid(unsigned long addr, int numpages, int enable) · line 170
Quoted 10 lines
arch/arm64/mm/pageattr.c +9
-1-#ifdef CONFIG_DEBUG_PAGEALLOC +int set_direct_map_invalid_noflush (struct page *page) +{ +struct page_change_data data = { + .set_mask =__pgprot (0 ), + .clear_mask =__pgprot (PTE_VALID ), + }; + +if (!rodata_full) +return 0 ;
Why rodata_full needs to be probed here ? Should not we still require the following transition even if rodata_full is not enabled. Just wondering whether we can use VM_FLUSH_RESET_PERMS feature without these required transitions.
/*
* Set direct map to something invalid so that it won't be cached if
* there are any accesses after the TLB flush, then flush the TLB and
* reset the direct map permissions to the default.
*/
set_area_direct_map(area, set_direct_map_invalid_noflush);
_vm_unmap_aliases(start, end, 1);
set_area_direct_map(area, set_direct_map_default_noflush);arch/arm64/mm/pageattr.c int set_memory_valid(unsigned long addr, int numpages, int enable) · line 181
Quoted 11 lines
arch/arm64/mm/pageattr.c +11
-0+ +return apply_to_page_range (&init_mm, + (unsigned long )page_address (page), +PAGE_SIZE , change_page_range, &data); +} + +int set_direct_map_default_noflush (struct page *page) +{ +struct page_change_data data = { + .set_mask =__pgprot (PTE_VALID |PTE_WRITE ), + .clear_mask =__pgprot (PTE_RDONLY ),
Replace __pgprot(PTE_VALID | PTE_WRITE) with PAGE_KERNEL instead !
arch/arm64/mm/pageattr.c int set_memory_valid(unsigned long addr, int numpages, int enable) · line 176
Quoted 10 lines
arch/arm64/mm/pageattr.c +10
-0+ }; + +if (!rodata_full) +return 0 ; + +return apply_to_page_range (&init_mm, + (unsigned long )page_address (page), +PAGE_SIZE , change_page_range, &data); +} +
IIUC set_direct_map_invalid_noflush() and set_direct_map_default_noflush() should set *appropriate* permissions as seen fit from platform perspective to implement this transition.
In here set_direct_map_invalid_noflush() makes the entry invalid preventing further MMU walks (hence new TLB entries). set_direct_map_default_noflush() makes it a valid write entry. Though it looks similar to PAGE_KERNEL which is the default permission for linear mapping on arm64 via __map_memblock(). Should not PAGE_KERNEL be used explicitly as suggested above.
arch/arm64/mm/pageattr.c int set_memory_valid(unsigned long addr, int numpages, int enable) · line 196
Quoted 5 lines
arch/arm64/mm/pageattr.c +3
-0void __kernel_map_pages (struct page *page,int numpages,int enable) { +if (!debug_pagealloc_enabled () && !rodata_full) +return ; +
I guess this is not related to CONFIG_ARCH_HAS_SET_DIRECT_MAP here and should be a fix or an enhancement to CONFIG_DEBUG_PAGEALLOC implementation. Just curious, !rodata_full check here to ensure that linear mapping does not have block or contig mappings and should be backed by regular pages only ?
Quoted 16 lines
arch/arm64/mm/pageattr.c +4
-5set_memory_valid ((unsigned long )page_address (page), numpages, enable); } -#ifdef CONFIG_HIBERNATION +/* -* When built with CONFIG_DEBUG_PAGEALLOC and CONFIG_HIBERNATION, this function -* is used to determine if a linear map page has been marked as not-valid by -* CONFIG_DEBUG_PAGEALLOC. Walk the page table and check the PTE_VALID bit. -* This is based on kern_addr_valid(), which almost does what we need. +* This function is used to determine if a linear map page has been marked as +* not-valid. Walk the page table and check the PTE_VALID bit. This is based +* on kern_addr_valid(), which almost does what we need. * * Because this is only called on the kernel linear map, p?d_sect() implies * p?d_present(). When debug_pagealloc is enabled, sections mappings are
arch/arm64/mm/pageattr.c bool kernel_page_present(struct page *page) · line 219
Quoted 6 lines
arch/arm64/mm/pageattr.c +3
-0@@ -183,6 +214,9 @@ bool kernel_page_present(struct page *page)pte_t *ptep;unsigned long addr = (unsigned long )page_address (page); +if (!debug_pagealloc_enabled () && !rodata_full) +return true; +
Ditto, not related to CONFIG_ARCH_HAS_SET_DIRECT_MAP.
Re: [PATCH 2/4] arm64/mm: wire up CONFIG_ARCH_HAS_SET_DIRECT_MAP
Quoted 65 lines · Anshuman Khandual
Quoted 2 lines · Ard Biesheuvel
Wire up the special helper functions to manipulate aliases of vmalloc regions in the linear map.
IMHO the commit message here could be bit more descriptive because of the amount of changes this patch brings in.
Quoted 41 lines
Signed-off-by Ard Biesheuvel <[email protected]>--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cacheflush.h | 3 ++ arch/arm64/mm/pageattr.c | 48 ++++++++++++++++---- mm/vmalloc.c | 11 ----- 4 files changed, 44 insertions(+), 19 deletions(-)arch/arm64/Kconfig +1
-0@@ -26,6 +26,7 @@ config ARM64 select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SETUP_DMA_OPS + select ARCH_HAS_SET_DIRECT_MAP select ARCH_HAS_SET_MEMORY select ARCH_HAS_STRICT_KERNEL_RWX select ARCH_HAS_STRICT_MODULE_RWXarch/arm64/include/asm/cacheflush.h +3
-0@@ -187,4 +187,7 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end)int set_memory_valid (unsigned long addr,int numpages,int enable); +int set_direct_map_invalid_noflush (struct page *page); +int set_direct_map_default_noflush (struct page *page); +#endif arch/arm64/mm/pageattr.c +0
-0@@ -159,17 +159,48 @@ int set_memory_valid(unsigned long addr, int numpages, int enable) __pgprot(PTE_VALID)); }arch/arm64/mm/pageattr.c int set_memory_valid(unsigned long addr, int numpages, int enable) · line 170
Quoted 10 lines
arch/arm64/mm/pageattr.c +9
-1-#ifdef CONFIG_DEBUG_PAGEALLOC +int set_direct_map_invalid_noflush (struct page *page) +{ +struct page_change_data data = { + .set_mask =__pgprot (0 ), + .clear_mask =__pgprot (PTE_VALID ), + }; + +if (!rodata_full) +return 0 ;Why
rodata_fullneeds to be probed here ? Should not we still require the following transition even ifrodata_fullis not enabled. Just wondering whether we can useVM_FLUSH_RESET_PERMSfeature without these required transitions.
Quoted 10 lines
/* * Set direct map to something invalid so that it won't be cached if * there are any accesses after the TLB flush, then flush the TLB and * reset the direct map permissions to the default. */ set_area_direct_map(area, set_direct_map_invalid_noflush); _vm_unmap_aliases(start, end, 1); set_area_direct_map(area, set_direct_map_default_noflush);Quoted 1 line
arch/arm64/mm/pageattr.c +1
-0+
How would that work? With rodata_full disabled, the linear region is not mapped down to pages, and so there is no way we can manipulate linear aliases at page granularity.
Quoted 4 lines
Quoted 4 lines
arch/arm64/mm/pageattr.c +4
-0+return apply_to_page_range (&init_mm, + (unsigned long )page_address (page), +PAGE_SIZE , change_page_range, &data); +}
Quoted 9 lines
arch/arm64/mm/pageattr.c int set_memory_valid(unsigned long addr, int numpages, int enable) · line 181
Quoted 6 lines
arch/arm64/mm/pageattr.c +6
-0+ +int set_direct_map_default_noflush (struct page *page) +{ +struct page_change_data data = { + .set_mask =__pgprot (PTE_VALID |PTE_WRITE ), + .clear_mask =__pgprot (PTE_RDONLY ),Replace
__pgprot(PTE_VALID | PTE_WRITE)withPAGE_KERNELinstead !
This is a delta mask, so no need to pull in the PTE_MAYBE_NG or other attributes that we know we haven't changed.
Quoted 15 lines
arch/arm64/mm/pageattr.c int set_memory_valid(unsigned long addr, int numpages, int enable) · line 176
Quoted 10 lines
arch/arm64/mm/pageattr.c +10
-0+ }; + +if (!rodata_full) +return 0 ; + +return apply_to_page_range (&init_mm, + (unsigned long )page_address (page), +PAGE_SIZE , change_page_range, &data); +} +IIUC
set_direct_map_invalid_noflush()andset_direct_map_default_noflush()should set *appropriate* permissions as seen fit from platform perspective to implement this transition.
Quoted 6 lines
In here
set_direct_map_invalid_noflush()makes the entry invalid preventing further MMU walks (hence new TLB entries).set_direct_map_default_noflush()makes it a valid write entry. Though it looks similar toPAGE_KERNELwhich is the default permission for linear mapping on arm64 via__map_memblock(). Should notPAGE_KERNELbe used explicitly as suggested above.
No. We should restore the attributes that we cleared when manipulating the linear aliases. There isn't a lot of code that does that, so I don't see the need to use PAGE_KERNEL here.
Quoted 11 lines
arch/arm64/mm/pageattr.c int set_memory_valid(unsigned long addr, int numpages, int enable) · line 196
Quoted 5 lines
arch/arm64/mm/pageattr.c +3
-0void __kernel_map_pages (struct page *page,int numpages,int enable) { +if (!debug_pagealloc_enabled () && !rodata_full) +return ; +I guess this is not related to
CONFIG_ARCH_HAS_SET_DIRECT_MAPhere and should be a fix or an enhancement toCONFIG_DEBUG_PAGEALLOCimplementation. Just curious, !rodata_full check here to ensure that linear mapping does not have block or contig mappings and should be backed by regular pages only ?
It is related. CONFIG_ARCH_HAS_SET_DIRECT_MAP introduces references to __kernel_map_pages() in generic code, so enabling CONFIG_ARCH_HAS_SET_DIRECT_MAP should make __kernel_map_pages() available unconditionally as well.
Quoted 19 lines
Quoted 19 lines
arch/arm64/mm/pageattr.c +4
-5set_memory_valid ((unsigned long )page_address (page), numpages, enable); } -#ifdef CONFIG_HIBERNATION +/* -* When built with CONFIG_DEBUG_PAGEALLOC and CONFIG_HIBERNATION, this function -* is used to determine if a linear map page has been marked as not-valid by -* CONFIG_DEBUG_PAGEALLOC. Walk the page table and check the PTE_VALID bit. -* This is based on kern_addr_valid(), which almost does what we need. +* This function is used to determine if a linear map page has been marked as +* not-valid. Walk the page table and check the PTE_VALID bit. This is based +* on kern_addr_valid(), which almost does what we need. * * Because this is only called on the kernel linear map, p?d_sect() implies * p?d_present(). When debug_pagealloc is enabled, sections mappings are @@ -183,6 +214,9 @@ bool kernel_page_present(struct page *page)pte_t *ptep;unsigned long addr = (unsigned long )page_address (page);
Quoted 6 lines
arch/arm64/mm/pageattr.c bool kernel_page_present(struct page *page) · line 219
Quoted 3 lines
arch/arm64/mm/pageattr.c +3
-0+if (!debug_pagealloc_enabled () && !rodata_full) +return true; +Ditto, not related to
CONFIG_ARCH_HAS_SET_DIRECT_MAP.
It is related.
Re: [PATCH 2/4] arm64/mm: wire up CONFIG_ARCH_HAS_SET_DIRECT_MAP
Quoted 72 lines · Ard Biesheuvel
Quoted 71 lines · Anshuman Khandual
Quoted 2 lines · Ard Biesheuvel
Wire up the special helper functions to manipulate aliases of vmalloc regions in the linear map.
IMHO the commit message here could be bit more descriptive because of the amount of changes this patch brings in.
Quoted 39 lines
Signed-off-by Ard Biesheuvel <[email protected]>---
arch/arm64/Kconfig | 1 +arch/arm64/include/asm/cacheflush.h| 3 ++ arch/arm64/mm/pageattr.c | 48 ++++++++++++++++---- mm/vmalloc.c | 11 -----4 files changed, 44 insertions(+), 19 deletions(-)arch/arm64/Kconfig +0
-0@@ -26,6 +26,7 @@ config ARM64select
ARCH_HAS_MEMBARRIER_SYNC_CORE
selectARCH_HAS_PTE_SPECIAL
selectARCH_HAS_SETUP_DMA_OPS
+ selectARCH_HAS_SET_DIRECT_MAP
selectARCH_HAS_SET_MEMORY
selectARCH_HAS_STRICT_KERNEL_RWX
selectARCH_HAS_STRICT_MODULE_RWXarch/arm64/include/asm/cacheflush.h +2
-0@@ -187,4 +187,7 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end) int set_memory_valid(unsigned long addr, int numpages, int enable); +int set_direct_map_invalid_noflush(struct page *page); +int set_direct_map_default_noflush (struct page *page); + #endifarch/arm64/mm/pageattr.c +0
-0@@ -159,17 +159,48 @@ int set_memory_valid(unsigned long addr, int numpages, int enable) __pgprot(PTE_VALID)); }-#ifdef
CONFIG_DEBUG_PAGEALLOCarch/arm64/mm/pageattr.c int set_memory_valid(unsigned long addr, int numpages, int enable) · line 170
Quoted 9 lines
arch/arm64/mm/pageattr.c +9
-0+int set_direct_map_invalid_noflush (struct page *page) +{ + struct page_change_data data = { + .set_mask = __pgprot(0), + .clear_mask = __pgprot(PTE_VALID), + }; + + if (!rodata_full) + return 0;Why
rodata_fullneeds to be probed here ? Should not we still require the following transition even ifrodata_fullis not enabled. Just wondering whether we can useVM_FLUSH_RESET_PERMSfeature without these required transitions./*
* Set direct map to something invalid so that it won't be cached if
* there are any accesses after the TLB flush, then flush the TLB and
* reset the direct map permissions to the default.
*/
set_area_direct_map(area, set_direct_map_invalid_noflush);_vm_unmap_aliases(start, end, 1);set_area_direct_map(area, set_direct_map_default_noflush);
Quoted 3 lines
Quoted 1 line
> +
How would that work? With
rodata_fulldisabled, the linear region is not mapped down to pages, and so there is no way we can manipulate linear aliases at page granularity.
Then should not we check debug_pagealloc_enabled() as well as in case for __kernel_map_pages() later in the patch.
Quoted 32 lines
Quoted 14 lines
arch/arm64/mm/pageattr.c int set_memory_valid(unsigned long addr, int numpages, int enable) · line 181
Quoted 11 lines
+ return apply_to_page_range(&init_mm,
+ (unsigned long)page_address(page), +PAGE_SIZE,change_page_range, &data);arch/arm64/mm/pageattr.c +7
-0+} + +int set_direct_map_default_noflush (struct page *page) +{ + struct page_change_data data = { + .set_mask = __pgprot(PTE_VALID | PTE_WRITE), + .clear_mask = __pgprot(PTE_RDONLY),Replace
__pgprot(PTE_VALID | PTE_WRITE)withPAGE_KERNELinstead !This is a delta mask, so no need to pull in the
PTE_MAYBE_NGor other attributes that we know we haven't changed.Quoted 15 lines
arch/arm64/mm/pageattr.c int set_memory_valid(unsigned long addr, int numpages, int enable) · line 176
Quoted 10 lines
+ };
arch/arm64/mm/pageattr.c +9
-0+ + if (!rodata_full) + return 0; + + return apply_to_page_range(&init_mm, + (unsigned long)page_address(page), + PAGE_SIZE, change_page_range, &data); +} +IIUC
set_direct_map_invalid_noflush()andset_direct_map_default_noflush()should set *appropriate* permissions as seen fit from platform perspective to implement this transition.
Quoted 8 lines
Quoted 6 lines
In here
set_direct_map_invalid_noflush()makes the entry invalid preventing further MMU walks (hence new TLB entries).set_direct_map_default_noflush()makes it a valid write entry. Though it looks similar toPAGE_KERNELwhich is the default permission for linear mapping on arm64 via__map_memblock(). Should notPAGE_KERNELbe used explicitly as suggested above.No. We should restore the attributes that we cleared when manipulating the linear aliases. There isn't a lot of code that does that, so I don't see the need to use
PAGE_KERNELhere.
Fair enough.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
void
__kernel_map_pages(struct page *page, int numpages, int enable){
+ if (!debug_pagealloc_enabled() && !rodata_full)
+ return;
+
Quoted 7 lines
Quoted 5 lines
I guess this is not related to
CONFIG_ARCH_HAS_SET_DIRECT_MAPhere and should be a fix or an enhancement toCONFIG_DEBUG_PAGEALLOCimplementation. Just curious, !rodata_full check here to ensure that linear mapping does not have block or contig mappings and should be backed by regular pages only ?It is related.
CONFIG_ARCH_HAS_SET_DIRECT_MAPintroduces references to__kernel_map_pages()in generic code, so enablingCONFIG_ARCH_HAS_SET_DIRECT_MAPshould make__kernel_map_pages()available unconditionally as well.
Ahh, got it.
Quoted 26 lines
Quoted 16 lines
Quoted 16 lines
set_memory_valid((unsigned long)page_address(page), numpages, enable); }arch/arm64/mm/pageattr.c +1
-1-#ifdef CONFIG_HIBERNATION +/*
- * When built withCONFIG_DEBUG_PAGEALLOCandCONFIG_HIBERNATION, this function
- * is used to determine if a linear map page has been marked as not-valid by
- *CONFIG_DEBUG_PAGEALLOC. Walk the page table and check thePTE_VALIDbit.
- * This is based onkern_addr_valid(), which almost does what we need.
+ * This function is used to determine if a linear map page has been marked as
+ * not-valid. Walk the page table and check thePTE_VALIDbit. This is based
+ * onkern_addr_valid(), which almost does what we need.
*
* Because this is only called on the kernel linear map, p?d_sect() implies
* p?d_present(). Whendebug_pageallocis enabled, sections mappings areQuoted 9 lines
arch/arm64/mm/pageattr.c bool kernel_page_present(struct page *page) · line 218
Quoted 6 lines
arch/arm64/mm/pageattr.c +2
-0@@ -183,6 +214,9 @@ bool kernel_page_present(struct page *page) pte_t *ptep; unsigned long addr = (unsigned long)page_address(page); + if (!debug_pagealloc_enabled() && !rodata_full) + return true; +Ditto, not related to
CONFIG_ARCH_HAS_SET_DIRECT_MAP.
Quoted 1 line
It is related.
Never mind.
Re: [PATCH 2/4] arm64/mm: wire up CONFIG_ARCH_HAS_SET_DIRECT_MAP
Quoted 75 lines · Anshuman Khandual
Quoted 72 lines · Ard Biesheuvel
Quoted 71 lines · Anshuman Khandual
Quoted 2 lines · Ard Biesheuvel
Wire up the special helper functions to manipulate aliases of vmalloc regions in the linear map.
IMHO the commit message here could be bit more descriptive because of the amount of changes this patch brings in.
Quoted 38 lines
Signed-off-by Ard Biesheuvel <[email protected]>--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cacheflush.h | 3 ++ arch/arm64/mm/pageattr.c | 48 ++++++++++++++++---- mm/vmalloc.c | 11 ----- 4 files changed, 44 insertions(+), 19 deletions(-)arch/arm64/Kconfig +1
-0@@ -26,6 +26,7 @@ config ARM64 select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SETUP_DMA_OPS + select ARCH_HAS_SET_DIRECT_MAP select ARCH_HAS_SET_MEMORY select ARCH_HAS_STRICT_KERNEL_RWX select ARCH_HAS_STRICT_MODULE_RWXarch/arm64/include/asm/cacheflush.h +2
-0@@ -187,4 +187,7 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end) int set_memory_valid(unsigned long addr, int numpages, int enable); +int set_direct_map_invalid_noflush(struct page *page); +int set_direct_map_default_noflush (struct page *page); + #endifarch/arm64/mm/pageattr.c +0
-0@@ -159,17 +159,48 @@ int set_memory_valid(unsigned long addr, int numpages, int enable) __pgprot(PTE_VALID)); }arch/arm64/mm/pageattr.c int set_memory_valid(unsigned long addr, int numpages, int enable) · line 170
Quoted 10 lines
arch/arm64/mm/pageattr.c +9
-0-#ifdef CONFIG_DEBUG_PAGEALLOC +int set_direct_map_invalid_noflush (struct page *page) +{ + struct page_change_data data = { + .set_mask = __pgprot(0), + .clear_mask = __pgprot(PTE_VALID), + }; + + if (!rodata_full) + return 0;Why
rodata_fullneeds to be probed here ? Should not we still require the following transition even ifrodata_fullis not enabled. Just wondering whether we can useVM_FLUSH_RESET_PERMSfeature without these required transitions./*
* Set direct map to something invalid so that it won't be cached if
* there are any accesses after the TLB flush, then flush the TLB and
* reset the direct map permissions to the default.
*/
set_area_direct_map(area, set_direct_map_invalid_noflush);_vm_unmap_aliases(start, end, 1);set_area_direct_map(area, set_direct_map_default_noflush);
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
> +
How would that work? With
rodata_fulldisabled, the linear region is not mapped down to pages, and so there is no way we can manipulate linear aliases at page granularity.Then should not we check
debug_pagealloc_enabled()as well as in case for__kernel_map_pages()later in the patch.
Yes, what we could do technically is to permit the direct_map_xx() calls to proceed if debug_pagealloc_enabled() returns true, since we are guaranteed to have a page granular mapping of the entire linear region.
However, that means we will be manipulating the linear aliases of vmalloc mappings even if the user has requested us not to, i.e., by passing rodata=on rather than rodata=full, so I don't think we should be doing that.
Quoted 90 lines
Quoted 32 lines
Quoted 14 lines
arch/arm64/mm/pageattr.c int set_memory_valid(unsigned long addr, int numpages, int enable) · line 181
Quoted 11 lines
arch/arm64/mm/pageattr.c +10
-0+ return apply_to_page_range(&init_mm, + (unsigned long)page_address(page), + PAGE_SIZE, change_page_range, &data); +} + +int set_direct_map_default_noflush (struct page *page) +{ + struct page_change_data data = { + .set_mask = __pgprot(PTE_VALID | PTE_WRITE), + .clear_mask = __pgprot(PTE_RDONLY),Replace
__pgprot(PTE_VALID | PTE_WRITE)withPAGE_KERNELinstead !This is a delta mask, so no need to pull in the
PTE_MAYBE_NGor other attributes that we know we haven't changed.Quoted 15 lines
arch/arm64/mm/pageattr.c int set_memory_valid(unsigned long addr, int numpages, int enable) · line 176
Quoted 10 lines
arch/arm64/mm/pageattr.c +10
-0+ }; + + if (!rodata_full) + return 0; + + return apply_to_page_range(&init_mm, + (unsigned long)page_address(page), + PAGE_SIZE, change_page_range, &data); +} +IIUC
set_direct_map_invalid_noflush()andset_direct_map_default_noflush()should set *appropriate* permissions as seen fit from platform perspective to implement this transition.Quoted 8 lines
Quoted 6 lines
In here
set_direct_map_invalid_noflush()makes the entry invalid preventing further MMU walks (hence new TLB entries).set_direct_map_default_noflush()makes it a valid write entry. Though it looks similar toPAGE_KERNELwhich is the default permission for linear mapping on arm64 via__map_memblock(). Should notPAGE_KERNELbe used explicitly as suggested above.No. We should restore the attributes that we cleared when manipulating the linear aliases. There isn't a lot of code that does that, so I don't see the need to use
PAGE_KERNELhere.Fair enough.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
arch/arm64/mm/pageattr.c +3
-0void __kernel_map_pages(struct page *page, int numpages, int enable) { + if (!debug_pagealloc_enabled() && !rodata_full) + return; +Quoted 7 lines
Quoted 5 lines
I guess this is not related to
CONFIG_ARCH_HAS_SET_DIRECT_MAPhere and should be a fix or an enhancement toCONFIG_DEBUG_PAGEALLOCimplementation. Just curious, !rodata_full check here to ensure that linear mapping does not have block or contig mappings and should be backed by regular pages only ?It is related.
CONFIG_ARCH_HAS_SET_DIRECT_MAPintroduces references to__kernel_map_pages()in generic code, so enablingCONFIG_ARCH_HAS_SET_DIRECT_MAPshould make__kernel_map_pages()available unconditionally as well.Ahh, got it.
Quoted 26 lines
Quoted 16 lines
Quoted 16 lines
arch/arm64/mm/pageattr.c +4
-5set_memory_valid((unsigned long)page_address(page), numpages, enable); } -#ifdef CONFIG_HIBERNATION + /* -* When built with CONFIG_DEBUG_PAGEALLOC and CONFIG_HIBERNATION, this function -* is used to determine if a linear map page has been marked as not-valid by -* CONFIG_DEBUG_PAGEALLOC. Walk the page table and check the PTE_VALID bit. -* This is based on kern_addr_valid(), which almost does what we need. +* This function is used to determine if a linear map page has been marked as +* not-valid. Walk the page table and check the PTE_VALID bit. This is based +* on kern_addr_valid(), which almost does what we need. * * Because this is only called on the kernel linear map, p?d_sect() implies * p?d_present(). When debug_pagealloc is enabled, sections mappings are Quoted 9 lines
arch/arm64/mm/pageattr.c bool kernel_page_present(struct page *page) · line 218
Quoted 6 lines
arch/arm64/mm/pageattr.c +2
-0@@ -183,6 +214,9 @@ bool kernel_page_present(struct page *page) pte_t *ptep; unsigned long addr = (unsigned long)page_address(page); + if (!debug_pagealloc_enabled() && !rodata_full) + return true; +Ditto, not related to
CONFIG_ARCH_HAS_SET_DIRECT_MAP.Quoted 1 line
It is related.
Never mind.
PATCH 3/4 arm64/kprobes: set VM_FLUSH_RESET_PERMS on kprobe instruction pages
In reply to Ard BiesheuvelIn 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.
--- arch/arm64/kernel/probes/kprobes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm64/kernel/probes/kprobes.c +3 -1
@@ -131,8 +131,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; }
Signature · 1 line
2.17.1
Re: [PATCH 3/4] arm64/kprobes: set VM_FLUSH_RESET_PERMS on kprobe instruction pages
Quoted 6 lines · Ard Biesheuvel
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_PERMSattribute. This instructs the core vmalloc code not to defer the TLB flush when this region is unmapped and returned to the page allocator.
Makes sense.
Quoted 11 lines
Signed-off-by Ard Biesheuvel <[email protected]>--- arch/arm64/kernel/probes/kprobes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/arm64/kernel/probes/kprobes.c +0
-0
arch/arm64/kernel/probes/kprobes.c void *alloc_insn_page(void) · line 137
Quoted 8 lines
arch/arm64/kernel/probes/kprobes.c +3
-1@@ -131,8 +131,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); + }
Looks good. It seems there might be more users who would like to set VM_FLUSH_RESET_PERMS right after their allocation for the same reason. Hence would not it help to have a variant like vmalloc_exec_reset() or such which will tag vm_struct->flags with VM_FLUSH_RESET_PERMS right after it's allocation without requiring the caller to do the same.
Re: [PATCH 3/4] arm64/kprobes: set VM_FLUSH_RESET_PERMS on kprobe instruction pages
Quoted 25 lines · Anshuman Khandual
Quoted 6 lines · Ard Biesheuvel
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_PERMSattribute. This instructs the core vmalloc code not to defer the TLB flush when this region is unmapped and returned to the page allocator.Makes sense.
Quoted 13 lines
Signed-off-by Ard Biesheuvel <[email protected]>--- arch/arm64/kernel/probes/kprobes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/arm64/kernel/probes/kprobes.c +0
-0@@ -131,8 +131,10 @@ void *alloc_insn_page(void)void *page;
Quoted 13 lines
arch/arm64/kernel/probes/kprobes.c void *alloc_insn_page(void) · line 137
Quoted 6 lines
arch/arm64/kernel/probes/kprobes.c +3
-1page =vmalloc_exec (PAGE_SIZE ); -if (page) +if (page) {set_memory_ro ((unsigned long )page,1 ); +set_vm_flush_reset_perms (page); + }Looks good. It seems there might be more users who would like to set
VM_FLUSH_RESET_PERMSright after their allocation for the same reason. Hence would not it help to have a variant likevmalloc_exec_reset()or such which will tagvm_struct->flagswithVM_FLUSH_RESET_PERMSright after it's allocation without requiring the caller to do the same.
If there is a sufficient number of similar users, then of course, it makes sense to factor this out. However, the kprobes code is slightly unusual in the sense that it allocates memory and immediately remaps it read-only, and relies on code patching to populate this allocation. I am not expecting to see this pattern in other places.
PATCH 4/4 arm64: bpf: do not allocate executable memory
In reply to Ard BiesheuvelThe BPF code now takes care of mapping the code pages executable after mapping them read-only, to ensure that no RWX mapped regions are needed, even transiently. This means we can drop the executable permissions from the mapping at allocation time.
--- arch/arm64/net/bpf_jit_comp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/net/bpf_jit_comp.c +1 -1
@@ -981,7 +981,7 @@ void *bpf_jit_alloc_exec(unsigned long size) {return __vmalloc_node_range (size,PAGE_SIZE ,BPF_JIT_REGION_START ,BPF_JIT_REGION_END ,GFP_KERNEL , -PAGE_KERNEL_EXEC ,0 ,NUMA_NO_NODE , +PAGE_KERNEL ,0 ,NUMA_NO_NODE ,__builtin_return_address (0 )); }
Signature · 1 line
2.17.1
Quoted 23 lines · Ard Biesheuvel
Wire up the code introduced in v5.2 to manage the permissions of executable vmalloc regions (and their linear aliases) more strictly.
One of the things that came up in the internal discussion is whether non-x86 architectures have any benefit at all from the lazy vunmap feature, and whether it would perhaps be better to implement eager vunmap instead.
Cc Nadav Amit <[email protected]>Cc Rick Edgecombe <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andrew Morton <[email protected]>Cc Will Deacon <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc James Morse <[email protected]>Ard Biesheuvel (4):
arm64: module: create module allocations without exec permissions arm64/mm: wire upCONFIG_ARCH_HAS_SET_DIRECT_MAParm64/kprobes: setVM_FLUSH_RESET_PERMSon kprobe instruction pages
arm64: bpf: do not allocate executable memory
Quoted 8 lines
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cacheflush.h | 3 ++ arch/arm64/kernel/module.c | 4 +- arch/arm64/kernel/probes/kprobes.c | 4 +- arch/arm64/mm/pageattr.c | 48 ++++++++++++++++---- arch/arm64/net/bpf_jit_comp.c | 2 +- mm/vmalloc.c | 11 ----- 7 files changed, 50 insertions(+), 23 deletions(-)
Thanks, this all looks good to me. I can get pick this up for 5.2 if Rick's fixes [1] land soon enough.
Cheers,
Will
Quoted 33 lines · Will Deacon
Quoted 23 lines · Ard Biesheuvel
Wire up the code introduced in v5.2 to manage the permissions of executable vmalloc regions (and their linear aliases) more strictly.
One of the things that came up in the internal discussion is whether non-x86 architectures have any benefit at all from the lazy vunmap feature, and whether it would perhaps be better to implement eager vunmap instead.
Cc Nadav Amit <[email protected]>Cc Rick Edgecombe <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andrew Morton <[email protected]>Cc Will Deacon <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc James Morse <[email protected]>Ard Biesheuvel (4):
arm64: module: create module allocations without exec permissions arm64/mm: wire upCONFIG_ARCH_HAS_SET_DIRECT_MAParm64/kprobes: setVM_FLUSH_RESET_PERMSon kprobe instruction pages
arm64: bpf: do not allocate executable memoryQuoted 8 lines
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cacheflush.h | 3 ++ arch/arm64/kernel/module.c | 4 +- arch/arm64/kernel/probes/kprobes.c | 4 +- arch/arm64/mm/pageattr.c | 48 ++++++++++++++++---- arch/arm64/net/bpf_jit_comp.c | 2 +- mm/vmalloc.c | 11 ----- 7 files changed, 50 insertions(+), 23 deletions(-)
Quoted 3 lines
Thanks, this all looks good to me. I can get pick this up for 5.2 if Rick's fixes [1] land soon enough.
Note that you'll get a trivial conflict in the hunk against mm/vmalloc.c.
Quoted 33 lines · Will Deacon
Quoted 23 lines · Ard Biesheuvel
Wire up the code introduced in v5.2 to manage the permissions of executable vmalloc regions (and their linear aliases) more strictly.
One of the things that came up in the internal discussion is whether non-x86 architectures have any benefit at all from the lazy vunmap feature, and whether it would perhaps be better to implement eager vunmap instead.
Cc Nadav Amit <[email protected]>Cc Rick Edgecombe <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andrew Morton <[email protected]>Cc Will Deacon <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc James Morse <[email protected]>Ard Biesheuvel (4):
arm64: module: create module allocations without exec permissions arm64/mm: wire upCONFIG_ARCH_HAS_SET_DIRECT_MAParm64/kprobes: setVM_FLUSH_RESET_PERMSon kprobe instruction pages
arm64: bpf: do not allocate executable memoryQuoted 8 lines
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cacheflush.h | 3 ++ arch/arm64/kernel/module.c | 4 +- arch/arm64/kernel/probes/kprobes.c | 4 +- arch/arm64/mm/pageattr.c | 48 ++++++++++++++++---- arch/arm64/net/bpf_jit_comp.c | 2 +- mm/vmalloc.c | 11 ----- 7 files changed, 50 insertions(+), 23 deletions(-)
Quoted 2 lines
Thanks, this all looks good to me. I can get pick this up for 5.2 if Rick's fixes [1] land soon enough.
Bah, I missed these landing in -rc5 and I think it's a bit too late for us to take this for 5.2. now particularly with our limited ability to fix any late regressions that might arise.
In which case, Catalin, please can you take these for 5.3? You might run into some testing failures with for-next/core due to the late of Rick's fixes, but linux-next should be alright and I don't think you'll get any conflicts.
Ard: are you ok with that?
Thanks,
Will
Quoted 41 lines · Will Deacon
Quoted 33 lines · Will Deacon
Quoted 23 lines · Ard Biesheuvel
Wire up the code introduced in v5.2 to manage the permissions of executable vmalloc regions (and their linear aliases) more strictly.
One of the things that came up in the internal discussion is whether non-x86 architectures have any benefit at all from the lazy vunmap feature, and whether it would perhaps be better to implement eager vunmap instead.
Cc Nadav Amit <[email protected]>Cc Rick Edgecombe <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andrew Morton <[email protected]>Cc Will Deacon <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc James Morse <[email protected]>Ard Biesheuvel (4):
arm64: module: create module allocations without exec permissions arm64/mm: wire upCONFIG_ARCH_HAS_SET_DIRECT_MAParm64/kprobes: setVM_FLUSH_RESET_PERMSon kprobe instruction pages
arm64: bpf: do not allocate executable memoryQuoted 8 lines
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cacheflush.h | 3 ++ arch/arm64/kernel/module.c | 4 +- arch/arm64/kernel/probes/kprobes.c | 4 +- arch/arm64/mm/pageattr.c | 48 ++++++++++++++++---- arch/arm64/net/bpf_jit_comp.c | 2 +- mm/vmalloc.c | 11 ----- 7 files changed, 50 insertions(+), 23 deletions(-)Quoted 2 lines
Thanks, this all looks good to me. I can get pick this up for 5.2 if Rick's fixes [1] land soon enough.
Bah, I missed these landing in -rc5 and I think it's a bit too late for us to take this for 5.2. now particularly with our limited ability to fix any late regressions that might arise.
Quoted 9 lines
In which case, Catalin, please can you take these for 5.3? You might run into some testing failures with for-next/core due to the late of Rick's fixes, but linux-next should be alright and I don't think you'll get any conflicts.
Acked-by Will Deacon <[email protected]>Ard: are you ok with that?
That is fine, although I won't be around to pick up the pieces by the time the merge window opens. Also, I'd like to follow up on the lazy vunmap thing for non-x86, but perhaps we can talk about this at plumbers?
(+ Catalin)
Quoted 48 lines · Ard Biesheuvel
Quoted 46 lines · Will Deacon
Quoted 33 lines · Will Deacon
Quoted 23 lines · Ard Biesheuvel
Wire up the code introduced in v5.2 to manage the permissions of executable vmalloc regions (and their linear aliases) more strictly.
One of the things that came up in the internal discussion is whether non-x86 architectures have any benefit at all from the lazy vunmap feature, and whether it would perhaps be better to implement eager vunmap instead.
Cc Nadav Amit <[email protected]>Cc Rick Edgecombe <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Andrew Morton <[email protected]>Cc Will Deacon <[email protected]>Cc Masami Hiramatsu <[email protected]>Cc James Morse <[email protected]>Ard Biesheuvel (4):
arm64: module: create module allocations without exec permissions arm64/mm: wire upCONFIG_ARCH_HAS_SET_DIRECT_MAParm64/kprobes: setVM_FLUSH_RESET_PERMSon kprobe instruction pages
arm64: bpf: do not allocate executable memoryQuoted 8 lines
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cacheflush.h | 3 ++ arch/arm64/kernel/module.c | 4 +- arch/arm64/kernel/probes/kprobes.c | 4 +- arch/arm64/mm/pageattr.c | 48 ++++++++++++++++---- arch/arm64/net/bpf_jit_comp.c | 2 +- mm/vmalloc.c | 11 ----- 7 files changed, 50 insertions(+), 23 deletions(-)Quoted 2 lines
Thanks, this all looks good to me. I can get pick this up for 5.2 if Rick's fixes [1] land soon enough.
Bah, I missed these landing in -rc5 and I think it's a bit too late for us to take this for 5.2. now particularly with our limited ability to fix any late regressions that might arise.
In which case, Catalin, please can you take these for 5.3? You might run into some testing failures with for-next/core due to the late of Rick's fixes, but linux-next should be alright and I don't think you'll get any conflicts.
Quoted 9 lines
Quoted 4 lines
Acked-by Will Deacon <[email protected]>Ard: are you ok with that?
That is fine, although I won't be around to pick up the pieces by the time the merge window opens. Also, I'd like to follow up on the lazy vunmap thing for non-x86, but perhaps we can talk about this at plumbers?
Actually, you will run into a couple of conflicts. Let me know if you want me to respin (although they still won't apply cleanly to both for-next/core and -next)
Quoted 35 lines · Ard Biesheuvel
Quoted 34 lines · Ard Biesheuvel
Quoted 32 lines · Will Deacon
Quoted 16 lines · Will Deacon
Quoted 6 lines · Ard Biesheuvel
Ard Biesheuvel (4):
arm64: module: create module allocations without exec permissions arm64/mm: wire upCONFIG_ARCH_HAS_SET_DIRECT_MAParm64/kprobes: setVM_FLUSH_RESET_PERMSon kprobe instruction pages
arm64: bpf: do not allocate executable memoryQuoted 8 lines
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cacheflush.h | 3 ++ arch/arm64/kernel/module.c | 4 +- arch/arm64/kernel/probes/kprobes.c | 4 +- arch/arm64/mm/pageattr.c | 48 ++++++++++++++++---- arch/arm64/net/bpf_jit_comp.c | 2 +- mm/vmalloc.c | 11 ----- 7 files changed, 50 insertions(+), 23 deletions(-)Quoted 2 lines
Thanks, this all looks good to me. I can get pick this up for 5.2 if Rick's fixes [1] land soon enough.
Bah, I missed these landing in -rc5 and I think it's a bit too late for us to take this for 5.2. now particularly with our limited ability to fix any late regressions that might arise.
In which case, Catalin, please can you take these for 5.3? You might run into some testing failures with for-next/core due to the late of Rick's fixes, but linux-next should be alright and I don't think you'll get any conflicts.
Acked-by Will Deacon <[email protected]>Ard: are you ok with that?
Quoted 7 lines
Quoted 3 lines
That is fine, although I won't be around to pick up the pieces by the time the merge window opens. Also, I'd like to follow up on the lazy vunmap thing for non-x86, but perhaps we can talk about this at plumbers?
Actually, you will run into a couple of conflicts. Let me know if you want me to respin (although they still won't apply cleanly to both for-next/core and -next)
I queued them in for-next/core (and fixed a minor conflict). Thanks.
Signature · 1 line
Catalin
Quoted 41 lines · Catalin Marinas
Quoted 39 lines · Ard Biesheuvel
Quoted 37 lines · Ard Biesheuvel
Quoted 24 lines · Will Deacon
Quoted 16 lines · Will Deacon
Quoted 6 lines · Ard Biesheuvel
Ard Biesheuvel (4):
arm64: module: create module allocations without exec permissions arm64/mm: wire upCONFIG_ARCH_HAS_SET_DIRECT_MAParm64/kprobes: setVM_FLUSH_RESET_PERMSon kprobe instruction pages
arm64: bpf: do not allocate executable memoryQuoted 8 lines
arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cacheflush.h | 3 ++ arch/arm64/kernel/module.c | 4 +- arch/arm64/kernel/probes/kprobes.c | 4 +- arch/arm64/mm/pageattr.c | 48 ++++++++++++++++---- arch/arm64/net/bpf_jit_comp.c | 2 +- mm/vmalloc.c | 11 ----- 7 files changed, 50 insertions(+), 23 deletions(-)Quoted 2 lines
Thanks, this all looks good to me. I can get pick this up for 5.2 if Rick's fixes [1] land soon enough.
Bah, I missed these landing in -rc5 and I think it's a bit too late for us to take this for 5.2. now particularly with our limited ability to fix any late regressions that might arise.
Quoted 8 lines
In which case, Catalin, please can you take these for 5.3? You might run into some testing failures with for-next/core due to the late of Rick's fixes, but linux-next should be alright and I don't think you'll get any conflicts.
Acked-by Will Deacon <[email protected]>Ard: are you ok with that?
That is fine, although I won't be around to pick up the pieces by the time the merge window opens. Also, I'd like to follow up on the lazy vunmap thing for non-x86, but perhaps we can talk about this at plumbers?
Quoted 6 lines
Quoted 3 lines
Actually, you will run into a couple of conflicts. Let me know if you want me to respin (although they still won't apply cleanly to both for-next/core and -next)
I queued them in for-next/core (and fixed a minor conflict). Thanks.
OK, in that case, you will get a conflict in -next on the hunk against mm/vmalloc.c in the second patch. Just FYI ...