diff mbox series

[1/5] um: set DONTDUMP and DONTFORK flags on KASAN shadow memory

Message ID 20241103150211.1366452-1-benjamin@sipsolutions.net
State Superseded
Headers show
Series [1/5] um: set DONTDUMP and DONTFORK flags on KASAN shadow memory | expand

Commit Message

Benjamin Berg Nov. 3, 2024, 3:02 p.m. UTC
From: Benjamin Berg <benjamin.berg@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.
---
 arch/um/os-Linux/mem.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

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. */