FreeBSD kernel kern code
subr_msan.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bio.h>
#include <sys/buf.h>
#include <sys/conf.h>
#include <sys/kdb.h>
#include <sys/kernel.h>
#include <sys/linker.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/memdesc.h>
#include <sys/msan.h>
#include <sys/proc.h>
#include <sys/stack.h>
#include <sys/sysctl.h>
#include <sys/uio.h>
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/msan.h>
#include <machine/stdarg.h>
#include <machine/atomic.h>
#include <sys/atomic_san.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <sys/bus_san.h>
Include dependency graph for subr_msan.c:

Go to the source code of this file.

Data Structures

struct  msan_meta_t
 
struct  msan_tls_t
 
struct  kmsan_td
 

Macros

#define SAN_RUNTIME
 
#define MSAN_PARAM_SIZE   800
 
#define MSAN_RETVAL_SIZE   800
 
#define MSAN_NCONTEXT   4
 
#define MSAN_ORIG_MASK   (~0x3)
 
#define kmsan_panic(f, ...)
 
#define REPORT(f, ...)
 
#define MSAN_META_FUNC(size)
 
#define _MSAN_ATOMIC_FUNC_ADD(name, type)
 
#define MSAN_ATOMIC_FUNC_ADD(name, type)
 
#define _MSAN_ATOMIC_FUNC_SUBTRACT(name, type)
 
#define MSAN_ATOMIC_FUNC_SUBTRACT(name, type)
 
#define _MSAN_ATOMIC_FUNC_SET(name, type)
 
#define MSAN_ATOMIC_FUNC_SET(name, type)
 
#define _MSAN_ATOMIC_FUNC_CLEAR(name, type)
 
#define MSAN_ATOMIC_FUNC_CLEAR(name, type)
 
#define MSAN_ATOMIC_FUNC_FETCHADD(name, type)
 
#define MSAN_ATOMIC_FUNC_READANDCLEAR(name, type)
 
#define MSAN_ATOMIC_FUNC_TESTANDCLEAR(name, type)
 
#define MSAN_ATOMIC_FUNC_TESTANDSET(name, type)
 
#define MSAN_ATOMIC_FUNC_SWAP(name, type)
 
#define _MSAN_ATOMIC_FUNC_CMPSET(name, type)
 
#define MSAN_ATOMIC_FUNC_CMPSET(name, type)
 
#define _MSAN_ATOMIC_FUNC_FCMPSET(name, type)
 
#define MSAN_ATOMIC_FUNC_FCMPSET(name, type)
 
#define MSAN_ATOMIC_FUNC_THREAD_FENCE(name)
 
#define _MSAN_ATOMIC_FUNC_LOAD(name, type)
 
#define MSAN_ATOMIC_FUNC_LOAD(name, type)
 
#define _MSAN_ATOMIC_FUNC_STORE(name, type)
 
#define MSAN_ATOMIC_FUNC_STORE(name, type)
 
#define MSAN_BUS_READ_FUNC(func, width, type)
 
#define MSAN_BUS_READ_PTR_FUNC(func, width, type)
 
#define MSAN_BUS_WRITE_FUNC(func, width, type)
 
#define MSAN_BUS_WRITE_PTR_FUNC(func, width, type)
 
#define MSAN_BUS_SET_FUNC(func, width, type)
 

Typedefs

typedef struct kmsan_td msan_td_t
 

Functions

 __FBSDID ("$FreeBSD$")
 
void kmsan_init_arg (size_t)
 
void kmsan_init_ret (size_t)
 
static uint8_t msan_dummy_shad[PAGE_SIZE] __aligned (PAGE_SIZE)
 
 FEATURE (kmsan, "Kernel memory sanitizer")
 
static SYSCTL_NODE (_debug, OID_AUTO, kmsan, CTLFLAG_RD|CTLFLAG_MPSAFE, 0, "KMSAN options")
 
 SYSCTL_BOOL (_debug_kmsan, OID_AUTO, panic_on_violation, CTLFLAG_RWTUN, &panic_on_violation, 0, "Panic if an invalid access is detected")
 
static MALLOC_DEFINE (M_KMSAN, "kmsan", "Kernel memory sanitizer")
 
static const char * kmsan_orig_name (int type)
 
static void kmsan_report_hook (const void *addr, size_t size, size_t off, const char *hook)
 
static void kmsan_report_inline (msan_orig_t orig, unsigned long pc)
 
static msan_meta_t kmsan_meta_get (const void *addr, size_t size, const bool write)
 
static void kmsan_origin_fill (const void *addr, msan_orig_t o, size_t size)
 
static void kmsan_shadow_fill (uintptr_t addr, uint8_t c, size_t size)
 
static void kmsan_meta_copy (void *dst, const void *src, size_t size)
 
static void kmsan_shadow_check (uintptr_t addr, size_t size, const char *hook)
 
static void kmsan_check_arg (size_t size, const char *hook)
 
void kmsan_thread_alloc (struct thread *td)
 
void kmsan_thread_free (struct thread *td)
 
void kmsan_intr_enter (void)
 
void kmsan_intr_leave (void)
 
void kmsan_shadow_map (vm_offset_t addr, size_t size)
 
void kmsan_orig (const void *addr, size_t size, int type, uintptr_t pc)
 
void kmsan_mark (const void *addr, size_t size, uint8_t c)
 
void kmsan_mark_bio (const struct bio *bp, uint8_t c)
 
static void kmsan_mark_ccb (const union ccb *ccb, uint8_t c)
 
void kmsan_mark_mbuf (const struct mbuf *m, uint8_t c)
 
void kmsan_check (const void *p, size_t sz, const char *descr)
 
void kmsan_check_bio (const struct bio *bp, const char *descr)
 
void kmsan_check_ccb (const union ccb *ccb, const char *descr)
 
void kmsan_check_mbuf (const struct mbuf *m, const char *descr)
 
void kmsan_init (void)
 
msan_meta_t __msan_metadata_ptr_for_load_n (void *, size_t)
 
msan_meta_t __msan_metadata_ptr_for_store_n (void *, size_t)
 
void __msan_instrument_asm_store (const void *, size_t)
 
msan_orig_t __msan_chain_origin (msan_orig_t)
 
void __msan_poison (const void *, size_t)
 
void __msan_unpoison (const void *, size_t)
 
void __msan_poison_alloca (const void *, uint64_t, const char *)
 
void __msan_unpoison_alloca (const void *, uint64_t)
 
void __msan_warning (msan_orig_t)
 
msan_tls_t__msan_get_context_state (void)
 
void * kmsan_memcpy (void *dst, const void *src, size_t len)
 
int kmsan_memcmp (const void *b1, const void *b2, size_t len)
 
void * kmsan_memset (void *dst, int c, size_t len)
 
void * kmsan_memmove (void *dst, const void *src, size_t len)
 
 __strong_reference (kmsan_memcpy, __msan_memcpy)
 
 __strong_reference (kmsan_memset, __msan_memset)
 
 __strong_reference (kmsan_memmove, __msan_memmove)
 
char * kmsan_strcpy (char *dst, const char *src)
 
int kmsan_strcmp (const char *s1, const char *s2)
 
size_t kmsan_strlen (const char *str)
 
int kmsan_copyin (const void *, void *, size_t)
 
int kmsan_copyout (const void *, void *, size_t)
 
int kmsan_copyinstr (const void *, void *, size_t, size_t *)
 
int kmsan_fubyte (volatile const void *base)
 
int kmsan_fuword16 (volatile const void *base)
 
int kmsan_fueword (volatile const void *base, long *val)
 
int kmsan_fueword32 (volatile const void *base, int32_t *val)
 
int kmsan_fueword64 (volatile const void *base, int64_t *val)
 
int kmsan_subyte (volatile void *base, int byte)
 
int kmsan_suword (volatile void *base, long word)
 
int kmsan_suword16 (volatile void *base, int word)
 
int kmsan_suword32 (volatile void *base, int32_t word)
 
int kmsan_suword64 (volatile void *base, int64_t word)
 
int kmsan_casueword32 (volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp, uint32_t newval)
 
int kmsan_casueword (volatile u_long *base, u_long oldval, u_long *oldvalp, u_long newval)
 
 MSAN_ATOMIC_FUNC_ADD (8, uint8_t)
 
 MSAN_ATOMIC_FUNC_ADD (16, uint16_t)
 
 MSAN_ATOMIC_FUNC_ADD (32, uint32_t)
 
 MSAN_ATOMIC_FUNC_ADD (64, uint64_t)
 
 MSAN_ATOMIC_FUNC_ADD (int, u_int)
 
 MSAN_ATOMIC_FUNC_ADD (long, u_long)
 
 MSAN_ATOMIC_FUNC_ADD (ptr, uintptr_t)
 
 MSAN_ATOMIC_FUNC_SUBTRACT (8, uint8_t)
 
 MSAN_ATOMIC_FUNC_SUBTRACT (16, uint16_t)
 
 MSAN_ATOMIC_FUNC_SUBTRACT (32, uint32_t)
 
 MSAN_ATOMIC_FUNC_SUBTRACT (64, uint64_t)
 
 MSAN_ATOMIC_FUNC_SUBTRACT (int, u_int)
 
 MSAN_ATOMIC_FUNC_SUBTRACT (long, u_long)
 
 MSAN_ATOMIC_FUNC_SUBTRACT (ptr, uintptr_t)
 
 MSAN_ATOMIC_FUNC_SET (8, uint8_t)
 
 MSAN_ATOMIC_FUNC_SET (16, uint16_t)
 
 MSAN_ATOMIC_FUNC_SET (32, uint32_t)
 
 MSAN_ATOMIC_FUNC_SET (64, uint64_t)
 
 MSAN_ATOMIC_FUNC_SET (int, u_int)
 
 MSAN_ATOMIC_FUNC_SET (long, u_long)
 
 MSAN_ATOMIC_FUNC_SET (ptr, uintptr_t)
 
 MSAN_ATOMIC_FUNC_CLEAR (8, uint8_t)
 
 MSAN_ATOMIC_FUNC_CLEAR (16, uint16_t)
 
 MSAN_ATOMIC_FUNC_CLEAR (32, uint32_t)
 
 MSAN_ATOMIC_FUNC_CLEAR (64, uint64_t)
 
 MSAN_ATOMIC_FUNC_CLEAR (int, u_int)
 
 MSAN_ATOMIC_FUNC_CLEAR (long, u_long)
 
 MSAN_ATOMIC_FUNC_CLEAR (ptr, uintptr_t)
 
 MSAN_ATOMIC_FUNC_FETCHADD (32, uint32_t)
 
 MSAN_ATOMIC_FUNC_FETCHADD (64, uint64_t)
 
 MSAN_ATOMIC_FUNC_FETCHADD (int, u_int)
 
 MSAN_ATOMIC_FUNC_FETCHADD (long, u_long)
 
 MSAN_ATOMIC_FUNC_READANDCLEAR (32, uint32_t)
 
 MSAN_ATOMIC_FUNC_READANDCLEAR (64, uint64_t)
 
 MSAN_ATOMIC_FUNC_READANDCLEAR (int, u_int)
 
 MSAN_ATOMIC_FUNC_READANDCLEAR (long, u_long)
 
 MSAN_ATOMIC_FUNC_READANDCLEAR (ptr, uintptr_t)
 
 MSAN_ATOMIC_FUNC_TESTANDCLEAR (32, uint32_t)
 
 MSAN_ATOMIC_FUNC_TESTANDCLEAR (64, uint64_t)
 
 MSAN_ATOMIC_FUNC_TESTANDCLEAR (int, u_int)
 
 MSAN_ATOMIC_FUNC_TESTANDCLEAR (long, u_long)
 
 MSAN_ATOMIC_FUNC_TESTANDSET (32, uint32_t)
 
 MSAN_ATOMIC_FUNC_TESTANDSET (64, uint64_t)
 
 MSAN_ATOMIC_FUNC_TESTANDSET (int, u_int)
 
 MSAN_ATOMIC_FUNC_TESTANDSET (long, u_long)
 
 MSAN_ATOMIC_FUNC_SWAP (32, uint32_t)
 
 MSAN_ATOMIC_FUNC_SWAP (64, uint64_t)
 
 MSAN_ATOMIC_FUNC_SWAP (int, u_int)
 
 MSAN_ATOMIC_FUNC_SWAP (long, u_long)
 
 MSAN_ATOMIC_FUNC_SWAP (ptr, uintptr_t)
 
 MSAN_ATOMIC_FUNC_CMPSET (8, uint8_t)
 
 MSAN_ATOMIC_FUNC_CMPSET (16, uint16_t)
 
 MSAN_ATOMIC_FUNC_CMPSET (32, uint32_t)
 
 MSAN_ATOMIC_FUNC_CMPSET (64, uint64_t)
 
 MSAN_ATOMIC_FUNC_CMPSET (int, u_int)
 
 MSAN_ATOMIC_FUNC_CMPSET (long, u_long)
 
 MSAN_ATOMIC_FUNC_CMPSET (ptr, uintptr_t)
 
 MSAN_ATOMIC_FUNC_FCMPSET (8, uint8_t)
 
 MSAN_ATOMIC_FUNC_FCMPSET (16, uint16_t)
 
 MSAN_ATOMIC_FUNC_FCMPSET (32, uint32_t)
 
 MSAN_ATOMIC_FUNC_FCMPSET (64, uint64_t)
 
 MSAN_ATOMIC_FUNC_FCMPSET (int, u_int)
 
 MSAN_ATOMIC_FUNC_FCMPSET (long, u_long)
 
 MSAN_ATOMIC_FUNC_FCMPSET (ptr, uintptr_t)
 
 MSAN_ATOMIC_FUNC_LOAD (8, uint8_t)
 
 MSAN_ATOMIC_FUNC_LOAD (16, uint16_t)
 
 MSAN_ATOMIC_FUNC_LOAD (32, uint32_t)
 
 MSAN_ATOMIC_FUNC_LOAD (64, uint64_t)
 
 MSAN_ATOMIC_FUNC_LOAD (char, u_char)
 
 MSAN_ATOMIC_FUNC_LOAD (short, u_short)
 
 MSAN_ATOMIC_FUNC_LOAD (int, u_int)
 
 MSAN_ATOMIC_FUNC_LOAD (long, u_long)
 
 MSAN_ATOMIC_FUNC_LOAD (ptr, uintptr_t)
 
 MSAN_ATOMIC_FUNC_STORE (8, uint8_t)
 
 MSAN_ATOMIC_FUNC_STORE (16, uint16_t)
 
 MSAN_ATOMIC_FUNC_STORE (32, uint32_t)
 
 MSAN_ATOMIC_FUNC_STORE (64, uint64_t)
 
 MSAN_ATOMIC_FUNC_STORE (char, u_char)
 
 MSAN_ATOMIC_FUNC_STORE (short, u_short)
 
 MSAN_ATOMIC_FUNC_STORE (int, u_int)
 
 MSAN_ATOMIC_FUNC_STORE (long, u_long)
 
 MSAN_ATOMIC_FUNC_STORE (ptr, uintptr_t)
 
 MSAN_ATOMIC_FUNC_THREAD_FENCE (acq)
 
 MSAN_ATOMIC_FUNC_THREAD_FENCE (rel)
 
 MSAN_ATOMIC_FUNC_THREAD_FENCE (acq_rel)
 
 MSAN_ATOMIC_FUNC_THREAD_FENCE (seq_cst)
 
void kmsan_atomic_interrupt_fence (void)
 
int kmsan_bus_space_map (bus_space_tag_t tag, bus_addr_t hnd, bus_size_t size, int flags, bus_space_handle_t *handlep)
 
void kmsan_bus_space_unmap (bus_space_tag_t tag, bus_space_handle_t hnd, bus_size_t size)
 
int kmsan_bus_space_subregion (bus_space_tag_t tag, bus_space_handle_t hnd, bus_size_t offset, bus_size_t size, bus_space_handle_t *handlep)
 
void kmsan_bus_space_free (bus_space_tag_t tag, bus_space_handle_t hnd, bus_size_t size)
 
void kmsan_bus_space_barrier (bus_space_tag_t tag, bus_space_handle_t hnd, bus_size_t offset, bus_size_t size, int flags)
 
void kmsan_bus_dmamap_sync (struct memdesc *desc, bus_dmasync_op_t op)
 

Variables

static msan_tls_t dummy_tls
 
static msan_td_t msan_thread0
 
static bool kmsan_enabled __read_mostly
 
static bool kmsan_reporting = false
 
static bool panic_on_violation = 1
 

Macro Definition Documentation

◆ _MSAN_ATOMIC_FUNC_ADD

#define _MSAN_ATOMIC_FUNC_ADD (   name,
  type 
)
Value:
void kmsan_atomic_add_##name(volatile type *ptr, type val) \
{ \
kmsan_check_arg(sizeof(ptr) + sizeof(val), \
"atomic_add_" #name "():args"); \
kmsan_shadow_check((uintptr_t)ptr, sizeof(type), \
"atomic_add_" #name "():ptr"); \
atomic_add_##name(ptr, val); \
}
device_property_type_t type
Definition: bus_if.m:941
const char * name
Definition: kern_fail.c:145

Definition at line 1119 of file subr_msan.c.

◆ _MSAN_ATOMIC_FUNC_CLEAR

#define _MSAN_ATOMIC_FUNC_CLEAR (   name,
  type 
)
Value:
void kmsan_atomic_clear_##name(volatile type *ptr, type val) \
{ \
kmsan_check_arg(sizeof(ptr) + sizeof(val), \
"atomic_clear_" #name "():args"); \
kmsan_shadow_check((uintptr_t)ptr, sizeof(type), \
"atomic_clear_" #name "():ptr"); \
atomic_clear_##name(ptr, val); \
}

Definition at line 1164 of file subr_msan.c.

◆ _MSAN_ATOMIC_FUNC_CMPSET

#define _MSAN_ATOMIC_FUNC_CMPSET (   name,
  type 
)
Value:
int kmsan_atomic_cmpset_##name(volatile type *ptr, type oval, \
type nval) \
{ \
kmsan_check_arg(sizeof(ptr) + sizeof(oval) + \
sizeof(nval), "atomic_cmpset_" #name "():args"); \
kmsan_shadow_check((uintptr_t)ptr, sizeof(type), \
"atomic_cmpset_" #name "():ptr"); \
kmsan_init_ret(sizeof(int)); \
return (atomic_cmpset_##name(ptr, oval, nval)); \
}

Definition at line 1234 of file subr_msan.c.

◆ _MSAN_ATOMIC_FUNC_FCMPSET

#define _MSAN_ATOMIC_FUNC_FCMPSET (   name,
  type 
)
Value:
int kmsan_atomic_fcmpset_##name(volatile type *ptr, type *oval, \
type nval) \
{ \
kmsan_check_arg(sizeof(ptr) + sizeof(oval) + \
sizeof(nval), "atomic_fcmpset_" #name "():args"); \
kmsan_shadow_check((uintptr_t)ptr, sizeof(type), \
"atomic_fcmpset_" #name "():ptr"); \
kmsan_init_ret(sizeof(int)); \
return (atomic_fcmpset_##name(ptr, oval, nval)); \
}

Definition at line 1251 of file subr_msan.c.

◆ _MSAN_ATOMIC_FUNC_LOAD

#define _MSAN_ATOMIC_FUNC_LOAD (   name,
  type 
)
Value:
type kmsan_atomic_load_##name(volatile type *ptr) \
{ \
kmsan_check_arg(sizeof(ptr), \
"atomic_load_" #name "():args"); \
kmsan_shadow_check((uintptr_t)ptr, sizeof(type), \
"atomic_load_" #name "():ptr"); \
kmsan_init_ret(sizeof(type)); \
return (atomic_load_##name(ptr)); \
}

Definition at line 1274 of file subr_msan.c.

◆ _MSAN_ATOMIC_FUNC_SET

#define _MSAN_ATOMIC_FUNC_SET (   name,
  type 
)
Value:
void kmsan_atomic_set_##name(volatile type *ptr, type val) \
{ \
kmsan_check_arg(sizeof(ptr) + sizeof(val), \
"atomic_set_" #name "():args"); \
kmsan_shadow_check((uintptr_t)ptr, sizeof(type), \
"atomic_set_" #name "():ptr"); \
atomic_set_##name(ptr, val); \
}

Definition at line 1149 of file subr_msan.c.

◆ _MSAN_ATOMIC_FUNC_STORE

#define _MSAN_ATOMIC_FUNC_STORE (   name,
  type 
)
Value:
void kmsan_atomic_store_##name(volatile type *ptr, type val) \
{ \
kmsan_check_arg(sizeof(ptr) + sizeof(val), \
"atomic_store_" #name "():args"); \
kmsan_shadow_fill((uintptr_t)ptr, KMSAN_STATE_INITED, \
sizeof(type)); \
atomic_store_##name(ptr, val); \
}

Definition at line 1289 of file subr_msan.c.

◆ _MSAN_ATOMIC_FUNC_SUBTRACT

#define _MSAN_ATOMIC_FUNC_SUBTRACT (   name,
  type 
)
Value:
void kmsan_atomic_subtract_##name(volatile type *ptr, type val) \
{ \
kmsan_check_arg(sizeof(ptr) + sizeof(val), \
"atomic_subtract_" #name "():args"); \
kmsan_shadow_check((uintptr_t)ptr, sizeof(type), \
"atomic_subtract_" #name "():ptr"); \
atomic_subtract_##name(ptr, val); \
}

Definition at line 1134 of file subr_msan.c.

◆ kmsan_panic

#define kmsan_panic (   f,
  ... 
)
Value:
do { \
kmsan_enabled = false; \
panic(f, __VA_ARGS__); \
} while (0)

Definition at line 122 of file subr_msan.c.

◆ MSAN_ATOMIC_FUNC_ADD

#define MSAN_ATOMIC_FUNC_ADD (   name,
  type 
)
Value:
_MSAN_ATOMIC_FUNC_ADD(acq_##name, type) \
_MSAN_ATOMIC_FUNC_ADD(rel_##name, type)
#define _MSAN_ATOMIC_FUNC_ADD(name, type)
Definition: subr_msan.c:1119

Definition at line 1129 of file subr_msan.c.

◆ MSAN_ATOMIC_FUNC_CLEAR

#define MSAN_ATOMIC_FUNC_CLEAR (   name,
  type 
)
Value:
_MSAN_ATOMIC_FUNC_CLEAR(acq_##name, type) \
_MSAN_ATOMIC_FUNC_CLEAR(rel_##name, type)
#define _MSAN_ATOMIC_FUNC_CLEAR(name, type)
Definition: subr_msan.c:1164

Definition at line 1174 of file subr_msan.c.

◆ MSAN_ATOMIC_FUNC_CMPSET

#define MSAN_ATOMIC_FUNC_CMPSET (   name,
  type 
)
Value:
_MSAN_ATOMIC_FUNC_CMPSET(acq_##name, type) \
_MSAN_ATOMIC_FUNC_CMPSET(rel_##name, type)
#define _MSAN_ATOMIC_FUNC_CMPSET(name, type)
Definition: subr_msan.c:1234

Definition at line 1246 of file subr_msan.c.

◆ MSAN_ATOMIC_FUNC_FCMPSET

#define MSAN_ATOMIC_FUNC_FCMPSET (   name,
  type 
)
Value:
_MSAN_ATOMIC_FUNC_FCMPSET(acq_##name, type) \
_MSAN_ATOMIC_FUNC_FCMPSET(rel_##name, type)
#define _MSAN_ATOMIC_FUNC_FCMPSET(name, type)
Definition: subr_msan.c:1251

Definition at line 1263 of file subr_msan.c.

◆ MSAN_ATOMIC_FUNC_FETCHADD

#define MSAN_ATOMIC_FUNC_FETCHADD (   name,
  type 
)
Value:
type kmsan_atomic_fetchadd_##name(volatile type *ptr, type val) \
{ \
kmsan_check_arg(sizeof(ptr) + sizeof(val), \
"atomic_fetchadd_" #name "():args"); \
kmsan_shadow_check((uintptr_t)ptr, sizeof(type), \
"atomic_fetchadd_" #name "():ptr"); \
kmsan_init_ret(sizeof(type)); \
return (atomic_fetchadd_##name(ptr, val)); \
}

Definition at line 1179 of file subr_msan.c.

◆ MSAN_ATOMIC_FUNC_LOAD

#define MSAN_ATOMIC_FUNC_LOAD (   name,
  type 
)
Value:
_MSAN_ATOMIC_FUNC_LOAD(acq_##name, type)
#define _MSAN_ATOMIC_FUNC_LOAD(name, type)
Definition: subr_msan.c:1274

Definition at line 1285 of file subr_msan.c.

◆ MSAN_ATOMIC_FUNC_READANDCLEAR

#define MSAN_ATOMIC_FUNC_READANDCLEAR (   name,
  type 
)
Value:
type kmsan_atomic_readandclear_##name(volatile type *ptr) \
{ \
kmsan_check_arg(sizeof(ptr), \
"atomic_readandclear_" #name "():args"); \
kmsan_shadow_check((uintptr_t)ptr, sizeof(type), \
"atomic_readandclear_" #name "():ptr"); \
kmsan_init_ret(sizeof(type)); \
return (atomic_readandclear_##name(ptr)); \
}

Definition at line 1190 of file subr_msan.c.

◆ MSAN_ATOMIC_FUNC_SET

#define MSAN_ATOMIC_FUNC_SET (   name,
  type 
)
Value:
_MSAN_ATOMIC_FUNC_SET(acq_##name, type) \
_MSAN_ATOMIC_FUNC_SET(rel_##name, type)
#define _MSAN_ATOMIC_FUNC_SET(name, type)
Definition: subr_msan.c:1149

Definition at line 1159 of file subr_msan.c.

◆ MSAN_ATOMIC_FUNC_STORE

#define MSAN_ATOMIC_FUNC_STORE (   name,
  type 
)
Value:
_MSAN_ATOMIC_FUNC_STORE(rel_##name, type)
#define _MSAN_ATOMIC_FUNC_STORE(name, type)
Definition: subr_msan.c:1289

Definition at line 1299 of file subr_msan.c.

◆ MSAN_ATOMIC_FUNC_SUBTRACT

#define MSAN_ATOMIC_FUNC_SUBTRACT (   name,
  type 
)
Value:
_MSAN_ATOMIC_FUNC_SUBTRACT(acq_##name, type) \
_MSAN_ATOMIC_FUNC_SUBTRACT(rel_##name, type)
#define _MSAN_ATOMIC_FUNC_SUBTRACT(name, type)
Definition: subr_msan.c:1134

Definition at line 1144 of file subr_msan.c.

◆ MSAN_ATOMIC_FUNC_SWAP

#define MSAN_ATOMIC_FUNC_SWAP (   name,
  type 
)
Value:
type kmsan_atomic_swap_##name(volatile type *ptr, type val) \
{ \
kmsan_check_arg(sizeof(ptr) + sizeof(val), \
"atomic_swap_" #name "():args"); \
kmsan_shadow_check((uintptr_t)ptr, sizeof(type), \
"atomic_swap_" #name "():ptr"); \
kmsan_init_ret(sizeof(type)); \
return (atomic_swap_##name(ptr, val)); \
}

Definition at line 1223 of file subr_msan.c.

◆ MSAN_ATOMIC_FUNC_TESTANDCLEAR

#define MSAN_ATOMIC_FUNC_TESTANDCLEAR (   name,
  type 
)
Value:
int kmsan_atomic_testandclear_##name(volatile type *ptr, u_int v) \
{ \
kmsan_check_arg(sizeof(ptr) + sizeof(v), \
"atomic_testandclear_" #name "():args"); \
kmsan_shadow_check((uintptr_t)ptr, sizeof(type), \
"atomic_testandclear_" #name "():ptr"); \
kmsan_init_ret(sizeof(int)); \
return (atomic_testandclear_##name(ptr, v)); \
}

Definition at line 1201 of file subr_msan.c.

◆ MSAN_ATOMIC_FUNC_TESTANDSET

#define MSAN_ATOMIC_FUNC_TESTANDSET (   name,
  type 
)
Value:
int kmsan_atomic_testandset_##name(volatile type *ptr, u_int v) \
{ \
kmsan_check_arg(sizeof(ptr) + sizeof(v), \
"atomic_testandset_" #name "():args"); \
kmsan_shadow_check((uintptr_t)ptr, sizeof(type), \
"atomic_testandset_" #name "():ptr"); \
kmsan_init_ret(sizeof(int)); \
return (atomic_testandset_##name(ptr, v)); \
}

Definition at line 1212 of file subr_msan.c.

◆ MSAN_ATOMIC_FUNC_THREAD_FENCE

#define MSAN_ATOMIC_FUNC_THREAD_FENCE (   name)
Value:
void kmsan_atomic_thread_fence_##name(void) \
{ \
atomic_thread_fence_##name(); \
}

Definition at line 1268 of file subr_msan.c.

◆ MSAN_BUS_READ_FUNC

#define MSAN_BUS_READ_FUNC (   func,
  width,
  type 
)
Value:
type kmsan_bus_space_read##func##_##width(bus_space_tag_t tag, \
bus_space_handle_t hnd, bus_size_t offset) \
{ \
type ret; \
if ((tag) != X86_BUS_SPACE_IO) \
kmsan_shadow_fill((uintptr_t)(hnd + offset), \
KMSAN_STATE_INITED, (width)); \
ret = bus_space_read##func##_##width(tag, hnd, offset); \
kmsan_init_ret(sizeof(type)); \
return (ret); \
} \

Definition at line 1451 of file subr_msan.c.

◆ MSAN_BUS_READ_PTR_FUNC

#define MSAN_BUS_READ_PTR_FUNC (   func,
  width,
  type 
)
Value:
void kmsan_bus_space_read_##func##_##width(bus_space_tag_t tag, \
bus_space_handle_t hnd, bus_size_t size, type *buf, \
bus_size_t count) \
{ \
kmsan_shadow_fill((uintptr_t)buf, KMSAN_STATE_INITED, \
(width) * count); \
bus_space_read_##func##_##width(tag, hnd, size, buf, \
count); \
}
int * count
Definition: cpufreq_if.m:63
struct stat * buf

Definition at line 1464 of file subr_msan.c.

◆ MSAN_BUS_SET_FUNC

#define MSAN_BUS_SET_FUNC (   func,
  width,
  type 
)
Value:
void kmsan_bus_space_set_##func##_##width(bus_space_tag_t tag, \
bus_space_handle_t hnd, bus_size_t offset, type value, \
bus_size_t count) \
{ \
bus_space_set_##func##_##width(tag, hnd, offset, value, \
count); \
}
caddr_t value
Definition: linker_if.m:63

Definition at line 1539 of file subr_msan.c.

◆ MSAN_BUS_WRITE_FUNC

#define MSAN_BUS_WRITE_FUNC (   func,
  width,
  type 
)
Value:
void kmsan_bus_space_write##func##_##width(bus_space_tag_t tag, \
bus_space_handle_t hnd, bus_size_t offset, type value) \
{ \
bus_space_write##func##_##width(tag, hnd, offset, value);\
} \

Definition at line 1498 of file subr_msan.c.

◆ MSAN_BUS_WRITE_PTR_FUNC

#define MSAN_BUS_WRITE_PTR_FUNC (   func,
  width,
  type 
)
Value:
void kmsan_bus_space_write_##func##_##width(bus_space_tag_t tag,\
bus_space_handle_t hnd, bus_size_t size, const type *buf, \
bus_size_t count) \
{ \
kmsan_shadow_check((uintptr_t)buf, sizeof(type) * count,\
"bus_space_write()"); \
bus_space_write_##func##_##width(tag, hnd, size, buf, \
count); \
}

Definition at line 1505 of file subr_msan.c.

◆ MSAN_META_FUNC

#define MSAN_META_FUNC (   size)
Value:
msan_meta_t __msan_metadata_ptr_for_load_##size(void *); \
msan_meta_t __msan_metadata_ptr_for_load_##size(void *addr) \
{ \
return (kmsan_meta_get(addr, size, false)); \
} \
msan_meta_t __msan_metadata_ptr_for_store_##size(void *); \
msan_meta_t __msan_metadata_ptr_for_store_##size(void *addr) \
{ \
return (kmsan_meta_get(addr, size, true)); \
}
uint64_t * addr
Definition: msi_if.m:89
static msan_meta_t kmsan_meta_get(const void *addr, size_t size, const bool write)
Definition: subr_msan.c:279

Definition at line 692 of file subr_msan.c.

◆ MSAN_NCONTEXT

#define MSAN_NCONTEXT   4

Definition at line 97 of file subr_msan.c.

◆ MSAN_ORIG_MASK

#define MSAN_ORIG_MASK   (~0x3)

Definition at line 98 of file subr_msan.c.

◆ MSAN_PARAM_SIZE

#define MSAN_PARAM_SIZE   800

Definition at line 83 of file subr_msan.c.

◆ MSAN_RETVAL_SIZE

#define MSAN_RETVAL_SIZE   800

Definition at line 84 of file subr_msan.c.

◆ REPORT

#define REPORT (   f,
  ... 
)
Value:
do { \
kmsan_panic(f, __VA_ARGS__); \
} else { \
struct stack st; \
\
stack_save(&st); \
printf(f "\n", __VA_ARGS__); \
stack_print_ddb(&st); \
} \
} while (0)
static struct bt_table st
static bool panic_on_violation
Definition: subr_msan.c:144

Definition at line 127 of file subr_msan.c.

◆ SAN_RUNTIME

#define SAN_RUNTIME

Definition at line 35 of file subr_msan.c.

Typedef Documentation

◆ msan_td_t

typedef struct kmsan_td msan_td_t

Function Documentation

◆ __aligned()

static uint8_t msan_dummy_shad[PAGE_SIZE] __aligned ( PAGE_SIZE  )
static

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ __msan_chain_origin()

msan_orig_t __msan_chain_origin ( msan_orig_t  origin)

Definition at line 725 of file subr_msan.c.

◆ __msan_get_context_state()

msan_tls_t * __msan_get_context_state ( void  )

Definition at line 767 of file subr_msan.c.

References kmsan_td::ctx, dummy_tls, and kmsan_td::tls.

◆ __msan_instrument_asm_store()

void __msan_instrument_asm_store ( const void *  addr,
size_t  size 
)

Definition at line 719 of file subr_msan.c.

References addr, and kmsan_shadow_fill().

Here is the call graph for this function:

◆ __msan_metadata_ptr_for_load_n()

msan_meta_t __msan_metadata_ptr_for_load_n ( void *  addr,
size_t  size 
)

Definition at line 681 of file subr_msan.c.

References addr, and kmsan_meta_get().

Here is the call graph for this function:

◆ __msan_metadata_ptr_for_store_n()

msan_meta_t __msan_metadata_ptr_for_store_n ( void *  addr,
size_t  size 
)

Definition at line 687 of file subr_msan.c.

References addr, and kmsan_meta_get().

Here is the call graph for this function:

◆ __msan_poison()

void __msan_poison ( const void *  addr,
size_t  size 
)

Definition at line 731 of file subr_msan.c.

References addr, and kmsan_shadow_fill().

Here is the call graph for this function:

◆ __msan_poison_alloca()

void __msan_poison_alloca ( const void *  addr,
uint64_t  size,
const char *  descr 
)

Definition at line 743 of file subr_msan.c.

References addr, kmsan_origin_fill(), and kmsan_shadow_fill().

Here is the call graph for this function:

◆ __msan_unpoison()

void __msan_unpoison ( const void *  addr,
size_t  size 
)

Definition at line 737 of file subr_msan.c.

References addr, and kmsan_shadow_fill().

Here is the call graph for this function:

◆ __msan_unpoison_alloca()

void __msan_unpoison_alloca ( const void *  addr,
uint64_t  size 
)

Definition at line 753 of file subr_msan.c.

References addr, and kmsan_shadow_fill().

Here is the call graph for this function:

◆ __msan_warning()

void __msan_warning ( msan_orig_t  origin)

Definition at line 759 of file subr_msan.c.

References kmsan_report_inline().

Here is the call graph for this function:

◆ __strong_reference() [1/3]

__strong_reference ( kmsan_memcpy  ,
__msan_memcpy   
)

◆ __strong_reference() [2/3]

__strong_reference ( kmsan_memmove  ,
__msan_memmove   
)

◆ __strong_reference() [3/3]

__strong_reference ( kmsan_memset  ,
__msan_memset   
)

◆ FEATURE()

FEATURE ( kmsan  ,
"Kernel memory sanitizer"   
)

◆ kmsan_atomic_interrupt_fence()

void kmsan_atomic_interrupt_fence ( void  )

Definition at line 1404 of file subr_msan.c.

◆ kmsan_bus_dmamap_sync()

void kmsan_bus_dmamap_sync ( struct memdesc *  desc,
bus_dmasync_op_t  op 
)

Definition at line 1566 of file subr_msan.c.

References kmsan_check(), kmsan_check_bio(), kmsan_check_ccb(), kmsan_check_mbuf(), kmsan_mark(), kmsan_mark_bio(), kmsan_mark_ccb(), kmsan_mark_mbuf(), and kmsan_panic.

Here is the call graph for this function:

◆ kmsan_bus_space_barrier()

void kmsan_bus_space_barrier ( bus_space_tag_t  tag,
bus_space_handle_t  hnd,
bus_size_t  offset,
bus_size_t  size,
int  flags 
)

Definition at line 1444 of file subr_msan.c.

References flags.

◆ kmsan_bus_space_free()

void kmsan_bus_space_free ( bus_space_tag_t  tag,
bus_space_handle_t  hnd,
bus_size_t  size 
)

Definition at line 1437 of file subr_msan.c.

◆ kmsan_bus_space_map()

int kmsan_bus_space_map ( bus_space_tag_t  tag,
bus_addr_t  hnd,
bus_size_t  size,
int  flags,
bus_space_handle_t *  handlep 
)

Definition at line 1416 of file subr_msan.c.

References flags.

◆ kmsan_bus_space_subregion()

int kmsan_bus_space_subregion ( bus_space_tag_t  tag,
bus_space_handle_t  hnd,
bus_size_t  offset,
bus_size_t  size,
bus_space_handle_t *  handlep 
)

Definition at line 1430 of file subr_msan.c.

◆ kmsan_bus_space_unmap()

void kmsan_bus_space_unmap ( bus_space_tag_t  tag,
bus_space_handle_t  hnd,
bus_size_t  size 
)

Definition at line 1423 of file subr_msan.c.

◆ kmsan_casueword()

int kmsan_casueword ( volatile u_long *  base,
u_long  oldval,
u_long *  oldvalp,
u_long  newval 
)

Definition at line 1100 of file subr_msan.c.

References kmsan_check_arg(), kmsan_init_ret(), and kmsan_shadow_fill().

Here is the call graph for this function:

◆ kmsan_casueword32()

int kmsan_casueword32 ( volatile uint32_t *  base,
uint32_t  oldval,
uint32_t *  oldvalp,
uint32_t  newval 
)

Definition at line 1085 of file subr_msan.c.

References kmsan_check_arg(), kmsan_init_ret(), and kmsan_shadow_fill().

Here is the call graph for this function:

◆ kmsan_check()

void kmsan_check ( const void *  p,
size_t  sz,
const char *  descr 
)

Definition at line 605 of file subr_msan.c.

References kmsan_shadow_check().

Referenced by kmsan_bus_dmamap_sync(), and kmsan_check_ccb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_check_arg()

static void kmsan_check_arg ( size_t  size,
const char *  hook 
)
static

◆ kmsan_check_bio()

void kmsan_check_bio ( const struct bio *  bp,
const char *  descr 
)

Definition at line 611 of file subr_msan.c.

References kmsan_shadow_check().

Referenced by kmsan_bus_dmamap_sync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_check_ccb()

void kmsan_check_ccb ( const union ccb *  ccb,
const char *  descr 
)

Definition at line 617 of file subr_msan.c.

References kmsan_check(), and kmsan_panic.

Referenced by kmsan_bus_dmamap_sync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_check_mbuf()

void kmsan_check_mbuf ( const struct mbuf *  m,
const char *  descr 
)

Definition at line 650 of file subr_msan.c.

References kmsan_shadow_check().

Referenced by kmsan_bus_dmamap_sync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_copyin()

int kmsan_copyin ( const void *  uaddr,
void *  kaddr,
size_t  len 
)

Definition at line 921 of file subr_msan.c.

References kmsan_check_arg(), kmsan_init_ret(), and kmsan_shadow_fill().

Here is the call graph for this function:

◆ kmsan_copyinstr()

int kmsan_copyinstr ( const void *  uaddr,
void *  kaddr,
size_t  len,
size_t *  done 
)

Definition at line 945 of file subr_msan.c.

References kmsan_check_arg(), kmsan_init_ret(), and kmsan_shadow_fill().

Here is the call graph for this function:

◆ kmsan_copyout()

int kmsan_copyout ( const void *  kaddr,
void *  uaddr,
size_t  len 
)

Definition at line 935 of file subr_msan.c.

References kmsan_check_arg(), kmsan_init_ret(), and kmsan_shadow_check().

Here is the call graph for this function:

◆ kmsan_fubyte()

int kmsan_fubyte ( volatile const void *  base)

Definition at line 966 of file subr_msan.c.

References kmsan_check_arg(), and kmsan_init_ret().

Here is the call graph for this function:

◆ kmsan_fueword()

int kmsan_fueword ( volatile const void *  base,
long *  val 
)

Definition at line 988 of file subr_msan.c.

References kmsan_check_arg(), kmsan_init_ret(), and kmsan_shadow_fill().

Here is the call graph for this function:

◆ kmsan_fueword32()

int kmsan_fueword32 ( volatile const void *  base,
int32_t *  val 
)

Definition at line 1002 of file subr_msan.c.

References kmsan_check_arg(), kmsan_init_ret(), and kmsan_shadow_fill().

Here is the call graph for this function:

◆ kmsan_fueword64()

int kmsan_fueword64 ( volatile const void *  base,
int64_t *  val 
)

Definition at line 1016 of file subr_msan.c.

References kmsan_check_arg(), kmsan_init_ret(), and kmsan_shadow_fill().

Here is the call graph for this function:

◆ kmsan_fuword16()

int kmsan_fuword16 ( volatile const void *  base)

Definition at line 977 of file subr_msan.c.

References kmsan_check_arg(), and kmsan_init_ret().

Here is the call graph for this function:

◆ kmsan_init()

void kmsan_init ( void  )

Definition at line 658 of file subr_msan.c.

References kmsan_td::ctx, and msan_thread0.

◆ kmsan_init_arg()

void kmsan_init_arg ( size_t  n)

Definition at line 387 of file subr_msan.c.

References kmsan_td::ctx, msan_tls_t::param_shadow, and kmsan_td::tls.

Referenced by kmsan_thread_alloc(), and kmsan_thread_free().

Here is the caller graph for this function:

◆ kmsan_init_ret()

◆ kmsan_intr_enter()

void kmsan_intr_enter ( void  )

Definition at line 483 of file subr_msan.c.

References kmsan_td::ctx, kmsan_panic, and MSAN_NCONTEXT.

◆ kmsan_intr_leave()

void kmsan_intr_leave ( void  )

Definition at line 497 of file subr_msan.c.

References kmsan_td::ctx, and kmsan_panic.

◆ kmsan_mark()

void kmsan_mark ( const void *  addr,
size_t  size,
uint8_t  c 
)

Definition at line 547 of file subr_msan.c.

References addr, and kmsan_shadow_fill().

Referenced by ast(), fork_exit(), kmsan_bus_dmamap_sync(), kmsan_mark_bio(), kmsan_mark_ccb(), kmsan_mark_mbuf(), kmsan_thread_alloc(), malloc(), and malloc_domainset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_mark_bio()

void kmsan_mark_bio ( const struct bio *  bp,
uint8_t  c 
)

Definition at line 553 of file subr_msan.c.

References kmsan_mark().

Referenced by kmsan_bus_dmamap_sync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_mark_ccb()

static void kmsan_mark_ccb ( const union ccb *  ccb,
uint8_t  c 
)
static

Definition at line 559 of file subr_msan.c.

References kmsan_mark(), and kmsan_panic.

Referenced by kmsan_bus_dmamap_sync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_mark_mbuf()

void kmsan_mark_mbuf ( const struct mbuf *  m,
uint8_t  c 
)

Definition at line 595 of file subr_msan.c.

References kmsan_mark().

Referenced by kmsan_bus_dmamap_sync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_memcmp()

int kmsan_memcmp ( const void *  b1,
const void *  b2,
size_t  len 
)

Definition at line 800 of file subr_msan.c.

References kmsan_check_arg(), kmsan_init_ret(), and kmsan_shadow_check().

Here is the call graph for this function:

◆ kmsan_memcpy()

void * kmsan_memcpy ( void *  dst,
const void *  src,
size_t  len 
)

Definition at line 789 of file subr_msan.c.

References kmsan_init_ret(), kmsan_meta_copy(), and src.

Here is the call graph for this function:

◆ kmsan_memmove()

void * kmsan_memmove ( void *  dst,
const void *  src,
size_t  len 
)

Definition at line 833 of file subr_msan.c.

References kmsan_init_ret(), kmsan_meta_copy(), and src.

Here is the call graph for this function:

◆ kmsan_memset()

void * kmsan_memset ( void *  dst,
int  c,
size_t  len 
)

Definition at line 824 of file subr_msan.c.

References kmsan_init_ret(), and kmsan_shadow_fill().

Referenced by kmsan_thread_alloc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_meta_copy()

static void kmsan_meta_copy ( void *  dst,
const void *  src,
size_t  size 
)
inlinestatic

Definition at line 335 of file subr_msan.c.

References kmsan_shadow_fill(), MSAN_ORIG_MASK, and src.

Referenced by kmsan_memcpy(), and kmsan_memmove().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_meta_get()

static msan_meta_t kmsan_meta_get ( const void *  addr,
size_t  size,
const bool  write 
)
inlinestatic

Definition at line 279 of file subr_msan.c.

References addr, MSAN_ORIG_MASK, msan_meta_t::orig, and msan_meta_t::shad.

Referenced by __msan_metadata_ptr_for_load_n(), and __msan_metadata_ptr_for_store_n().

Here is the caller graph for this function:

◆ kmsan_orig()

void kmsan_orig ( const void *  addr,
size_t  size,
int  type,
uintptr_t  pc 
)

Definition at line 538 of file subr_msan.c.

References addr, kmsan_origin_fill(), and type.

Referenced by malloc(), and malloc_domainset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_orig_name()

static const char * kmsan_orig_name ( int  type)
inlinestatic

Definition at line 154 of file subr_msan.c.

References type.

Referenced by kmsan_report_hook(), and kmsan_report_inline().

Here is the caller graph for this function:

◆ kmsan_origin_fill()

static void kmsan_origin_fill ( const void *  addr,
msan_orig_t  o,
size_t  size 
)
inlinestatic

Definition at line 301 of file subr_msan.c.

References addr, and MSAN_ORIG_MASK.

Referenced by __msan_poison_alloca(), and kmsan_orig().

Here is the caller graph for this function:

◆ kmsan_report_hook()

static void kmsan_report_hook ( const void *  addr,
size_t  size,
size_t  off,
const char *  hook 
)
static

Definition at line 171 of file subr_msan.c.

References addr, buf, kdb_active, kmsan_orig_name(), kmsan_reporting, linker_ddb_search_symbol_name(), MSAN_ORIG_MASK, panicstr, REPORT, and type.

Referenced by kmsan_check_arg(), and kmsan_shadow_check().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_report_inline()

static void kmsan_report_inline ( msan_orig_t  orig,
unsigned long  pc 
)
static

Definition at line 228 of file subr_msan.c.

References buf, kdb_active, kmsan_orig_name(), kmsan_reporting, linker_ddb_search_symbol_name(), panicstr, REPORT, and type.

Referenced by __msan_warning().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_shadow_check()

static void kmsan_shadow_check ( uintptr_t  addr,
size_t  size,
const char *  hook 
)
inlinestatic

Definition at line 367 of file subr_msan.c.

References addr, and kmsan_report_hook().

Referenced by kmsan_check(), kmsan_check_bio(), kmsan_check_mbuf(), kmsan_copyout(), kmsan_memcmp(), kmsan_strcmp(), kmsan_strcpy(), and kmsan_strlen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_shadow_fill()

static void kmsan_shadow_fill ( uintptr_t  addr,
uint8_t  c,
size_t  size 
)
inlinestatic

◆ kmsan_shadow_map()

void kmsan_shadow_map ( vm_offset_t  addr,
size_t  size 
)

Definition at line 513 of file subr_msan.c.

References addr.

◆ kmsan_strcmp()

int kmsan_strcmp ( const char *  s1,
const char *  s2 
)

Definition at line 871 of file subr_msan.c.

References kmsan_check_arg(), kmsan_init_ret(), and kmsan_shadow_check().

Here is the call graph for this function:

◆ kmsan_strcpy()

char * kmsan_strcpy ( char *  dst,
const char *  src 
)

Definition at line 848 of file subr_msan.c.

References kmsan_check_arg(), kmsan_init_ret(), kmsan_shadow_check(), kmsan_shadow_fill(), and src.

Here is the call graph for this function:

◆ kmsan_strlen()

size_t kmsan_strlen ( const char *  str)

Definition at line 898 of file subr_msan.c.

References kmsan_check_arg(), kmsan_init_ret(), and kmsan_shadow_check().

Here is the call graph for this function:

◆ kmsan_subyte()

int kmsan_subyte ( volatile void *  base,
int  byte 
)

Definition at line 1030 of file subr_msan.c.

References kmsan_check_arg(), and kmsan_init_ret().

Here is the call graph for this function:

◆ kmsan_suword()

int kmsan_suword ( volatile void *  base,
long  word 
)

Definition at line 1041 of file subr_msan.c.

References kmsan_check_arg(), and kmsan_init_ret().

Here is the call graph for this function:

◆ kmsan_suword16()

int kmsan_suword16 ( volatile void *  base,
int  word 
)

Definition at line 1052 of file subr_msan.c.

References kmsan_check_arg(), and kmsan_init_ret().

Here is the call graph for this function:

◆ kmsan_suword32()

int kmsan_suword32 ( volatile void *  base,
int32_t  word 
)

Definition at line 1063 of file subr_msan.c.

References kmsan_check_arg(), and kmsan_init_ret().

Here is the call graph for this function:

◆ kmsan_suword64()

int kmsan_suword64 ( volatile void *  base,
int64_t  word 
)

Definition at line 1074 of file subr_msan.c.

References kmsan_check_arg(), and kmsan_init_ret().

Here is the call graph for this function:

◆ kmsan_thread_alloc()

void kmsan_thread_alloc ( struct thread *  td)

Definition at line 439 of file subr_msan.c.

References kmsan_td::ctx, kmsan_init_arg(), kmsan_mark(), kmsan_memset(), and malloc().

Referenced by fork1(), and thread_alloc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kmsan_thread_free()

void kmsan_thread_free ( struct thread *  td)

Definition at line 464 of file subr_msan.c.

References free(), kmsan_init_arg(), and kmsan_panic.

Referenced by thread_free_batched().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_KMSAN  ,
"kmsan"  ,
"Kernel memory sanitizer"   
)
static

◆ MSAN_ATOMIC_FUNC_ADD() [1/7]

MSAN_ATOMIC_FUNC_ADD ( 16  ,
uint16_t   
)

◆ MSAN_ATOMIC_FUNC_ADD() [2/7]

MSAN_ATOMIC_FUNC_ADD ( 32  ,
uint32_t   
)

◆ MSAN_ATOMIC_FUNC_ADD() [3/7]

MSAN_ATOMIC_FUNC_ADD ( 64  ,
uint64_t   
)

◆ MSAN_ATOMIC_FUNC_ADD() [4/7]

MSAN_ATOMIC_FUNC_ADD ( ,
uint8_t   
)

◆ MSAN_ATOMIC_FUNC_ADD() [5/7]

MSAN_ATOMIC_FUNC_ADD ( int  ,
u_int   
)

◆ MSAN_ATOMIC_FUNC_ADD() [6/7]

MSAN_ATOMIC_FUNC_ADD ( long  ,
u_long   
)

◆ MSAN_ATOMIC_FUNC_ADD() [7/7]

MSAN_ATOMIC_FUNC_ADD ( ptr  ,
uintptr_t   
)

◆ MSAN_ATOMIC_FUNC_CLEAR() [1/7]

MSAN_ATOMIC_FUNC_CLEAR ( 16  ,
uint16_t   
)

◆ MSAN_ATOMIC_FUNC_CLEAR() [2/7]

MSAN_ATOMIC_FUNC_CLEAR ( 32  ,
uint32_t   
)

◆ MSAN_ATOMIC_FUNC_CLEAR() [3/7]

MSAN_ATOMIC_FUNC_CLEAR ( 64  ,
uint64_t   
)

◆ MSAN_ATOMIC_FUNC_CLEAR() [4/7]

MSAN_ATOMIC_FUNC_CLEAR ( ,
uint8_t   
)

◆ MSAN_ATOMIC_FUNC_CLEAR() [5/7]

MSAN_ATOMIC_FUNC_CLEAR ( int  ,
u_int   
)

◆ MSAN_ATOMIC_FUNC_CLEAR() [6/7]

MSAN_ATOMIC_FUNC_CLEAR ( long  ,
u_long   
)

◆ MSAN_ATOMIC_FUNC_CLEAR() [7/7]

MSAN_ATOMIC_FUNC_CLEAR ( ptr  ,
uintptr_t   
)

◆ MSAN_ATOMIC_FUNC_CMPSET() [1/7]

MSAN_ATOMIC_FUNC_CMPSET ( 16  ,
uint16_t   
)

◆ MSAN_ATOMIC_FUNC_CMPSET() [2/7]

MSAN_ATOMIC_FUNC_CMPSET ( 32  ,
uint32_t   
)

◆ MSAN_ATOMIC_FUNC_CMPSET() [3/7]

MSAN_ATOMIC_FUNC_CMPSET ( 64  ,
uint64_t   
)

◆ MSAN_ATOMIC_FUNC_CMPSET() [4/7]

MSAN_ATOMIC_FUNC_CMPSET ( ,
uint8_t   
)

◆ MSAN_ATOMIC_FUNC_CMPSET() [5/7]

MSAN_ATOMIC_FUNC_CMPSET ( int  ,
u_int   
)

◆ MSAN_ATOMIC_FUNC_CMPSET() [6/7]

MSAN_ATOMIC_FUNC_CMPSET ( long  ,
u_long   
)

◆ MSAN_ATOMIC_FUNC_CMPSET() [7/7]

MSAN_ATOMIC_FUNC_CMPSET ( ptr  ,
uintptr_t   
)

◆ MSAN_ATOMIC_FUNC_FCMPSET() [1/7]

MSAN_ATOMIC_FUNC_FCMPSET ( 16  ,
uint16_t   
)

◆ MSAN_ATOMIC_FUNC_FCMPSET() [2/7]

MSAN_ATOMIC_FUNC_FCMPSET ( 32  ,
uint32_t   
)

◆ MSAN_ATOMIC_FUNC_FCMPSET() [3/7]

MSAN_ATOMIC_FUNC_FCMPSET ( 64  ,
uint64_t   
)

◆ MSAN_ATOMIC_FUNC_FCMPSET() [4/7]

MSAN_ATOMIC_FUNC_FCMPSET ( ,
uint8_t   
)

◆ MSAN_ATOMIC_FUNC_FCMPSET() [5/7]

MSAN_ATOMIC_FUNC_FCMPSET ( int  ,
u_int   
)

◆ MSAN_ATOMIC_FUNC_FCMPSET() [6/7]

MSAN_ATOMIC_FUNC_FCMPSET ( long  ,
u_long   
)

◆ MSAN_ATOMIC_FUNC_FCMPSET() [7/7]

MSAN_ATOMIC_FUNC_FCMPSET ( ptr  ,
uintptr_t   
)

◆ MSAN_ATOMIC_FUNC_FETCHADD() [1/4]

MSAN_ATOMIC_FUNC_FETCHADD ( 32  ,
uint32_t   
)

◆ MSAN_ATOMIC_FUNC_FETCHADD() [2/4]

MSAN_ATOMIC_FUNC_FETCHADD ( 64  ,
uint64_t   
)

◆ MSAN_ATOMIC_FUNC_FETCHADD() [3/4]

MSAN_ATOMIC_FUNC_FETCHADD ( int  ,
u_int   
)

◆ MSAN_ATOMIC_FUNC_FETCHADD() [4/4]

MSAN_ATOMIC_FUNC_FETCHADD ( long  ,
u_long   
)

◆ MSAN_ATOMIC_FUNC_LOAD() [1/9]

MSAN_ATOMIC_FUNC_LOAD ( 16  ,
uint16_t   
)

◆ MSAN_ATOMIC_FUNC_LOAD() [2/9]

MSAN_ATOMIC_FUNC_LOAD ( 32  ,
uint32_t   
)

◆ MSAN_ATOMIC_FUNC_LOAD() [3/9]

MSAN_ATOMIC_FUNC_LOAD ( 64  ,
uint64_t   
)

◆ MSAN_ATOMIC_FUNC_LOAD() [4/9]

MSAN_ATOMIC_FUNC_LOAD ( ,
uint8_t   
)

◆ MSAN_ATOMIC_FUNC_LOAD() [5/9]

MSAN_ATOMIC_FUNC_LOAD ( char  ,
u_char   
)

◆ MSAN_ATOMIC_FUNC_LOAD() [6/9]

MSAN_ATOMIC_FUNC_LOAD ( int  ,
u_int   
)

◆ MSAN_ATOMIC_FUNC_LOAD() [7/9]

MSAN_ATOMIC_FUNC_LOAD ( long  ,
u_long   
)

◆ MSAN_ATOMIC_FUNC_LOAD() [8/9]

MSAN_ATOMIC_FUNC_LOAD ( ptr  ,
uintptr_t   
)

◆ MSAN_ATOMIC_FUNC_LOAD() [9/9]

MSAN_ATOMIC_FUNC_LOAD ( short  ,
u_short   
)

◆ MSAN_ATOMIC_FUNC_READANDCLEAR() [1/5]

MSAN_ATOMIC_FUNC_READANDCLEAR ( 32  ,
uint32_t   
)

◆ MSAN_ATOMIC_FUNC_READANDCLEAR() [2/5]

MSAN_ATOMIC_FUNC_READANDCLEAR ( 64  ,
uint64_t   
)

◆ MSAN_ATOMIC_FUNC_READANDCLEAR() [3/5]

MSAN_ATOMIC_FUNC_READANDCLEAR ( int  ,
u_int   
)

◆ MSAN_ATOMIC_FUNC_READANDCLEAR() [4/5]

MSAN_ATOMIC_FUNC_READANDCLEAR ( long  ,
u_long   
)

◆ MSAN_ATOMIC_FUNC_READANDCLEAR() [5/5]

MSAN_ATOMIC_FUNC_READANDCLEAR ( ptr  ,
uintptr_t   
)

◆ MSAN_ATOMIC_FUNC_SET() [1/7]

MSAN_ATOMIC_FUNC_SET ( 16  ,
uint16_t   
)

◆ MSAN_ATOMIC_FUNC_SET() [2/7]

MSAN_ATOMIC_FUNC_SET ( 32  ,
uint32_t   
)

◆ MSAN_ATOMIC_FUNC_SET() [3/7]

MSAN_ATOMIC_FUNC_SET ( 64  ,
uint64_t   
)

◆ MSAN_ATOMIC_FUNC_SET() [4/7]

MSAN_ATOMIC_FUNC_SET ( ,
uint8_t   
)

◆ MSAN_ATOMIC_FUNC_SET() [5/7]

MSAN_ATOMIC_FUNC_SET ( int  ,
u_int   
)

◆ MSAN_ATOMIC_FUNC_SET() [6/7]

MSAN_ATOMIC_FUNC_SET ( long  ,
u_long   
)

◆ MSAN_ATOMIC_FUNC_SET() [7/7]

MSAN_ATOMIC_FUNC_SET ( ptr  ,
uintptr_t   
)

◆ MSAN_ATOMIC_FUNC_STORE() [1/9]

MSAN_ATOMIC_FUNC_STORE ( 16  ,
uint16_t   
)

◆ MSAN_ATOMIC_FUNC_STORE() [2/9]

MSAN_ATOMIC_FUNC_STORE ( 32  ,
uint32_t   
)

◆ MSAN_ATOMIC_FUNC_STORE() [3/9]

MSAN_ATOMIC_FUNC_STORE ( 64  ,
uint64_t   
)

◆ MSAN_ATOMIC_FUNC_STORE() [4/9]

MSAN_ATOMIC_FUNC_STORE ( ,
uint8_t   
)

◆ MSAN_ATOMIC_FUNC_STORE() [5/9]

MSAN_ATOMIC_FUNC_STORE ( char  ,
u_char   
)

◆ MSAN_ATOMIC_FUNC_STORE() [6/9]

MSAN_ATOMIC_FUNC_STORE ( int  ,
u_int   
)

◆ MSAN_ATOMIC_FUNC_STORE() [7/9]

MSAN_ATOMIC_FUNC_STORE ( long  ,
u_long   
)

◆ MSAN_ATOMIC_FUNC_STORE() [8/9]

MSAN_ATOMIC_FUNC_STORE ( ptr  ,
uintptr_t   
)

◆ MSAN_ATOMIC_FUNC_STORE() [9/9]

MSAN_ATOMIC_FUNC_STORE ( short  ,
u_short   
)

◆ MSAN_ATOMIC_FUNC_SUBTRACT() [1/7]

MSAN_ATOMIC_FUNC_SUBTRACT ( 16  ,
uint16_t   
)

◆ MSAN_ATOMIC_FUNC_SUBTRACT() [2/7]

MSAN_ATOMIC_FUNC_SUBTRACT ( 32  ,
uint32_t   
)

◆ MSAN_ATOMIC_FUNC_SUBTRACT() [3/7]

MSAN_ATOMIC_FUNC_SUBTRACT ( 64  ,
uint64_t   
)

◆ MSAN_ATOMIC_FUNC_SUBTRACT() [4/7]

MSAN_ATOMIC_FUNC_SUBTRACT ( ,
uint8_t   
)

◆ MSAN_ATOMIC_FUNC_SUBTRACT() [5/7]

MSAN_ATOMIC_FUNC_SUBTRACT ( int  ,
u_int   
)

◆ MSAN_ATOMIC_FUNC_SUBTRACT() [6/7]

MSAN_ATOMIC_FUNC_SUBTRACT ( long  ,
u_long   
)

◆ MSAN_ATOMIC_FUNC_SUBTRACT() [7/7]

MSAN_ATOMIC_FUNC_SUBTRACT ( ptr  ,
uintptr_t   
)

◆ MSAN_ATOMIC_FUNC_SWAP() [1/5]

MSAN_ATOMIC_FUNC_SWAP ( 32  ,
uint32_t   
)

◆ MSAN_ATOMIC_FUNC_SWAP() [2/5]

MSAN_ATOMIC_FUNC_SWAP ( 64  ,
uint64_t   
)

◆ MSAN_ATOMIC_FUNC_SWAP() [3/5]

MSAN_ATOMIC_FUNC_SWAP ( int  ,
u_int   
)

◆ MSAN_ATOMIC_FUNC_SWAP() [4/5]

MSAN_ATOMIC_FUNC_SWAP ( long  ,
u_long   
)

◆ MSAN_ATOMIC_FUNC_SWAP() [5/5]

MSAN_ATOMIC_FUNC_SWAP ( ptr  ,
uintptr_t   
)

◆ MSAN_ATOMIC_FUNC_TESTANDCLEAR() [1/4]

MSAN_ATOMIC_FUNC_TESTANDCLEAR ( 32  ,
uint32_t   
)

◆ MSAN_ATOMIC_FUNC_TESTANDCLEAR() [2/4]

MSAN_ATOMIC_FUNC_TESTANDCLEAR ( 64  ,
uint64_t   
)

◆ MSAN_ATOMIC_FUNC_TESTANDCLEAR() [3/4]

MSAN_ATOMIC_FUNC_TESTANDCLEAR ( int  ,
u_int   
)

◆ MSAN_ATOMIC_FUNC_TESTANDCLEAR() [4/4]

MSAN_ATOMIC_FUNC_TESTANDCLEAR ( long  ,
u_long   
)

◆ MSAN_ATOMIC_FUNC_TESTANDSET() [1/4]

MSAN_ATOMIC_FUNC_TESTANDSET ( 32  ,
uint32_t   
)

◆ MSAN_ATOMIC_FUNC_TESTANDSET() [2/4]

MSAN_ATOMIC_FUNC_TESTANDSET ( 64  ,
uint64_t   
)

◆ MSAN_ATOMIC_FUNC_TESTANDSET() [3/4]

MSAN_ATOMIC_FUNC_TESTANDSET ( int  ,
u_int   
)

◆ MSAN_ATOMIC_FUNC_TESTANDSET() [4/4]

MSAN_ATOMIC_FUNC_TESTANDSET ( long  ,
u_long   
)

◆ MSAN_ATOMIC_FUNC_THREAD_FENCE() [1/4]

MSAN_ATOMIC_FUNC_THREAD_FENCE ( acq  )

◆ MSAN_ATOMIC_FUNC_THREAD_FENCE() [2/4]

MSAN_ATOMIC_FUNC_THREAD_FENCE ( acq_rel  )

◆ MSAN_ATOMIC_FUNC_THREAD_FENCE() [3/4]

MSAN_ATOMIC_FUNC_THREAD_FENCE ( rel  )

◆ MSAN_ATOMIC_FUNC_THREAD_FENCE() [4/4]

MSAN_ATOMIC_FUNC_THREAD_FENCE ( seq_cst  )

◆ SYSCTL_BOOL()

SYSCTL_BOOL ( _debug_kmsan  ,
OID_AUTO  ,
panic_on_violation  ,
CTLFLAG_RWTUN  ,
panic_on_violation,
,
"Panic if an invalid access is detected"   
)

◆ SYSCTL_NODE()

static SYSCTL_NODE ( _debug  ,
OID_AUTO  ,
kmsan  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
,
"KMSAN options"   
)
static

Variable Documentation

◆ __read_mostly

bool kmsan_enabled __read_mostly
static

Definition at line 115 of file subr_msan.c.

◆ dummy_tls

msan_tls_t dummy_tls
static

Definition at line 105 of file subr_msan.c.

Referenced by __msan_get_context_state().

◆ kmsan_reporting

bool kmsan_reporting = false
static

Definition at line 117 of file subr_msan.c.

Referenced by kmsan_report_hook(), and kmsan_report_inline().

◆ msan_thread0

msan_td_t msan_thread0
static

Definition at line 114 of file subr_msan.c.

Referenced by kmsan_init().

◆ panic_on_violation

bool panic_on_violation = 1
static

Definition at line 144 of file subr_msan.c.