git: 8e3c0a69fed2 - stable/14 - livedump: Silence KASAN and KMSAN when livedumping
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 13 Dec 2024 01:43:57 UTC
The branch stable/14 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=8e3c0a69fed2805157f61c5024e0948b48f80559
commit 8e3c0a69fed2805157f61c5024e0948b48f80559
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-11-25 21:11:37 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-12-13 01:34:14 +0000
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
(cherry picked from commit 37cef00192ef1347d27ac64be419267a4ba604ac)
---
sys/kern/kern_vnodedumper.c | 2 ++
sys/kern/subr_asan.c | 3 +++
sys/kern/subr_msan.c | 6 ++++++
sys/sys/proc.h | 1 +
4 files changed, 12 insertions(+)
diff --git a/sys/kern/kern_vnodedumper.c b/sys/kern/kern_vnodedumper.c
index 0104369b9d67..78979f906abd 100644
--- a/sys/kern/kern_vnodedumper.c
+++ b/sys/kern/kern_vnodedumper.c
@@ -117,8 +117,10 @@ livedump_start(int fd, 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:
diff --git a/sys/kern/subr_asan.c b/sys/kern/subr_asan.c
index bd143a816932..c934ff83874e 100644
--- a/sys/kern/subr_asan.c
+++ b/sys/kern/subr_asan.c
@@ -395,6 +395,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)))
diff --git a/sys/kern/subr_msan.c b/sys/kern/subr_msan.c
index 029c5ed8df96..b596443de2aa 100644
--- a/sys/kern/subr_msan.c
+++ b/sys/kern/subr_msan.c
@@ -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();
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 3815571cd46f..c43d00a223f7 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -568,6 +568,7 @@ enum {
#define TDP2_COMPAT32RB 0x00000002 /* compat32 ABI for robust lists */
#define TDP2_ACCT 0x00000004 /* Doing accounting */
#define TDP2_EFIRT 0x20000000 /* In firmware (EFI RT) call */
+#define TDP2_SAN_QUIET 0x00000008 /* Disable warnings from K(A|M)SAN */
/*
* Reasons that the current thread can not be run yet.