OpenBSD/src ovaMC0Csys/dev kcov.c

   Make kcov MP-safe. Calling the injected tracing function
   __sanitizer_cov_trace_pc() early in the boot process caused a subtle
   crash while booting the secondary CPU(s). On amd64, accessing curcpu
   during this period is not safe since its GSBASE register is yet not
   written. After the CPU has been booted curproc can also be NULL for a
   brief period of time before the idle thread tied to the same CPU has
   started. The two problems can simply be avoided by postponing access to
   curcpu and curproc until /dev/kcov has been opened at least once.

   The end goal here is to allow fuzzing of MP kernels, which already is in
   full swing.

   This work has gone through many iterations before settling on the least
   intrusive change; many thanks for visa@ for reviewing and providing
   valuable input.

   Issue originally reported by Greg Steuck on tech@ who also took the time
   to test all iterations and providing me access to a virtualised OpenBSD
   machine for easier testing.

   ok mpi@ visa@
VersionDeltaFile
1.5+12-4sys/dev/kcov.c
+12-41 files

UnifiedSplitRaw