aboutsummaryrefslogtreecommitdiffstats
path: root/sbin/savecore
Commit message (Collapse)AuthorAgeFilesLines
* savecore: bail on write error even when decompressingRyan Libby2020-12-111-9/+16
| | | | | | | | | Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D27560 Notes: svn path=/head/; revision=368568
* Add '-u' switch that would uncompress cores that were compressed byGleb Smirnoff2020-11-193-56/+173
| | | | | | | | | | | | | | | | | | | kernel during dump time. A real life scenario is that cores are compressed to reduce size of dumpon partition, but we either don't care about space in the /var/crash or we have a filesystem level compression of /var/crash. And we want cores to be uncompressed in /var/crash because we'd like to instantily read them with kgdb. In this case we want kernel to write cores compressed, but savecore(1) write them uncompressed. Reviewed by: markj, gallatin Relnotes: yes Differential Revision: https://reviews.freebsd.org/D27245 Notes: svn path=/head/; revision=367824
* Style, not functional changes:Gleb Smirnoff2020-11-031-7/+7
| | | | | | | | | | - Improve spelling of a false check [1] - A missing line from r367150. Submitted by: kib Notes: svn path=/head/; revision=367307
* Convert flags from int to bool. Some (compress) were already used inGleb Smirnoff2020-10-291-12/+14
| | | | | | | comparisons with bool values. No functional changes. Notes: svn path=/head/; revision=367150
* savecore: accept device names without the /dev/ prefixAlan Somers2020-06-291-3/+44
| | | | | | | | | | | | | | | | | dumpon has accepted device names without the prefix ever since r291207. Since dumpon and savecore are always paired, they ought to accept the same arguments. Prior to this change, specifying 'dumpdev="da3"' in /etc/rc.conf, for example, would result in dumpon working just fine but savecore complaining that "Dump device does not exist". PR: 247618 Reviewed by: cem, bcr MFC after: 2 weeks Sponsored by: Axcient Differential Revision: https://reviews.freebsd.org/D25500 Notes: svn path=/head/; revision=362790
* savecore: include time zone in info.N fileEric van Gyzen2020-01-131-1/+6
| | | | | | | | | | | | | This helps with event correlation when machines are distributed across multiple time zones. Format the time with relaxed ISO 8601 for all the usual reasons. MFC after: 2 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=356706
* Update Makefile.depend filesSimon J. Gerraty2019-12-111-1/+2
| | | | | | | | | | | | | Update a bunch of Makefile.depend files as a result of adding Makefile.depend.options files Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22494 Notes: svn path=/head/; revision=355617
* Add Makefile.depend.optionsSimon J. Gerraty2019-12-111-0/+10
| | | | | | | | | | | | | | | | | | | | Leaf directories that have dependencies impacted by options need a Makefile.depend.options file to avoid churn in Makefile.depend DIRDEPS for cases such as OPENSSL, TCP_WRAPPERS etc can be set in local.dirdeps-options.mk which can add to those set in Makefile.depend.options See share/mk/dirdeps-options.mk Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22469 Notes: svn path=/head/; revision=355616
* cap_fileargs: chase r346315, update fileargs_init in consumersEd Maste2019-04-171-1/+1
| | | | | | | | | | Reported by: ci.freebsd.org (8 times so far) MFC after: 3 weeks MFC with: r346315 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=346316
* Disable savecore(8)'s libcasper support when WITHOUT_DYNAMICROOT=yes.Mark Johnston2019-01-041-1/+3
| | | | | | | | | | | This follows the example of other Capsicumized programs in /sbin. Reported by: Manfred Antar <manfredantar@gmail.com> MFC with: r342699 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=342776
* Fix an error check after r342699.Mark Johnston2019-01-021-1/+1
| | | | | | | | | Reported by: gcc MFC with: r342699 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=342701
* Capsicumize savecore(8).Mark Johnston2019-01-022-163/+309
| | | | | | | | | | | | | | | - Use cap_fileargs(3) to open dump devices after entering capability mode, and use cap_syslog(3) to log messages. - Use a relative directory fd to open output files. - Use zdopen(3) to compress kernel dumps in capability mode. Reviewed by: cem, oshogbo MFC after: 2 months Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D18458 Notes: svn path=/head/; revision=342699
* Restore /var/crash permissions to 0750, as declared in mtree file. AfterRenato Botelho2018-12-041-1/+3
| | | | | | | | | | | | | r337337 it changed to 0755. Reviewed by: loos Approved by: loos MFC after: 3 days Sponsored by: Rubicon Communications, LLC (Netgate) Differential Revision: https://reviews.freebsd.org/D18355 Notes: svn path=/head/; revision=341464
* Move etc/minfree to sbin/savecore/.Brad Davis2018-08-042-0/+3
| | | | | | | | | | This is prep for pkgbase to have config files tagged as such. Approved by: will (mentor) Differential Revision: https://reviews.freebsd.org/D16558 Notes: svn path=/head/; revision=337337
* The extension for zstd-compressed files is ".zst".Mark Johnston2018-05-291-1/+1
| | | | | | | Reported by: manu Notes: svn path=/head/; revision=334339
* Bump .Dd after r331113.Edward Tomasz Napierala2018-03-271-1/+1
| | | | | | | | Reported by: oshogbo@ MFC after: 2 weeks Notes: svn path=/head/; revision=331624
* Xr crashinfo(8) from savecore(8).Edward Tomasz Napierala2018-03-171-0/+1
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=331113
* Prevent savecore from reading bounds from the current directory.Mike Silbersack2018-02-161-0/+7
| | | | | | | | | | | | | | | | Rev 244218 removed the requirement that you provide a dump directory when checking if there is a coredump ready to be written. That had the side-effect of causing the bounds file to be read from the current working directory instead of the dump directory. As the bounds file is irrelevant when just checking, the simplest fix is to not read the bounds file when checking. Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D14383 Notes: svn path=/head/; revision=329362
* Add support for zstd-compressed user and kernel core dumps.Mark Johnston2018-02-131-7/+27
| | | | | | | | | | | | | | | | | | | This works similarly to the existing gzip compression support, but zstd is typically faster and gives better compression ratios. Support for this functionality must be configured by adding ZSTDIO to one's kernel configuration file. dumpon(8)'s new -Z option is used to configure zstd compression for kernel dumps. savecore(8) now recognizes and saves zstd-compressed kernel dumps with a .zst extension. Submitted by: cem (original version) Relnotes: yes Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D13101, https://reviews.freebsd.org/D13633 Notes: svn path=/head/; revision=329240
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Add support for compressed kernel dumps.Mark Johnston2017-10-252-19/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using a kernel built with the GZIO config option, dumpon -z can be used to configure gzip compression using the in-kernel copy of zlib. This is useful on systems with large amounts of RAM, which require a correspondingly large dump device. Recovery of compressed dumps is also faster since fewer bytes need to be copied from the dump device. Because we have no way of knowing the final size of a compressed dump until it is written, the kernel will always attempt to dump when compression is configured, regardless of the dump device size. If the dump is aborted because we run out of space, an error is reported on the console. savecore(8) is modified to handle compressed dumps and save them to vmcore.<index>.gz, as it does when given the -z option. A new rc.conf variable, dumpon_flags, is added. Its value is added to the boot-time dumpon(8) invocation that occurs when a dump device is configured in rc.conf. Reviewed by: cem (earlier version) Discussed with: def, rgrimes Relnotes: yes Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D11723 Notes: svn path=/head/; revision=324965
* Fix style and wrap lines to 80 columns in savecore.c.Mark Johnston2017-07-241-16/+29
| | | | | | | | | No functional change intended. MFC after: 3 days Notes: svn path=/head/; revision=321437
* Revert r320918 and have mkdumpheader() handle version string truncation.Mark Johnston2017-07-151-1/+1
| | | | | | | | Reported by: jhb MFC after: 1 week Notes: svn path=/head/; revision=321035
* Add a newline after the version string.Mark Johnston2017-07-121-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=320918
* Add a subroutine for comparing kerneldump identifiers.Mark Johnston2017-07-111-5/+10
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=320896
* Switch back to non-IEC units for 1024 bytesEnji Cooper2017-04-151-1/+1
| | | | | | | | | | | | | | I was swayed a little too quickly when I saw the wiki page discussing kB vs KiB. Switch back as none of the code in base openly uses IEC units via humanize_number(3) (which was my next step), and there's a large degree of dislike with IEC vs more SI-like units. MFC after: 7 weeks Submitted by: jhb, rgrimes Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316953
* savecore: fix space calculation with respect to `minfree` in check_space(..)Enji Cooper2017-04-141-8/+27
| | | | | | | | | | | | | | | | | | | | | | | | | - Use strtoll(3) instead of atoi(3), because atoi(3) limits the representable data to INT_MAX. Check the values received from strtoll(3), trimming trailing whitespace off the end to maintain POLA. - Use `KiB` instead of `kB` when describing free space, total space, etc. I am now fully aware of `KiB` being the IEC standard for 1024 bytes and `kB` being the IEC standard for 1000 bytes. - Store available number of KiB in `available` so it can be more easily queried and compared to ensure that there are enough KiB to store the dump image on disk. - Print out the reserved space on disk, per `minfree`, so end-users can troubleshoot why check_space(..) is reporting that there isn't enough free space. MFC after: 7 weeks Reviewed by: Anton Rang <rang@acm.com> (earlier diff), cem (earlier diff) Tested with: positive/negative cases (see review); make tinderbox Sponsored by: Dell EMC Isilon Differential Revision: D10379 Notes: svn path=/head/; revision=316938
* Clarify units for mediasize and sectorsize in DoFile(..)Enji Cooper2017-04-121-2/+2
| | | | | | | | | | They're byte quantities. MFC after: 7 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316742
* Clarify `minfree` warning message in check_space(..)Enji Cooper2017-04-121-1/+2
| | | | | | | | | | | | - State that the units are kB. - Be more complete/concise in terms of what is required (in this case `minfree` must be at least `X`kB) MFC after: 7 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316740
* Renumber copyright clause 4Warner Losh2017-02-282-2/+2
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* Make savecore(8) output nicer by specifying the maximum field widthEdward Tomasz Napierala2017-02-191-1/+1
| | | | | | | | | | instead of minimum one (precision instead of width). MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=313946
* Fix bugs found by Coverity in decryptcore(8) and savecore(8):Konrad Witaszczyk2017-02-041-0/+3
| | | | | | | | | | | | | | | | | - Perform final decryption and write decrypted data in case of non-block aligned input data; - Use strlcpy(3) instead of strncpy(3) to verify if paths aren't too long; - Check errno after calling unlink(2) instead of calling stat(2) in order to verify if a decrypted core was created by a child process; - Free dumpkey. Reported by: Coverity, cem, pfg Suggested by: cem CID: 1366936, 1366942, 1366951, 1366952 Approved by: pjd (mentor) Notes: svn path=/head/; revision=313195
* Add support for encrypted kernel crash dumps.Konrad Witaszczyk2016-12-102-13/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes include modifications in kernel crash dump routines, dumpon(8) and savecore(8). A new tool called decryptcore(8) was added. A new DIOCSKERNELDUMP I/O control was added to send a kernel crash dump configuration in the diocskerneldump_arg structure to the kernel. The old DIOCSKERNELDUMP I/O control was renamed to DIOCSKERNELDUMP_FREEBSD11 for backward ABI compatibility. dumpon(8) generates an one-time random symmetric key and encrypts it using an RSA public key in capability mode. Currently only AES-256-CBC is supported but EKCD was designed to implement support for other algorithms in the future. The public key is chosen using the -k flag. The dumpon rc(8) script can do this automatically during startup using the dumppubkey rc.conf(5) variable. Once the keys are calculated dumpon sends them to the kernel via DIOCSKERNELDUMP I/O control. When the kernel receives the DIOCSKERNELDUMP I/O control it generates a random IV and sets up the key schedule for the specified algorithm. Each time the kernel tries to write a crash dump to the dump device, the IV is replaced by a SHA-256 hash of the previous value. This is intended to make a possible differential cryptanalysis harder since it is possible to write multiple crash dumps without reboot by repeating the following commands: # sysctl debug.kdb.enter=1 db> call doadump(0) db> continue # savecore A kernel dump key consists of an algorithm identifier, an IV and an encrypted symmetric key. The kernel dump key size is included in a kernel dump header. The size is an unsigned 32-bit integer and it is aligned to a block size. The header structure has 512 bytes to match the block size so it was required to make a panic string 4 bytes shorter to add a new field to the header structure. If the kernel dump key size in the header is nonzero it is assumed that the kernel dump key is placed after the first header on the dump device and the core dump is encrypted. Separate functions were implemented to write the kernel dump header and the kernel dump key as they need to be unencrypted. The dump_write function encrypts data if the kernel was compiled with the EKCD option. Encrypted kernel textdumps are not supported due to the way they are constructed which makes it impossible to use the CBC mode for encryption. It should be also noted that textdumps don't contain sensitive data by design as a user decides what information should be dumped. savecore(8) writes the kernel dump key to a key.# file if its size in the header is nonzero. # is the number of the current core dump. decryptcore(8) decrypts the core dump using a private RSA key and the kernel dump key. This is performed by a child process in capability mode. If the decryption was not successful the parent process removes a partially decrypted core dump. Description on how to encrypt crash dumps was added to the decryptcore(8), dumpon(8), rc.conf(5) and savecore(8) manual pages. EKCD was tested on amd64 using bhyve and i386, mipsel and sparc64 using QEMU. The feature still has to be tested on arm and arm64 as it wasn't possible to run FreeBSD due to the problems with QEMU emulation and lack of hardware. Designed by: def, pjd Reviewed by: cem, oshogbo, pjd Partial review: delphij, emaste, jhb, kib Approved by: pjd (mentor) Differential Revision: https://reviews.freebsd.org/D4712 Notes: svn path=/head/; revision=309818
* savecore(8): Fix buffer overrun inspecting disks with varying sector sizeConrad Meyer2016-10-061-6/+7
| | | | | | | | | | | | | | | | | A premature optimization lead to caching a native-sector sized memory allocation. If the program examined a 512 byte sector disk, then a 4096 byte sector disk, the program would overrun the cached 512 byte buffer. Just remove the optimization to fix the bug. This was introduced with the 4Kn dump support in r298076. Reported by: markj Reviewed by: markj, rpokala Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D8162 Notes: svn path=/head/; revision=306752
* Don't leak fd on sectorsize malloc failureEnji Cooper2016-04-201-1/+2
| | | | | | | | | | | | | | | Also, call endfsent after calling getfsent (i.e. when not explicitly called with a swap device) for code cleanliness CID: 1354785 Differential Revision: https://reviews.freebsd.org/D6014 X-MFC with: r298076 Reported by: Coverity Reviewed by: cem Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=298315
* MFHGlen Barber2016-04-161-8/+25
|\ | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=298092
| * savecore(8): Explicitly cast to fix i386 warningConrad Meyer2016-04-151-3/+3
| | | | | | | | Notes: svn path=/head/; revision=298086
| * Add 4Kn kernel dump supportConrad Meyer2016-04-151-8/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (And 4Kn minidump support, but only for amd64.) Make sure all I/O to the dump device is of the native sector size. To that end, we keep a native sector sized buffer associated with dump devices (di->blockbuf) and use it to pad smaller objects as needed (e.g. kerneldumpheader). Add dump_write_pad() as a convenience API to dump smaller objects with zero padding. (Rather than pull in NPM leftpad, we wrote our own.) Savecore(1) has been updated to deal with these dumps. The format for 512-byte sector dumps should remain backwards compatible. Minidumps for other architectures are left as an exercise for the reader. PR: 194279 Submitted by: ambrisko@ Reviewed by: cem (earlier version), rpokala Tested by: rpokala (4Kn/512 except 512 fulldump), cem (512 fulldump) Relnotes: yes Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D5848 Notes: svn path=/head/; revision=298076
* | Explicitly add more files to the 'runtime' package.Glen Barber2016-02-091-0/+1
|/ | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=295450
* Add more text to explain --libxo flag.Craig Rodrigues2015-12-011-1/+11
| | | | Notes: svn path=/head/; revision=291607
* savecore(8): Be quiet unless the user asks for verboseConrad Meyer2015-11-071-7/+10
| | | | | | | | | | Make savecore(8) more suitable for init-time scripts; be quiet by default. Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D3229 Notes: svn path=/head/; revision=290520
* Always check the return value of lseek.Alan Somers2015-11-061-6/+4
| | | | | | | | | | | | | | | This is a follow-up to r289845, which only fixed one occurence of CID 1009429. Coverity CID: 1009429 Reviewed by: markj MFC after: 2 weeks X-MFC-With: r289845 Sponsored by: Spectra Logic Differential Revision: https://reviews.freebsd.org/D4096 Notes: svn path=/head/; revision=290463
* Fix various Coverity issues in sbin/savecore/savecore.c:Alan Somers2015-10-231-6/+6
| | | | | | | | | | | | | | | | CID1009429: Fix unchecked return value from lseek while clearing dump CID1007781: Fix file descriptor leak in DoFile CID1007261: Don't send potentially unterminated string to syslog(3) Coverity CID: 1009429 Coverity CID: 1007781 Coverity CID: 1007261 MFC after: 2 weeks Sponsored by: Spectra Logic Differential Revision: https://reviews.freebsd.org/D3991 Notes: svn path=/head/; revision=289845
* Make libxo depend on libutil because it uses humanize_number after r287111Enji Cooper2015-10-181-1/+1
| | | | | | | | | | | Remove overlinking in lib/libxo/tests, sbin/savecore, and usr.bin/{iscsictl,wc,xo} PR: 203673 Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=289490
* Update META_MODE dependencies.Bryan Drewery2015-09-171-0/+1
| | | | Notes: svn path=/head/; revision=287905
* Upgrade libxo to 0.4.5.Marcel Moolenaar2015-08-241-1/+1
| | | | | | | | | | Local changes incorporated by 0.4.5: r284340 Local changes retained: r276260, r282117 Obtained from: https://github.com/Juniper/libxo Notes: svn path=/head/; revision=287111
* Add META_MODE support.Simon J. Gerraty2015-06-131-0/+20
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Off by default, build behaves normally. WITH_META_MODE we get auto objdir creation, the ability to start build from anywhere in the tree. Still need to add real targets under targets/ to build packages. Differential Revision: D2796 Reviewed by: brooks imp Notes: svn path=/head/; revision=284345
| * dirdeps.mk now sets DEP_RELDIRSimon J. Gerraty2015-06-081-2/+0
| | | | | | | | Notes: svn path=/projects/bmake/; revision=284172
| * Merge sync of headSimon J. Gerraty2015-05-273-25/+51
| |\ | |/ |/| | | Notes: svn path=/projects/bmake/; revision=283595