um: set DONTDUMP and DONTFORK flags on KASAN shadow memory

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@intel.com>
Link: https://patch.msgid.link/20241103150506.1367695-1-benjamin@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Benjamin Berg 2024-11-03 16:05:02 +01:00 committed by Johannes Berg
parent 81e0679d85
commit fce0128863

View File

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