livedump: Silence KASAN and KMSAN when livedumping

The livedumper triggers reports from both of these sanitizers since it
necessarily accesses uninitialized or freed memory.  Add a flag to
silence reports from both sanitizers.

Reviewed by:	mhorne, khng
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D47714
This commit is contained in:
Mark Johnston 2024-11-25 21:11:37 +00:00
parent e9fa399180
commit 37cef00192
4 changed files with 12 additions and 0 deletions

View File

@ -133,8 +133,10 @@ livedump_start_vnode(struct vnode *vp, int flags, uint8_t compression)
if (error != 0)
goto out;
curthread->td_pflags2 |= TDP2_SAN_QUIET;
dump_savectx();
error = minidumpsys(livedi, true);
curthread->td_pflags2 &= ~TDP2_SAN_QUIET;
EVENTHANDLER_INVOKE(livedumper_finish);
out:

View File

@ -405,6 +405,9 @@ kasan_shadow_check(unsigned long addr, size_t size, bool write,
if (__predict_false(!kasan_enabled))
return;
if (__predict_false(curthread != NULL &&
(curthread->td_pflags2 & TDP2_SAN_QUIET) != 0))
return;
if (__predict_false(size == 0))
return;
if (__predict_false(kasan_md_unsupported(addr)))

View File

@ -179,6 +179,9 @@ kmsan_report_hook(const void *addr, msan_orig_t *orig, size_t size, size_t off,
if (__predict_false(KERNEL_PANICKED() || kdb_active || kmsan_reporting))
return;
if (__predict_false(curthread != NULL &&
(curthread->td_pflags2 & TDP2_SAN_QUIET) != 0))
return;
kmsan_reporting = true;
__compiler_membar();
@ -232,6 +235,9 @@ kmsan_report_inline(msan_orig_t orig, unsigned long pc)
if (__predict_false(KERNEL_PANICKED() || kdb_active || kmsan_reporting))
return;
if (__predict_false(curthread != NULL &&
(curthread->td_pflags2 & TDP2_SAN_QUIET) != 0))
return;
kmsan_reporting = true;
__compiler_membar();

View File

@ -567,6 +567,7 @@ enum {
#define TDP2_SBPAGES 0x00000001 /* Owns sbusy on some pages */
#define TDP2_COMPAT32RB 0x00000002 /* compat32 ABI for robust lists */
#define TDP2_ACCT 0x00000004 /* Doing accounting */
#define TDP2_SAN_QUIET 0x00000008 /* Disable warnings from K(A|M)SAN */
/*
* Reasons that the current thread can not be run yet.