Page MenuHomeFreeBSD

D30126.id88683.diff
No OneTemporary

D30126.id88683.diff

Index: sys/sys/cdefs.h
===================================================================
--- sys/sys/cdefs.h
+++ sys/sys/cdefs.h
@@ -863,12 +863,18 @@
#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis)
/*
- * Function or variable should not be sanitized, i.e. by AddressSanitizer.
+ * Function or variable should not be sanitized, e.g., by AddressSanitizer.
* GCC has the nosanitize attribute, but as a function attribute only, and
* warns on use as a variable attribute.
*/
#if __has_attribute(no_sanitize) && defined(__clang__)
+#ifdef _KERNEL
+#define __nosanitizeaddress __attribute__((no_sanitize("kernel-address")))
+#define __nosanitizememory __attribute__((no_sanitize("kernel-memory")))
+#else
#define __nosanitizeaddress __attribute__((no_sanitize("address")))
+#define __nosanitizememory __attribute__((no_sanitize("memory")))
+#endif
#define __nosanitizethread __attribute__((no_sanitize("thread")))
#else
#define __nosanitizeaddress
Index: sys/sys/linker_set.h
===================================================================
--- sys/sys/linker_set.h
+++ sys/sys/linker_set.h
@@ -59,12 +59,23 @@
* Private macros, not to be used outside this header file.
*/
#ifdef __GNUCLIKE___SECTION
+
+/*
+ * The userspace address sanitizer inserts redzones around global variables,
+ * violating the assumption that linker set elements are packed.
+ */
+#ifdef _KERNEL
+#define __NOASAN
+#else
+#define __NOASAN __nosanitizeaddress
+#endif
+
#define __MAKE_SET_QV(set, sym, qv) \
__WEAK(__CONCAT(__start_set_,set)); \
__WEAK(__CONCAT(__stop_set_,set)); \
static void const * qv \
+ __NOASAN \
__set_##set##_sym_##sym __section("set_" #set) \
- __nosanitizeaddress \
__used = &(sym)
#define __MAKE_SET(set, sym) __MAKE_SET_QV(set, sym, __MAKE_SET_CONST)
#else /* !__GNUCLIKE___SECTION */
Index: sys/x86/x86/stack_machdep.c
===================================================================
--- sys/x86/x86/stack_machdep.c
+++ sys/x86/x86/stack_machdep.c
@@ -70,7 +70,7 @@
MTX_SYSINIT(intr_lock, &intr_lock, "stack intr", MTX_DEF);
#endif
-static void
+static void __nosanitizeaddress
stack_capture(struct thread *td, struct stack *st, register_t fp)
{
x86_frame_t frame;

File Metadata

Mime Type
text/plain
Expires
Sun, Jul 12, 2:27 PM (17 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34999101
Default Alt Text
D30126.id88683.diff (2 KB)

Event Timeline