.\" $NetBSD: crashme.9,v 1.5 2021/12/11 23:47:53 riastradh Exp $ .\" .\" Copyright (c) 2019 Matthew R. Green .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .Dd January 7, 2019 .Dt CRASHME 9 .Os .Sh NAME .Nm crashme , .Nm crashme_add , .Nm crashme_remove .Nd in-kernel testing of crash handling .Sh SYNOPSIS .In sys/crashme.h .Ft int .Fn crashme_add "crashme_node *cn" .Ft int .Fn crashme_remove "crashme_node *cn" .Sh DESCRIPTION The .Nm functions provide access to dynamically add and remove crashme nodes. These nodes are simply named callbacks that are expected to cause the system to crash. .Pp The crashme functionality is only available in kernels with the .Xr options 4 .Dv DEBUG option set. .Pp Each crashme node is maintained in a .Vt crashme_node structure which has the following public members: .Bd -literal typedef int (*crashme_fn)(int); typedef struct crashme_node { const char *cn_name; const char *cn_longname; crashme_fn cn_fn; } crashme_node; .Ed .Pp The caller must fill in the .Fa cn_name , .Fa cn_longname , and .Fa cn_fn members. .Pp The .Ar flags parameter is passed from sysctl. The return value is 0 upon success or non zero for failure. .Sh SYSCTL SUPPORT The following .Xr sysctl 8 variables are provided by the .Nm subsystem: .Bl -tag -width Li .It Li debug.crashme_enable Must be set to 1 for any .Nm node to be executed. .El .Pp The following .Xr sysctl 8 nodes trigger crashes in different ways when written: .Bl -tag -width ".Li debug.crashme.null_deref" .It Li debug.crashme.panic Call .Xr panic 9 . .It Li debug.crashme.null_deref Dereference a null pointer. .It Li debug.crashme.null_jump Call a null function pointer, i.e., jump to the instruction address zero. .It Li debug.crashme.ddb Enter .Xr ddb 9 directly by calling .Xr Debugger 9 . Requires .Xr options 4 .Dv DDB . .El .Sh SEE ALSO .Xr options 4 , .Xr panic 9 .Sh HISTORY The .Nm driver appeared in .Nx 9.0 . .Sh AUTHORS .An Matthew R. Green