From: Christophe Leroy <christophe.leroy@c-s.fr> To: Benjamin Herrenschmidt <benh@kernel.crashing.org>, Paul Mackerras <paulus@samba.org>, Michael Ellerman <mpe@ellerman.id.au>, erhard_f@mailbox.org, dja@axtens.net Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH 3/5] powerpc/32: force KASAN_VMALLOC for modules Date: Tue, 14 Jan 2020 17:54:02 +0000 (UTC) [thread overview] Message-ID: <f909da11aecb59ab7f32ba01fae6f356eaa4d7bc.1579024426.git.christophe.leroy@c-s.fr> (raw) In-Reply-To: <031dec5487bde9b2181c8b3c9800e1879cf98c1a.1579024426.git.christophe.leroy@c-s.fr> Unloading/Reloading of modules seems to fail with KASAN_VMALLOC but works properly with it. Force selection of KASAN_VMALLOC when MODULES are selected, and drop module_alloc() which was dedicated to KASAN for modules. Reported-by: <erhard_f@mailbox.org> Link: https://bugzilla.kernel.org/show_bug.cgi?id=205283 Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> --- arch/powerpc/mm/kasan/kasan_init_32.c | 31 +++++-------------------------- arch/powerpc/platforms/Kconfig.cputype | 1 + 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c index 88036fb88350..b782d92622b4 100644 --- a/arch/powerpc/mm/kasan/kasan_init_32.c +++ b/arch/powerpc/mm/kasan/kasan_init_32.c @@ -12,7 +12,7 @@ #include <asm/code-patching.h> #include <mm/mmu_decl.h> -static pgprot_t kasan_prot_ro(void) +static pgprot_t __init kasan_prot_ro(void) { if (early_mmu_has_feature(MMU_FTR_HPTE_TABLE)) return PAGE_READONLY; @@ -20,7 +20,7 @@ static pgprot_t kasan_prot_ro(void) return PAGE_KERNEL_RO; } -static void kasan_populate_pte(pte_t *ptep, pgprot_t prot) +static void __init kasan_populate_pte(pte_t *ptep, pgprot_t prot) { unsigned long va = (unsigned long)kasan_early_shadow_page; phys_addr_t pa = __pa(kasan_early_shadow_page); @@ -30,7 +30,7 @@ static void kasan_populate_pte(pte_t *ptep, pgprot_t prot) __set_pte_at(&init_mm, va, ptep, pfn_pte(PHYS_PFN(pa), prot), 0); } -static int __ref kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end) +static int __init kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end) { pmd_t *pmd; unsigned long k_cur, k_next; @@ -70,7 +70,7 @@ static int __ref kasan_init_shadow_page_tables(unsigned long k_start, unsigned l return 0; } -static void __ref *kasan_get_one_page(void) +static void __init *kasan_get_one_page(void) { if (slab_is_available()) return (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO); @@ -78,7 +78,7 @@ static void __ref *kasan_get_one_page(void) return memblock_alloc(PAGE_SIZE, PAGE_SIZE); } -static int __ref kasan_init_region(void *start, size_t size) +static int __init kasan_init_region(void *start, size_t size) { unsigned long k_start = (unsigned long)kasan_mem_to_shadow(start); unsigned long k_end = (unsigned long)kasan_mem_to_shadow(start + size); @@ -196,27 +196,6 @@ void __init kasan_late_init(void) kasan_unmap_early_shadow_vmalloc(); } -#if defined(CONFIG_MODULES) && !defined(CONFIG_KASAN_VMALLOC) -void *module_alloc(unsigned long size) -{ - void *base; - - base = __vmalloc_node_range(size, MODULE_ALIGN, VMALLOC_START, VMALLOC_END, - GFP_KERNEL, PAGE_KERNEL_EXEC, VM_FLUSH_RESET_PERMS, - NUMA_NO_NODE, __builtin_return_address(0)); - - if (!base) - return NULL; - - if (!kasan_init_region(base, size)) - return base; - - vfree(base); - - return NULL; -} -#endif - #ifdef CONFIG_PPC_BOOK3S_32 u8 __initdata early_hash[256 << 10] __aligned(256 << 10) = {0}; diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index 536a2efcb7f0..851a92ffe290 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -2,6 +2,7 @@ config PPC32 bool default y if !PPC64 + select KASAN_VMALLOC if KASAN && MODULES config PPC64 bool "64-bit kernel" -- 2.13.3
WARNING: multiple messages have this Message-ID (diff)
From: Christophe Leroy <christophe.leroy@c-s.fr> To: Benjamin Herrenschmidt <benh@kernel.crashing.org>, Paul Mackerras <paulus@samba.org>, Michael Ellerman <mpe@ellerman.id.au>, erhard_f@mailbox.org, dja@axtens.net Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] powerpc/32: force KASAN_VMALLOC for modules Date: Tue, 14 Jan 2020 17:54:02 +0000 (UTC) [thread overview] Message-ID: <f909da11aecb59ab7f32ba01fae6f356eaa4d7bc.1579024426.git.christophe.leroy@c-s.fr> (raw) In-Reply-To: <031dec5487bde9b2181c8b3c9800e1879cf98c1a.1579024426.git.christophe.leroy@c-s.fr> Unloading/Reloading of modules seems to fail with KASAN_VMALLOC but works properly with it. Force selection of KASAN_VMALLOC when MODULES are selected, and drop module_alloc() which was dedicated to KASAN for modules. Reported-by: <erhard_f@mailbox.org> Link: https://bugzilla.kernel.org/show_bug.cgi?id=205283 Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> --- arch/powerpc/mm/kasan/kasan_init_32.c | 31 +++++-------------------------- arch/powerpc/platforms/Kconfig.cputype | 1 + 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c index 88036fb88350..b782d92622b4 100644 --- a/arch/powerpc/mm/kasan/kasan_init_32.c +++ b/arch/powerpc/mm/kasan/kasan_init_32.c @@ -12,7 +12,7 @@ #include <asm/code-patching.h> #include <mm/mmu_decl.h> -static pgprot_t kasan_prot_ro(void) +static pgprot_t __init kasan_prot_ro(void) { if (early_mmu_has_feature(MMU_FTR_HPTE_TABLE)) return PAGE_READONLY; @@ -20,7 +20,7 @@ static pgprot_t kasan_prot_ro(void) return PAGE_KERNEL_RO; } -static void kasan_populate_pte(pte_t *ptep, pgprot_t prot) +static void __init kasan_populate_pte(pte_t *ptep, pgprot_t prot) { unsigned long va = (unsigned long)kasan_early_shadow_page; phys_addr_t pa = __pa(kasan_early_shadow_page); @@ -30,7 +30,7 @@ static void kasan_populate_pte(pte_t *ptep, pgprot_t prot) __set_pte_at(&init_mm, va, ptep, pfn_pte(PHYS_PFN(pa), prot), 0); } -static int __ref kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end) +static int __init kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end) { pmd_t *pmd; unsigned long k_cur, k_next; @@ -70,7 +70,7 @@ static int __ref kasan_init_shadow_page_tables(unsigned long k_start, unsigned l return 0; } -static void __ref *kasan_get_one_page(void) +static void __init *kasan_get_one_page(void) { if (slab_is_available()) return (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO); @@ -78,7 +78,7 @@ static void __ref *kasan_get_one_page(void) return memblock_alloc(PAGE_SIZE, PAGE_SIZE); } -static int __ref kasan_init_region(void *start, size_t size) +static int __init kasan_init_region(void *start, size_t size) { unsigned long k_start = (unsigned long)kasan_mem_to_shadow(start); unsigned long k_end = (unsigned long)kasan_mem_to_shadow(start + size); @@ -196,27 +196,6 @@ void __init kasan_late_init(void) kasan_unmap_early_shadow_vmalloc(); } -#if defined(CONFIG_MODULES) && !defined(CONFIG_KASAN_VMALLOC) -void *module_alloc(unsigned long size) -{ - void *base; - - base = __vmalloc_node_range(size, MODULE_ALIGN, VMALLOC_START, VMALLOC_END, - GFP_KERNEL, PAGE_KERNEL_EXEC, VM_FLUSH_RESET_PERMS, - NUMA_NO_NODE, __builtin_return_address(0)); - - if (!base) - return NULL; - - if (!kasan_init_region(base, size)) - return base; - - vfree(base); - - return NULL; -} -#endif - #ifdef CONFIG_PPC_BOOK3S_32 u8 __initdata early_hash[256 << 10] __aligned(256 << 10) = {0}; diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype index 536a2efcb7f0..851a92ffe290 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -2,6 +2,7 @@ config PPC32 bool default y if !PPC64 + select KASAN_VMALLOC if KASAN && MODULES config PPC64 bool "64-bit kernel" -- 2.13.3
next prev parent reply other threads:[~2020-01-14 17:54 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-01-14 17:54 [PATCH 1/5] powerpc/32: add support of KASAN_VMALLOC Christophe Leroy 2020-01-14 17:54 ` Christophe Leroy 2020-01-14 17:54 ` [PATCH 2/5] powerpc/kconfig: move CONFIG_PPC32 into Kconfig.cputype Christophe Leroy 2020-01-14 17:54 ` Christophe Leroy 2020-01-14 17:54 ` Christophe Leroy [this message] 2020-01-14 17:54 ` [PATCH 3/5] powerpc/32: force KASAN_VMALLOC for modules Christophe Leroy 2020-01-14 17:54 ` [PATCH 4/5] powerpc/32: Simplify KASAN init Christophe Leroy 2020-01-14 17:54 ` Christophe Leroy 2020-01-14 17:54 ` [PATCH 5/5] powerpc/32: reuse orphaned memblocks in kasan_init_shadow_page_tables() Christophe Leroy 2020-01-14 17:54 ` Christophe Leroy 2020-01-29 5:17 ` [PATCH 1/5] powerpc/32: add support of KASAN_VMALLOC Michael Ellerman
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=f909da11aecb59ab7f32ba01fae6f356eaa4d7bc.1579024426.git.christophe.leroy@c-s.fr \ --to=christophe.leroy@c-s.fr \ --cc=benh@kernel.crashing.org \ --cc=dja@axtens.net \ --cc=erhard_f@mailbox.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=mpe@ellerman.id.au \ --cc=paulus@samba.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.