aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/null/null.c
Commit message (Collapse)AuthorAgeFilesLines
* Refactor some of the MI kernel dump code in preparation for netdump.Mark Johnston2018-05-061-2/+2
| | | | | | | | | | | | | | | - Add clear_dumper() to complement set_dumper(). - Drain netdump's preallocated mbuf pool when clearing the dumper. - Don't do bounds checking for dumpers with mediasize 0. - Add dumper callbacks for initialization for writing out headers. Reviewed by: sbruno MFC after: 1 month Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D15252 Notes: svn path=/head/; revision=333282
* Move most of the contents of opt_compat.h to opt_global.h.Brooks Davis2018-04-061-2/+0
| | | | | | | | | | | | | | | | | | | | | opt_compat.h is mentioned in nearly 180 files. In-progress network driver compabibility improvements may add over 100 more so this is closer to "just about everywhere" than "only some files" per the guidance in sys/conf/options. Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of sys/compat/linux/*.c. A fake _COMPAT_LINUX option ensure opt_compat.h is created on all architectures. Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the set of compiled files. Reviewed by: kib, cem, jhb, jtl Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14941 Notes: svn path=/head/; revision=332122
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. 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. Notes: svn path=/head/; revision=326255
* Add support for compressed kernel dumps.Mark Johnston2017-10-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add support for encrypted kernel crash dumps.Konrad Witaszczyk2016-12-101-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add missing privilege check when setting the dump device. Before that change itPawel Jakub Dawidek2014-11-111-4/+1
| | | | | | | | | | | | | | | was possible for a regular user to setup the dump device if he had write access to the given device. In theory it is a security issue as user might get access to kernel's memory after provoking kernel crash, but in practise it is not recommended to give regular users direct access to storage devices. Rework the code so that we do privileges check within the set_dumper() function to avoid similar problems in the future. Discussed with: secteam Notes: svn path=/head/; revision=274366
* null.c: uio is unusedEitan Adler2014-04-301-1/+1
| | | | | | | | | Mark another parameter as unused Reported by: rpaulo Notes: svn path=/head/; revision=265136
* null.c: fix orderingEitan Adler2014-04-301-8/+9
| | | | | | | | | Use a consistent ordering of full -> null -> zero (alphabetical) in null.c Reported by: mjg Notes: svn path=/head/; revision=265134
* Add a /dev/full device.Eitan Adler2014-04-301-1/+24
| | | | | | | | | | | /dev/full is similar to /dev/zero except it always returns ENOSPC when you attempt to write to it. Reviewed by: jhibbits Discussed with: rpaulo Notes: svn path=/head/; revision=265132
* Provide a device name in the sysctl tree for programs to query theAlfred Perlstein2012-11-011-1/+1
| | | | | | | | | | | | state of crashdump target devices. This will be used to add a "-l" (ell) flag to dumpon(8) to list the currently configured dumpdev. Reviewed by: phk Notes: svn path=/head/; revision=242439
* Fix for PR 138526.George V. Neville-Neil2012-01-111-6/+42
| | | | | | | | | | | | | Add the ability for /dev/null and /dev/zero to accept being set into non blocking mode via fcntl(). This brings the code into compliance with IEEE Std 1003.1-2001 as referenced in another PR, 94729. Reviewed by: jhb MFC after: 1 week Notes: svn path=/head/; revision=229965
* Move the ZERO_REGION_SIZE to a machine-dependent file, as on manyMatthew D Fleming2011-05-131-0/+2
| | | | | | | | | | | | | | | | | | | | | architectures (i386, for example) the virtual memory space may be constrained enough that 2MB is a large chunk. Use 64K for arches other than amd64 and ia64, with special handling for sparc64 due to differing hardware. Also commit the comment changes to kmem_init_zero_region() that I missed due to not saving the file. (Darn the unfamiliar development environment). Arch maintainers, please feel free to adjust ZERO_REGION_SIZE as you see fit. Requested by: alc MFC after: 1 week MFC with: r221853 Notes: svn path=/head/; revision=221855
* Usa a globally visible region of zeros for both /dev/zero and the mdMatthew D Fleming2011-05-131-6/+11
| | | | | | | | | | | device. There are likely other kernel uses of "blob of zeros" than can be converted. Reviewed by: alc MFC after: 1 week Notes: svn path=/head/; revision=221853
* Mark /dev/zero and /dev/null as eternal.Konstantin Belousov2010-08-061-4/+4
| | | | | | | | In collaboration with: pho MFC after: 1 month Notes: svn path=/head/; revision=210926
* Remove unneeded minor numbers from /dev/null and /dev/zero.Ed Schouten2009-09-061-7/+4
| | | | Notes: svn path=/head/; revision=196885
* Sweep kernel replacing suser(9) calls with priv(9) calls, assigningRobert Watson2006-11-061-1/+2
| | | | | | | | | | | | | | | | specific privilege names to a broad range of privileges. These may require some future tweaking. Sponsored by: nCircle Network Security, Inc. Obtained from: TrustedBSD Project Discussed on: arch@ Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri, Alex Lyashkov <umka at sevcity dot net>, Skip Ford <skip dot ford at verizon dot net>, Antoine Brodin <antoine dot brodin at laposte dot net> Notes: svn path=/head/; revision=164033
* Use dynamic major number allocation.Poul-Henning Kamp2005-02-271-3/+0
| | | | Notes: svn path=/head/; revision=142707
* Go back to the historical minor numbers. Add a module version whileMark Murray2004-08-021-2/+3
| | | | | | | | | I'm here. Asked for minor numbers by: jhb Notes: svn path=/head/; revision=133033
* YA oops. Remove code that was being tested locally.Mark Murray2004-08-011-21/+0
| | | | Notes: svn path=/head/; revision=132963
* Break out the MI part of the /dev/[k]mem and /dev/io drivers intoMark Murray2004-08-011-9/+27
| | | | | | | | | | | their own directory and module, leaving the MD parts in the MD area (the MD parts _are_ part of the modules). /dev/mem and /dev/io are now loadable modules, thus taking us one step further towards a kernel created entirely out of modules. Of course, there is nothing preventing the kernel from having these statically compiled. Notes: svn path=/head/; revision=132956
* Do a pass over all modules in the kernel and make them return EOPNOTSUPPPoul-Henning Kamp2004-07-151-0/+2
| | | | | | | | | | | for unknown events. A number of modules return EINVAL in this instance, and I have left those alone for now and instead taught MOD_QUIESCE to accept this as "didn't do anything". Notes: svn path=/head/; revision=132199
* Micro-tweaking.Mark Murray2004-06-201-7/+10
| | | | Notes: svn path=/head/; revision=130788
* Do the dreaded s/dev_t/struct cdev */Poul-Henning Kamp2004-06-161-5/+5
| | | | | | | Bump __FreeBSD_version accordingly. Notes: svn path=/head/; revision=130585
* Device megapatch 4/6:Poul-Henning Kamp2004-02-211-2/+3
| | | | | | | | | | | Introduce d_version field in struct cdevsw, this must always be initialized to D_VERSION. Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing four D_NOGIANT flags and adding 145 D_NEEDGIANT flags. Notes: svn path=/head/; revision=126080
* Shorten the code by removing one "do-nothing" function, replacing itMark Murray2003-11-011-10/+1
| | | | | | | with nullop(), which is in kern_conf.c. Notes: svn path=/head/; revision=121856
* Mark as __unused some arguments that are, erm, unused.Mark Murray2003-10-181-2/+5
| | | | Notes: svn path=/head/; revision=121189
* Return ENOIOCTL for unknown ioctls, don't use noioctl to return ENODEV.Poul-Henning Kamp2003-09-271-1/+1
| | | | Notes: svn path=/head/; revision=120510
* The present defaults for the open and close for device drivers whichPoul-Henning Kamp2003-09-271-4/+0
| | | | | | | | | | | | | | | | | provide no methods does not make any sense, and is not used by any driver. It is a pretty hard to come up with even a theoretical concept of a device driver which would always fail open and close with ENODEV. Change the defaults to be nullopen() and nullclose() which simply does nothing. Remove explicit initializations to these from the drivers which already used them. Notes: svn path=/head/; revision=120506
* Use __FBSDID().David E. O'Brien2003-08-241-1/+3
| | | | | | | Also some minor style cleanups. Notes: svn path=/head/; revision=119418
* /dev/null and /dev/zero does not need GiantPoul-Henning Kamp2003-06-241-1/+2
| | | | Notes: svn path=/head/; revision=116794
* Gigacommit to improve device-driver source compatibility betweenPoul-Henning Kamp2003-03-031-28/+14
| | | | | | | | | | | | | | | | branches: Initialize struct cdevsw using C99 sparse initializtion and remove all initializations to default values. This patch is automatically generated and has been tested by compiling LINT with all the fields in struct cdevsw in reverse order on alpha, sparc64 and i386. Approved by: re(scottl) Notes: svn path=/head/; revision=111815
* Don't use evil casts in cdevsw initialization.Poul-Henning Kamp2003-03-021-5/+13
| | | | Notes: svn path=/head/; revision=111758
* Warns and lint fix. Nearly all trivial stuff.Mark Murray2003-02-271-7/+8
| | | | Notes: svn path=/head/; revision=111630
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-1/+1
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-1/+1
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* Everywhere else, an argument passed to a device containing flagsMark Murray2002-09-211-5/+4
| | | | | | | is called "flags". Make it so here. Notes: svn path=/head/; revision=103745
* Modernise the cdevsw WRT to (unused) kqueue.Mark Murray2002-08-021-0/+2
| | | | Notes: svn path=/head/; revision=101219
* Rename DIOCGKERNELDUMP to DIOCSKERNELDUMP as it strictly speakingPoul-Henning Kamp2002-04-091-1/+1
| | | | | | | | | is a "set" not a "get" operation. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=94272
* Move generic disk ioctls from <sys/disklabel.h> to <sys/disk.h>.Poul-Henning Kamp2002-04-081-1/+1
| | | | | | | Sponsored by: DARPA & NAI Labs Notes: svn path=/head/; revision=94182
* Change the suser() API to take advantage of td_ucred as well as do aJohn Baldwin2002-04-011-1/+1
| | | | | | | | | | | | | | | general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@ Notes: svn path=/head/; revision=93593
* Here follows the new kernel dumping infrastructure.Poul-Henning Kamp2002-03-311-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Caveats: The new savecore program is not complete in the sense that it emulates enough of the old savecores features to do the job, but implements none of the options yet. I would appreciate if a userland hacker could help me out getting savecore to do what we want it to do from a users point of view, compression, email-notification, space reservation etc etc. (send me email if you are interested). Currently, savecore will scan all devices marked as "swap" or "dump" in /etc/fstab _or_ any devices specified on the command-line. All architectures but i386 lack an implementation of dumpsys(), but looking at the i386 version it should be trivial for anybody familiar with the platform(s) to provide this function. Documentation is quite sparse at this time, more to come. Details: ATA and SCSI drivers should work as the dump formatting code has been removed. The IDA, TWE and AAC have not yet been converted. Dumpon now opens the device and uses ioctl(DIOCGKERNELDUMP) to set the device as dumpdev. To implement the "off" argument, /dev/null is used as the device. Savecore will fail if handed any options since they are not (yet) implemented. All devices marked "dump" or "swap" in /etc/fstab will be scanned and dumps found will be saved to diskfiles named from the MD5 hash of the header record. The header record is dumped in readable format in the .info file. The kernel is not saved. Only complete dumps will be saved. All maintainer rights for this code are disclaimed: feel free to improve and extend. Sponsored by: DARPA, NAI Labs Notes: svn path=/head/; revision=93496
* Send the remains (such as I have located) of "block major numbers" toPoul-Henning Kamp2001-03-261-2/+0
| | | | | | | the bit-bucket. Notes: svn path=/head/; revision=74810
* Convert more malloc+bzero to malloc+M_ZERO.David Malone2000-12-081-2/+1
| | | | | | | | Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net> Notes: svn path=/head/; revision=69781
* During a verbose boot, call the null device 'null' rather than 'null0' toJohn Baldwin2000-10-061-1/+1
| | | | | | | be more consistent with the rest of the kernel. Notes: svn path=/head/; revision=66709
* Move sys/dev/nulldev to sys/dev/null to be more consistent with namingJohn Baldwin2000-10-021-2/+2
| | | | | | | under sys/dev. Notes: svn path=/head/; revision=66560
* Small style change; make function names less likely to clash withMark Murray2000-07-091-7/+7
| | | | | | | existing names. "null" is too common a string; use "null_". Notes: svn path=/head/; revision=62843
* New machine independant /dev/null and /dev/zero driver. This device isMark Murray2000-06-251-0/+137
severely stripped down compared with its predecessor, and is measurably a _lot_ faster. Many thanks to Jeroen van Gelderen for lots of good ideas. There is still a problem with this; it is written as a mudule, and as such is theoretically unloadable. However, there is no refcounting done as I would prefer to do that a'la device_busy(9), rather than some "home-rolled" scheme. The point is pretty moot, as /dev/null is effectively compulsory. Reviewed by: dfr Notes: svn path=/head/; revision=62052