From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Alex Sverdlin <alexander.sverdlin@nokia.com>,
Linus Walleij <linus.walleij@linaro.org>,
Russell King <rmk+kernel@armlinux.org.uk>,
Sasha Levin <sashal@kernel.org>,
aryabinin@virtuozzo.com, linux@armlinux.org.uk,
kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org
Subject: [PATCH AUTOSEL 5.19 39/40] ARM: 9242/1: kasan: Only map modules if CONFIG_KASAN_VMALLOC=n
Date: Tue, 11 Oct 2022 10:51:28 -0400 [thread overview]
Message-ID: <20221011145129.1623487-39-sashal@kernel.org> (raw)
In-Reply-To: <20221011145129.1623487-1-sashal@kernel.org>
From: Alex Sverdlin <alexander.sverdlin@nokia.com>
[ Upstream commit 823f606ab6b4759a1faf0388abcf4fb0776710d2 ]
In case CONFIG_KASAN_VMALLOC=y kasan_populate_vmalloc() allocates the
shadow pages dynamically. But even worse is that kasan_release_vmalloc()
releases them, which is not compatible with create_mapping() of
MODULES_VADDR..MODULES_END range:
BUG: Bad page state in process kworker/9:1 pfn:2068b
page:e5e06160 refcount:0 mapcount:0 mapping:00000000 index:0x0
flags: 0x1000(reserved)
raw: 00001000 e5e06164 e5e06164 00000000 00000000 00000000 ffffffff 00000000
page dumped because: PAGE_FLAGS_CHECK_AT_FREE flag(s) set
bad because of flags: 0x1000(reserved)
Modules linked in: ip_tables
CPU: 9 PID: 154 Comm: kworker/9:1 Not tainted 5.4.188-... #1
Hardware name: LSI Axxia AXM55XX
Workqueue: events do_free_init
unwind_backtrace
show_stack
dump_stack
bad_page
free_pcp_prepare
free_unref_page
kasan_depopulate_vmalloc_pte
__apply_to_page_range
apply_to_existing_page_range
kasan_release_vmalloc
__purge_vmap_area_lazy
_vm_unmap_aliases.part.0
__vunmap
do_free_init
process_one_work
worker_thread
kthread
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/arm/mm/kasan_init.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mm/kasan_init.c b/arch/arm/mm/kasan_init.c
index 5ad0d6c56d56..29d7233e5ad2 100644
--- a/arch/arm/mm/kasan_init.c
+++ b/arch/arm/mm/kasan_init.c
@@ -264,12 +264,17 @@ void __init kasan_init(void)
/*
* 1. The module global variables are in MODULES_VADDR ~ MODULES_END,
- * so we need to map this area.
+ * so we need to map this area if CONFIG_KASAN_VMALLOC=n. With
+ * VMALLOC support KASAN will manage this region dynamically,
+ * refer to kasan_populate_vmalloc() and ARM's implementation of
+ * module_alloc().
* 2. PKMAP_BASE ~ PKMAP_BASE+PMD_SIZE's shadow and MODULES_VADDR
* ~ MODULES_END's shadow is in the same PMD_SIZE, so we can't
* use kasan_populate_zero_shadow.
*/
- create_mapping((void *)MODULES_VADDR, (void *)(PKMAP_BASE + PMD_SIZE));
+ if (!IS_ENABLED(CONFIG_KASAN_VMALLOC) && IS_ENABLED(CONFIG_MODULES))
+ create_mapping((void *)MODULES_VADDR, (void *)(MODULES_END));
+ create_mapping((void *)PKMAP_BASE, (void *)(PKMAP_BASE + PMD_SIZE));
/*
* KAsan may reuse the contents of kasan_early_shadow_pte directly, so
--
2.35.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2022-10-11 15:23 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20221011145129.1623487-1-sashal@kernel.org>
2022-10-11 14:50 ` [PATCH AUTOSEL 5.19 02/40] ARM: dts: imx6: delete interrupts property if interrupts-extended is set Sasha Levin
2022-10-11 14:50 ` [PATCH AUTOSEL 5.19 03/40] ARM: dts: imx7d-sdb: config the max pressure for tsc2046 Sasha Levin
2022-10-11 14:50 ` [PATCH AUTOSEL 5.19 04/40] soc: mediatek: Let PMIC Wrapper and SCPSYS depend on OF Sasha Levin
2022-10-11 14:50 ` [PATCH AUTOSEL 5.19 06/40] ARM: dts: imx6q: add missing properties for sram Sasha Levin
2022-10-11 14:50 ` [PATCH AUTOSEL 5.19 07/40] ARM: dts: imx6dl: " Sasha Levin
2022-10-11 14:50 ` [PATCH AUTOSEL 5.19 08/40] ARM: dts: imx6qp: " Sasha Levin
2022-10-11 14:50 ` [PATCH AUTOSEL 5.19 09/40] ARM: dts: imx6sl: " Sasha Levin
2022-10-11 14:50 ` [PATCH AUTOSEL 5.19 10/40] ARM: dts: imx6sll: " Sasha Levin
2022-10-11 14:51 ` [PATCH AUTOSEL 5.19 11/40] ARM: dts: imx6sx: " Sasha Levin
2022-10-11 14:51 ` [PATCH AUTOSEL 5.19 12/40] ARM: dts: imx6sl: use tabs for code indent Sasha Levin
2022-10-11 14:51 ` [PATCH AUTOSEL 5.19 13/40] ARM: dts: imx6sx-udoo-neo: don't use multiple blank lines Sasha Levin
2022-10-11 14:51 ` [PATCH AUTOSEL 5.19 14/40] kselftest/arm64: Fix validatation termination record after EXTRA_CONTEXT Sasha Levin
2022-10-11 14:51 ` [PATCH AUTOSEL 5.19 15/40] kselftest/arm64: Allow larger buffers in get_signal_context() Sasha Levin
2022-10-11 14:51 ` [PATCH AUTOSEL 5.19 17/40] arm64: atomics: remove LL/SC trampolines Sasha Levin
2022-10-12 8:53 ` Catalin Marinas
2022-10-13 17:57 ` Sasha Levin
2022-10-11 14:51 ` [PATCH AUTOSEL 5.19 18/40] arm64: run softirqs on the per-CPU IRQ stack Sasha Levin
2022-10-11 14:51 ` [PATCH AUTOSEL 5.19 19/40] arm64: dts: imx8mm-kontron: Use the VSELECT signal to switch SD card IO voltage Sasha Levin
2022-10-11 14:51 ` [PATCH AUTOSEL 5.19 20/40] arm64: dts: imx8ulp: no executable source file permission Sasha Levin
2022-10-11 14:51 ` [PATCH AUTOSEL 5.19 21/40] arm64: dts: imx8mq-librem5: Add bq25895 as max17055's power supply Sasha Levin
2022-10-11 14:51 ` [PATCH AUTOSEL 5.19 22/40] ARM: orion: fix include path Sasha Levin
2022-10-11 14:51 ` [PATCH AUTOSEL 5.19 36/40] arm64: dts: uniphier: Add USB-device support for PXs3 reference board Sasha Levin
2022-10-11 14:51 ` [PATCH AUTOSEL 5.19 37/40] ARM: 9233/1: stacktrace: Skip frame pointer boundary check for call_with_stack() Sasha Levin
2022-10-11 14:51 ` [PATCH AUTOSEL 5.19 38/40] ARM: 9234/1: stacktrace: Avoid duplicate saving of exception PC value Sasha Levin
2022-10-11 14:51 ` Sasha Levin [this message]
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=20221011145129.1623487-39-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=alexander.sverdlin@nokia.com \
--cc=aryabinin@virtuozzo.com \
--cc=kasan-dev@googlegroups.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=rmk+kernel@armlinux.org.uk \
--cc=stable@vger.kernel.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).