[PATCH v2 1/5] um: set DONTDUMP and DONTFORK flags on KASAN shadow memory
Benjamin Berg
benjamin at sipsolutions.net
Sun Nov 3 07:05:02 PST 2024
From: Benjamin Berg <benjamin.berg at intel.com>
There is no point in either dumping the KASAN shadow memory or doing
copy-on-write after a fork on these memory regions.
This considerably speeds up coredump generation.
Signed-off-by: Benjamin Berg <benjamin.berg at intel.com>
---
arch/um/os-Linux/mem.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index 857e3deab293..72f302f4d197 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -39,6 +39,18 @@ void kasan_map_memory(void *start, size_t len)
strerror(errno));
exit(1);
}
+
+ if (madvise(start, len, MADV_DONTDUMP)) {
+ os_info("Couldn't set MAD_DONTDUMP on shadow memory: %s\n.",
+ strerror(errno));
+ exit(1);
+ }
+
+ if (madvise(start, len, MADV_DONTFORK)) {
+ os_info("Couldn't set MADV_DONTFORK on shadow memory: %s\n.",
+ strerror(errno));
+ exit(1);
+ }
}
/* Set by make_tempfile() during early boot. */
--
2.47.0
More information about the linux-um
mailing list