xref: /freebsd/sbin/dumpon/dumpon.8 (revision 8ccc0d235c226d84112561d453c49904398d085c)
1.\" Copyright (c) 1980, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd November 6, 2025
29.Dt DUMPON 8
30.Os
31.Sh NAME
32.Nm dumpon
33.Nd "specify a device for crash dumps"
34.Sh SYNOPSIS
35.Nm
36.Op Fl i Ar index
37.Op Fl r
38.Op Fl v
39.Op Fl C Ar cipher
40.Op Fl k Ar pubkey
41.Op Fl Z
42.Op Fl z
43.Ar device
44.Nm
45.Op Fl i Ar index
46.Op Fl r
47.Op Fl v
48.Op Fl C Ar cipher
49.Op Fl k Ar pubkey
50.Op Fl Z
51.Op Fl z
52.Op Fl g Ar gateway
53.Fl s Ar server
54.Fl c Ar client
55.Ar iface
56.Nm
57.Op Fl v
58.Cm off
59.Nm
60.Op Fl v
61.Fl l
62.Sh DESCRIPTION
63The
64.Nm
65utility is used to configure where the kernel can save a crash dump in the case
66of a panic.
67.Pp
68System administrators should typically configure
69.Nm
70in a persistent fashion using the
71.Xr rc.conf 5
72variables
73.Va dumpdev
74and
75.Va dumpon_flags .
76For more information on this usage, see
77.Xr rc.conf 5 .
78.Pp
79Starting in
80.Fx 13.0 ,
81.Nm
82can configure a series of fallback dump devices.
83For example, an administrator may prefer
84.Xr netdump 4
85by default, but if the
86.Xr netdump 4
87service cannot be reached or some other failure occurs, they might choose a
88local disk dump as a second choice option.
89.Ss General options
90.Bl -tag -width _k_pubkey
91.It Fl i Ar index
92Insert the specified dump configuration into the prioritized fallback dump
93device list at the specified index, starting at zero.
94.Pp
95If
96.Fl i
97is not specified, the configured dump device is appended to the prioritized
98list.
99.It Fl r
100Remove the specified dump device configuration or configurations from the
101fallback dump device list rather than inserting or appending it.
102In contrast,
103.Do
104.Nm
105off
106.Dc
107removes all configured devices.
108Conflicts with
109.Fl i .
110.It Fl k Ar pubkey
111Configure encrypted kernel dumps.
112.Pp
113A random, one-time symmetric key is automatically generated for bulk kernel
114dump encryption every time
115.Nm
116is used.
117The provided
118.Ar pubkey
119is used to encrypt a copy of the symmetric key.
120The encrypted dump contents consist of a standard dump header, the
121pubkey-encrypted symmetric key contents, and the symmetric key encrypted core
122dump contents.
123.Pp
124As a result, only someone with the corresponding private key can decrypt the symmetric key.
125The symmetric key is necessary to decrypt the kernel core.
126The goal of the mechanism is to provide confidentiality.
127.Pp
128The
129.Va pubkey
130file should be a PEM-formatted RSA key of at least 2048 bits.
131.It Fl C Ar cipher
132Select the symmetric algorithm used for encrypted kernel crash dump.
133The default is
134.Dq chacha20
135but
136.Dq aes256-cbc
137is also available.
138(AES256-CBC mode does not work in conjunction with compression.)
139.It Fl l
140List the currently configured dump device(s), or /dev/null if no devices are
141configured.
142.It Fl v
143Enable verbose mode.
144.It Fl Z
145Enable compression (Zstandard).
146.It Fl z
147Enable compression (gzip).
148Only one compression method may be enabled at a time, so
149.Fl z
150is incompatible with
151.Fl Z .
152.Pp
153Zstandard provides superior compression ratio and performance.
154.El
155.Ss Netdump
156.Nm
157may also configure the kernel to dump to a remote
158.Xr netdumpd 8
159server.
160(The
161.Xr netdumpd 8
162server is available in ports.)
163.Xr netdump 4
164eliminates the need to reserve space for crash dumps.
165It is especially useful in diskless environments.
166When
167.Nm
168is used to configure netdump, the
169.Ar device
170(or
171.Ar iface )
172parameter should specify a network interface (e.g.,
173.Va igb1 ) .
174The specified NIC must be up (online) to configure netdump.
175.Pp
176.Xr netdump 4
177specific options include:
178.Bl -tag -width _g_gateway
179.It Fl c Ar client
180The local IP address of the
181.Xr netdump 4
182client.
183.It Fl g Ar gateway
184The first-hop router between
185.Ar client
186and
187.Ar server .
188If the
189.Fl g
190option is not specified and the system has a default route, the default
191router is used as the
192.Xr netdump 4
193gateway.
194If the
195.Fl g
196option is not specified and the system does not have a default route,
197.Ar server
198is assumed to be on the same link as
199.Ar client .
200.It Fl s Ar server
201The IP address of the
202.Xr netdumpd 8
203server.
204.El
205.Pp
206All of these options can be specified in the
207.Xr rc.conf 5
208variable
209.Va dumpon_flags .
210.Ss Minidumps
211The default type of kernel crash dump is the mini crash dump.
212Mini crash dumps hold only memory pages in use by the kernel.
213Alternatively, full memory dumps can be enabled by setting the
214.Va debug.minidump
215.Xr sysctl 8
216variable to 0.
217.Ss Full dumps
218For systems using full memory dumps, the size of the specified dump
219device must be at least the size of physical memory.
220Even though an additional 64 kB header is added to the dump, the BIOS for a
221platform typically holds back some memory, so it is not usually
222necessary to size the dump device larger than the actual amount of RAM
223available in the machine.
224Also, when using full memory dumps, the
225.Nm
226utility will refuse to enable a dump device which is smaller than the
227total amount of physical memory as reported by the
228.Va hw.physmem
229.Xr sysctl 8
230variable.
231.Sh SYSCTL VARIABLES
232The following
233.Xr sysctl 8
234variables can be used to modify or monitor the behavior of crash dumps:
235.Bl -tag -width "machdep.dump_retry_count"
236.It Va debug.minidump
237Set the type of kernel crash dump.
238Possible values are 0 for a full crash dump or 1 for a minidump.
239The default is minidump.
240.It Va machdep.dump_retry_count
241The maximum number of times dump will retry before giving up.
242The default value is 5.
243This sysctl is only supported on PowerPC and AMD64.
244.El
245.Sh IMPLEMENTATION NOTES
246Because the file system layer is already dead by the time a crash dump
247is taken, it is not possible to send crash dumps directly to a file.
248.Pp
249The
250.Xr loader 8
251variable
252.Va dumpdev
253may be used to enable early kernel core dumps for system panics which occur
254before userspace starts.
255.Sh EXAMPLES
256In order to generate an RSA private key, a user can use the
257.Xr genrsa 1
258tool:
259.Pp
260.Dl # openssl genrsa -out private.pem 4096
261.Pp
262A public key can be extracted from the private key using the
263.Xr rsa 1
264tool:
265.Pp
266.Dl # openssl rsa -in private.pem -out public.pem -pubout
267.Pp
268Once the RSA keys are created in a safe place, the public key may be moved to
269the untrusted netdump client machine.
270Now
271.Pa public.pem
272can be used by
273.Nm
274to configure encrypted kernel crash dumps:
275.Pp
276.Dl # dumpon -k public.pem /dev/ada0s1b
277.Pp
278It is recommended to test if the kernel saves encrypted crash dumps using the
279current configuration.
280The easiest way to do that is to cause a kernel panic using the
281.Xr ddb 4
282debugger:
283.Pp
284.Dl # sysctl debug.kdb.panic=1
285.Pp
286In the debugger the following commands should be typed to write a core dump and
287reboot:
288.Pp
289.Dl db> dump
290.Dl db> reset
291.Pp
292After reboot
293.Xr savecore 8
294should be able to save the core dump in the
295.Va Dq dumpdir
296directory, which is
297.Pa /var/crash
298by default:
299.Pp
300.Dl # savecore /dev/ada0s1b
301.Pp
302Three files should be created in the core directory:
303.Pa info.# ,
304.Pa key.#
305and
306.Pa vmcore_encrypted.#
307(where
308.Dq #
309is the number of the last core dump saved by
310.Xr savecore 8 ) .
311The
312.Pa vmcore_encrypted.#
313can be decrypted using the
314.Xr decryptcore 8
315utility:
316.Pp
317.Dl # decryptcore -p private.pem -k key.# -e vmcore_encrypted.# -c vmcore.#
318.Pp
319or shorter:
320.Pp
321.Dl # decryptcore -p private.pem -n #
322.Pp
323The
324.Pa vmcore.#
325can be now examined using
326.Xr kgdb 1 Pq Pa ports/devel/gdb :
327.Pp
328.Dl # kgdb /boot/kernel/kernel vmcore.#
329.Pp
330or shorter:
331.Pp
332.Dl # kgdb -n #
333.Pp
334The core was decrypted properly if
335.Xr kgdb 1 Pq Pa ports/devel/gdb
336does not print any errors.
337Note that the live kernel might be at a different path
338which can be examined by looking at the
339.Va kern.bootfile
340.Xr sysctl 8 .
341.Pp
342The
343.Nm
344.Xr rc 8
345script runs early during boot, typically before networking is configured.
346This makes it unsuitable for configuring
347.Xr netdump 4
348when the client address is dynamic.
349To configure
350.Xr netdump 4
351when
352.Xr dhclient 8
353binds to a server,
354.Xr dhclient-script 8
355can be used to run
356.Nm .
357For example, to automatically configure
358.Xr netdump 4
359on the vtnet0 interface, add the following to
360.Pa /etc/dhclient-exit-hooks .
361.Bd -literal
362case $reason in
363BOUND|REBIND|REBOOT|RENEW)
364	if [ "$interface" != vtnet0 ] || [ -n "$old_ip_address" -a \\
365	     "$old_ip_address" = "$new_ip_address" ]; then
366		break
367	fi
368	if [ -n "$new_routers" ]; then
369		# Take the first router in the list.
370		gateway_flag="-g ${new_routers%% *}"
371	fi
372	# Configure as the highest-priority dump device.
373	dumpon -i 0 -c $new_ip_address -s $server $gateway_flag vtnet0
374	;;
375esac
376.Ed
377.Pp
378Be sure to fill in the server IP address and change the interface name if
379needed.
380.Sh SEE ALSO
381.Xr gzip 1 ,
382.Xr kgdb 1 Pq Pa ports/devel/gdb ,
383.Xr zstd 1 ,
384.Xr ddb 4 ,
385.Xr netdump 4 ,
386.Xr fstab 5 ,
387.Xr rc.conf 5 ,
388.Xr config 8 ,
389.Xr decryptcore 8 ,
390.Xr init 8 ,
391.Xr loader 8 ,
392.Xr rc 8 ,
393.Xr savecore 8 ,
394.Xr sysctl 8 ,
395.Xr swapon 8 ,
396.Xr panic 9
397.Sh HISTORY
398The
399.Nm
400utility appeared in
401.Fx 2.0.5 .
402.Pp
403Support for encrypted kernel core dumps and netdump was added in
404.Fx 12.0 .
405.Sh AUTHORS
406The
407.Nm
408manual page was written by
409.An Mark Johnston Aq Mt markj@FreeBSD.org ,
410.An Conrad Meyer Aq Mt cem@FreeBSD.org ,
411.An Konrad Witaszczyk Aq Mt def@FreeBSD.org ,
412and countless others.
413.Sh CAVEATS
414To configure encrypted kernel core dumps, the running kernel must have been
415compiled with the
416.Dv EKCD
417option.
418.Pp
419Netdump does not automatically update the configured
420.Ar gateway
421if routing topology changes.
422.Pp
423The size of a compressed dump or a minidump is not a fixed function of RAM
424size.
425Therefore, when at least one of these options is enabled, the
426.Nm
427utility cannot verify that the
428.Ar device
429has sufficient space for a dump.
430.Nm
431is also unable to verify that a configured
432.Xr netdumpd 8
433server has sufficient space for a dump.
434.Pp
435.Fl Z
436requires a kernel compiled with the
437.Dv ZSTDIO
438kernel option.
439Similarly,
440.Fl z
441requires the
442.Dv GZIO
443option.
444.Sh BUGS
445Netdump only supports IPv4 at this time.
446.Sh SECURITY CONSIDERATIONS
447The current encrypted kernel core dump scheme does not provide integrity nor
448authentication.
449That is, the recipient of an encrypted kernel core dump cannot know if they
450received an intact core dump, nor can they verify the provenance of the dump.
451.Pp
452RSA keys smaller than 1024 bits are practical to factor and therefore weak.
453Even 1024 bit keys may not be large enough to ensure privacy for many
454years, so NIST recommends a minimum of 2048 bit RSA keys.
455As a seatbelt,
456.Nm
457prevents users from configuring encrypted kernel dumps with extremely weak RSA
458keys.
459If you do not care for cryptographic privacy guarantees, just use
460.Nm
461without specifying a
462.Fl k Ar pubkey
463option.
464.Pp
465This process is sandboxed using
466.Xr capsicum 4 .
467