xref: /freebsd/share/man/man4/netgdb.4 (revision dda17b3672f2c7f661699a69ea4462710a52480d)
1*dda17b36SConrad Meyer.\"-
2*dda17b36SConrad Meyer.\" Copyright (c) 2019 Conrad Meyer <cem@FreeBSD.org>
3*dda17b36SConrad Meyer.\"
4*dda17b36SConrad Meyer.\" Redistribution and use in source and binary forms, with or without
5*dda17b36SConrad Meyer.\" modification, are permitted provided that the following conditions
6*dda17b36SConrad Meyer.\" are met:
7*dda17b36SConrad Meyer.\" 1. Redistributions of source code must retain the above copyright
8*dda17b36SConrad Meyer.\"    notice, this list of conditions and the following disclaimer.
9*dda17b36SConrad Meyer.\" 2. Redistributions in binary form must reproduce the above copyright
10*dda17b36SConrad Meyer.\"    notice, this list of conditions and the following disclaimer in the
11*dda17b36SConrad Meyer.\"    documentation and/or other materials provided with the distribution.
12*dda17b36SConrad Meyer.\"
13*dda17b36SConrad Meyer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14*dda17b36SConrad Meyer.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15*dda17b36SConrad Meyer.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16*dda17b36SConrad Meyer.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17*dda17b36SConrad Meyer.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18*dda17b36SConrad Meyer.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19*dda17b36SConrad Meyer.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20*dda17b36SConrad Meyer.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21*dda17b36SConrad Meyer.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22*dda17b36SConrad Meyer.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23*dda17b36SConrad Meyer.\" SUCH DAMAGE.
24*dda17b36SConrad Meyer.\"
25*dda17b36SConrad Meyer.\" $FreeBSD$
26*dda17b36SConrad Meyer.\"
27*dda17b36SConrad Meyer.Dd October 17, 2019
28*dda17b36SConrad Meyer.Dt NETGDB 4
29*dda17b36SConrad Meyer.Os
30*dda17b36SConrad Meyer.Sh NAME
31*dda17b36SConrad Meyer.Nm netgdb
32*dda17b36SConrad Meyer.Nd protocol for debugging the kernel with GDB over the network
33*dda17b36SConrad Meyer.Sh SYNOPSIS
34*dda17b36SConrad MeyerNetGDB support is compiled by default, if DDB, GDB, and INET are enabled.
35*dda17b36SConrad MeyerTo build a kernel without it, add the following line to your kernel
36*dda17b36SConrad Meyerconfiguration file:
37*dda17b36SConrad Meyer.Bd -ragged -offset indent
38*dda17b36SConrad Meyer.Cd "nooptions NETGDB"
39*dda17b36SConrad Meyer.Ed
40*dda17b36SConrad Meyer.Sh DESCRIPTION
41*dda17b36SConrad Meyer.Nm
42*dda17b36SConrad Meyeris a UDP-based protocol for communicating with a remote GDB client via an
43*dda17b36SConrad Meyerintermediary proxy.
44*dda17b36SConrad Meyer.Pp
45*dda17b36SConrad MeyerA
46*dda17b36SConrad Meyer.Nm
47*dda17b36SConrad Meyersession is started by using the
48*dda17b36SConrad Meyer.Ic netgdb Fl s Ar server Oo Fl g Ar gateway Fl c Ar client Fl i Ar iface Oc
49*dda17b36SConrad Meyercommand in
50*dda17b36SConrad Meyer.Xr ddb 4
51*dda17b36SConrad Meyerto connect to a proxy server.
52*dda17b36SConrad MeyerWhen the connection is made, the proxy server logs a message that a
53*dda17b36SConrad Meyer.Nm
54*dda17b36SConrad Meyerclient has connected.
55*dda17b36SConrad MeyerIt subsequently establishes a TCP listening socket and logs a message
56*dda17b36SConrad Meyerspecifying which port it is listening on.
57*dda17b36SConrad MeyerThen it waits for a GDB client to connect.
58*dda17b36SConrad MeyerThe GDB command to connect is:
59*dda17b36SConrad Meyer.Bd -ragged -offset indent
60*dda17b36SConrad Meyer.Ic target remote Aq Ar proxyip:proxyport
61*dda17b36SConrad Meyer.Ed
62*dda17b36SConrad Meyer.Pp
63*dda17b36SConrad MeyerAt this point, the server proxies traffic back and forth between
64*dda17b36SConrad Meyer.Nm
65*dda17b36SConrad Meyerand the ordinary GDB client, speaking the ordinary GDB remote protocol.
66*dda17b36SConrad MeyerThe
67*dda17b36SConrad Meyer.Nm
68*dda17b36SConrad Meyersession is identical to any other kernel GDB sesssion from the perspective
69*dda17b36SConrad Meyerof the GDB debugger.
70*dda17b36SConrad Meyer.Sh IMPLEMENTATION NOTES
71*dda17b36SConrad MeyerThe UDP protocol is based on the same packet structure and a subset of the
72*dda17b36SConrad Meyerexact same message types as
73*dda17b36SConrad Meyer.Xr netdump 4 .
74*dda17b36SConrad MeyerIt uses the
75*dda17b36SConrad Meyer.Dv HERALD ,
76*dda17b36SConrad Meyer.Dv DATA ( née VMCORE ) ,
77*dda17b36SConrad Meyerand
78*dda17b36SConrad Meyer.Dv FINISHED
79*dda17b36SConrad Meyermessage types.
80*dda17b36SConrad MeyerLike
81*dda17b36SConrad Meyer.Xr netdump 4 ,
82*dda17b36SConrad Meyerthe client's initial
83*dda17b36SConrad Meyer.Dv HERALD
84*dda17b36SConrad Meyermessage is acknowledged from a random source port, and the client sends
85*dda17b36SConrad Meyersubsequent communication to that port.
86*dda17b36SConrad Meyer.Pp
87*dda17b36SConrad MeyerUnlike
88*dda17b36SConrad Meyer.Xr netdump 4 ,
89*dda17b36SConrad Meyerthe initial
90*dda17b36SConrad Meyer.Dv HERALD
91*dda17b36SConrad Meyerport is 20025.
92*dda17b36SConrad MeyerAdditionally,
93*dda17b36SConrad Meyerthe proxy server sends responses to the source port of the client's initial
94*dda17b36SConrad Meyer.Dv HERALD ,
95*dda17b36SConrad Meyerrather than a separate reserved port.
96*dda17b36SConrad Meyer.Nm
97*dda17b36SConrad Meyermessage and acknowledgements are bidirectional.
98*dda17b36SConrad MeyerThe sequence number and acknowledgement protocol is otherwise identical to
99*dda17b36SConrad Meyerthe unidirectional version used by netdump; it just runs in both directions.
100*dda17b36SConrad MeyerAcknowledgements are sent to and from the same addresses and ports as
101*dda17b36SConrad Meyerregular messages.
102*dda17b36SConrad Meyer.Pp
103*dda17b36SConrad MeyerThe first version of the
104*dda17b36SConrad Meyer.Nm
105*dda17b36SConrad Meyerprotocol uses the protocol number
106*dda17b36SConrad Meyer.Dv Sq 0x2515f095
107*dda17b36SConrad Meyerin the 32-bit
108*dda17b36SConrad Meyer.Va aux2
109*dda17b36SConrad Meyerparameter of the initial
110*dda17b36SConrad Meyer.Dv HERALD
111*dda17b36SConrad Meyermessage.
112*dda17b36SConrad Meyer.Pp
113*dda17b36SConrad MeyerThe list of supported network drivers and protocol families is identical to
114*dda17b36SConrad Meyerthat of
115*dda17b36SConrad Meyer.Xr netdump 4 .
116*dda17b36SConrad Meyer.Sh DIAGNOSTICS
117*dda17b36SConrad MeyerThe following variable is available via both
118*dda17b36SConrad Meyer.Xr sysctl 8
119*dda17b36SConrad Meyerand
120*dda17b36SConrad Meyer.Xr loader 8
121*dda17b36SConrad Meyer(as a tunable):
122*dda17b36SConrad Meyer.Bl -tag -width "indent"
123*dda17b36SConrad Meyer.It Va debug.gdb.netgdb.debug
124*dda17b36SConrad MeyerControl debug message verbosity.
125*dda17b36SConrad MeyerDebug messages are disabled by default.
126*dda17b36SConrad MeyerThey may be enabled by setting the variable to a non-zero value.
127*dda17b36SConrad Meyer.El
128*dda17b36SConrad Meyer.Sh SEE ALSO
129*dda17b36SConrad Meyer.Xr ddb 4 ,
130*dda17b36SConrad Meyer.Xr gdb 4 ,
131*dda17b36SConrad Meyer.Xr netdump 4
132*dda17b36SConrad Meyer.Sh HISTORY
133*dda17b36SConrad Meyer.Nm
134*dda17b36SConrad Meyerfirst appeared in
135*dda17b36SConrad Meyer.Fx 13.0 .
136*dda17b36SConrad Meyer.Sh BUGS
137*dda17b36SConrad Meyer.Nm
138*dda17b36SConrad Meyermay only be used after the kernel has panicked, due to limitations in the
139*dda17b36SConrad Meyertreatment of locking primitives under
140*dda17b36SConrad Meyer.Xr ddb 4 .
141*dda17b36SConrad Meyer.Sh SECURITY CONSIDERATIONS
142*dda17b36SConrad MeyerVersion 1 of the
143*dda17b36SConrad Meyer.Nm
144*dda17b36SConrad Meyerprotocol has no security properties whatsoever.
145*dda17b36SConrad MeyerAll messages are sent and acknowledged in cleartext, and no message
146*dda17b36SConrad Meyerauthentication codes are used to prevent attackers from forging messages.
147*dda17b36SConrad MeyerIt is absolutely inappropriate for use across the public internet.
148