Commit Graph

9 Commits

Author SHA1 Message Date
maxv
ca08b3e761 Make copystr() a MI C function, part of libkern and shared on all
architectures.

Notes:

 - On alpha and ia64 the function is kept but gets renamed locally to avoid
   symbol collision. This is because on these two arches, I am not sure
   whether the ASM callers do not rely on fixed registers, so I prefer to
   keep the ASM body for now.
 - On Vax, only the symbol is removed, because the body is used from other
   functions.
 - On RISC-V, this change fixes a bug: copystr() was just a wrapper around
   strlcpy(), but strlcpy() makes the operation less safe (strlen on the
   source beyond its size).
 - The kASan, kCSan and kMSan wrappers are removed, because now that
   copystr() is in C, the compiler transformations are applied to it,
   without the need for manual wrappers.

Could test on amd64 only, but should be fine.
2020-06-30 16:20:00 +00:00
maxv
d8df46ec95 Drop the todo and qualify the accesses. 2020-04-15 17:28:26 +00:00
maxv
a381bde5bc Add a comment. 2020-04-02 16:31:37 +00:00
maxv
890f284aec Add KCSAN instrumentation for atomic_{load,store}_*. 2019-12-01 08:15:58 +00:00
maxv
072e3fce8b Instrument copyout() in kCSan, for parity with kMSan. 2019-11-15 08:11:36 +00:00
maxv
59b172a87d Don't include "opt_kcsan.h" since there's already <sys/csan.h> included. 2019-11-14 16:56:13 +00:00
maxv
b081609ec2 Exclude the PTE space from KCSAN, since there the same VA can point to
different PAs.
2019-11-08 12:36:10 +00:00
maxv
9cce0b0a08 Change kcsan_md_is_avail() to always return true; I was testing with
interrupts disabled as debugging. Change the delay/sample parameters
to have better fluidity.
2019-11-06 06:57:22 +00:00
maxv
b7edd3d132 Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

 - On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
   describing the access, and delay the calling CPU (10ms).

 - On all memory accesses, we verify if the memory we're reading/writing
   is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.
2019-11-05 20:19:17 +00:00