summaryrefslogtreecommitdiff
path: root/sys/dev/random/randomdev.c
Commit message (Collapse)AuthorAgeFilesLines
* Copy releng/7.2 to release/7.2.0 for FreeBSD 7.2-RELEASE.release/7.2.0_cvsKen Smith2009-05-011-1/+1
| | | | | | Approved by: re (implicit) This commit was manufactured to restore the state of the 7.2-RELEASE image.
* Make sure arc4random(9) is properly seeded when /etc/rc.d/initrandom returns.Colin Percival2008-11-241-0/+1
| | | | | | | | | Approved by: so (cperciva) Approved by: re (kensmith) Security: FreeBSD-SA-08:11.arc4random Notes: svn path=/stable/7/; revision=185254
* 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
* Remove GIANT from device random.Paul Saab2005-12-201-11/+3
| | | | | | | Submitted by: ups Notes: svn path=/head/; revision=153575
* Check O_NONBLOCK not IO_NDELAY.Poul-Henning Kamp2004-12-221-2/+1
| | | | | | | Don't include vnode.h Notes: svn path=/head/; revision=139194
* Add module versions.Mark Murray2004-08-021-0/+1
| | | | Notes: svn path=/head/; revision=133036
* Start the entropy device insecure/unblocked. I'll be handing overMark Murray2004-07-181-3/+1
| | | | | | | | | | responsibility for critical randomness requirements (like sshd) to rc.d/* Requested by: many Notes: svn path=/head/; revision=132346
* Do a pass over all modules in the kernel and make them return EOPNOTSUPPPoul-Henning Kamp2004-07-151-0/+4
| | | | | | | | | | | 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
* Trim a few things from the dmesg output and stick them under bootverbose toJohn Baldwin2004-07-011-1/+3
| | | | | | | | | | cut down on the clutter including PCI interrupt routing, MTRR, pcibios, etc. Discussed with: USENIX Cabal Notes: svn path=/head/; revision=131398
* Do the dreaded s/dev_t/struct cdev */Poul-Henning Kamp2004-06-161-6/+6
| | | | | | | Bump __FreeBSD_version accordingly. Notes: svn path=/head/; revision=130585
* Add some missing <sys/module.h> includes which are masked by thePoul-Henning Kamp2004-05-301-0/+1
| | | | | | | one on death-row in <sys/kernel.h> Notes: svn path=/head/; revision=129876
* More removal of the abortive locking code; malloc buffers whenMark Murray2004-04-171-4/+12
| | | | | | | needed, rather than potentially reusing contents. Notes: svn path=/head/; revision=128367
* Attempts to make this device Giant-free were ill-conceived asMark Murray2004-04-161-13/+9
| | | | | | | | | | | uiomove(9) is not properly locked. So, return to NEEDGIANT mode. Later, when uiomove is finely locked, I'll revisit. While I'm here, provide some temporary debugging output to help catch blocking startups. Notes: svn path=/head/; revision=128321
* Fix "sleeping without a mutex" panic.Mark Murray2004-04-121-3/+6
| | | | Notes: svn path=/head/; revision=128151
* Reorganise the entropy device so that high-yield entropy sourcesMark Murray2004-04-091-328/+78
| | | | | | | | | | can more easily be used INSTEAD OF the hard-working Yarrow. The only hardware source used at this point is the one inside the VIA C3 Nehemiah (Stepping 3 and above) CPU. More sources will be added in due course. Contributions welcome! Notes: svn path=/head/; revision=128059
* Device megapatch 4/6:Poul-Henning Kamp2004-02-211-0/+2
| | | | | | | | | | | 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
* Correct the cleanup of the alias dev_t for /dev/urandom: being anPoul-Henning Kamp2004-02-121-3/+1
| | | | | | | | | | alias it depends on the aliased dev_t and disappears automatically when that is removed. Submitted by: "Bjoern A. Zeeb" <bzeeb+freebsd@zabbadoz.net> Notes: svn path=/head/; revision=125746
* Fix a major faux pas of mine. I was causing 2 very bad things toMark Murray2003-11-201-12/+56
| | | | | | | | | | | | | | | | | | happen in interrupt context; 1) sleep locks, and 2) malloc/free calls. 1) is fixed by using spin locks instead. 2) is fixed by preallocating a FIFO (implemented with a STAILQ) and using elements from this FIFO instead. This turns out to be rather fast. OK'ed by: re (scottl) Thanks to: peter, jhb, rwatson, jake Apologies to: * Notes: svn path=/head/; revision=122917
* Overhaul the entropy device:Mark Murray2003-11-171-97/+88
| | | | | | | | | | | | | | | | | | | | | o Each source gets its own queue, which is a FIFO, not a ring buffer. The FIFOs are implemented with the sys/queue.h macros. The separation is so that a low entropy/high rate source can't swamp the harvester with low-grade entropy and destroy the reseeds. o Each FIFO is limited to 256 (set as a macro, so adjustable) events queueable. Full FIFOs are ignored by the harvester. This is to prevent memory wastage, and helps to keep the kernel thread CPU usage within reasonable limits. o There is no need to break up the event harvesting into ${burst} sized chunks, so retire that feature. o Break the device away from its roots with the memory device, and allow it to get its major number automagically. Notes: svn path=/head/; revision=122871
* - Implement selwakeuppri() which allows raising the priority of aSeigo Tanimura2003-11-091-1/+1
| | | | | | | | | | | | | | | | thread being waken up. The thread waken up can run at a priority as high as after tsleep(). - Replace selwakeup()s with selwakeuppri()s and pass appropriate priorities. - Add cv_broadcastpri() which raises the priority of the broadcast threads. Used by selwakeuppri() if collision occurs. Not objected in: -arch, -current Notes: svn path=/head/; revision=122352
* Make sure we get all user-written input. This simplifies theMark Murray2003-11-021-14/+5
| | | | | | | | | | code considerably. Submitted by: (forgotten) [I'll happily acknowledge the submitter if he owns up!] Notes: svn path=/head/; revision=121895
* Use __FBSDID().David E. O'Brien2003-08-241-1/+3
| | | | | | | Also some minor style cleanups. Notes: svn path=/head/; revision=119418
* Change the sleep identifier to "-" where random normally sleeps.Poul-Henning Kamp2003-07-021-1/+1
| | | | Notes: svn path=/head/; revision=117149
* Gigacommit to improve device-driver source compatibility betweenPoul-Henning Kamp2003-03-031-14/+8
| | | | | | | | | | | | | | | | 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
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-2/+2
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-2/+2
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* Some kernel threads try to do significant work, and the default KSTACK_PAGESScott Long2002-10-021-1/+1
| | | | | | | | | | | | | | | | doesn't give them enough stack to do much before blowing away the pcb. This adds MI and MD code to allow the allocation of an alternate kstack who's size can be speficied when calling kthread_create. Passing the value 0 prevents the alternate kstack from being created. Note that the ia64 MD code is missing for now, and PowerPC was only partially written due to the pmap.c being incomplete there. Though this patch does not modify anything to make use of the alternate kstack, acpi and usb are good candidates. Reviewed by: jake, peter, jhb Notes: svn path=/head/; revision=104354
* Remove #ifdef'ed Giant mutex wrappers round debugging statements.Mark Murray2002-09-211-2/+0
| | | | Notes: svn path=/head/; revision=103765
* Change the suser() API to take advantage of td_ucred as well as do aJohn Baldwin2002-04-011-2/+2
| | | | | | | | | | | | | | | 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
* Provide infrastructure for harvesting SWI entropy.Mark Murray2002-03-031-0/+3
| | | | Notes: svn path=/head/; revision=91601
* Massive lint-inspired cleanup.Mark Murray2002-03-031-30/+41
| | | | | | | | | | Remove unneeded includes. Deal with unused function arguments. Resolve a boatload of signed/unsigned imcompatabilities. Etc. Notes: svn path=/head/; revision=91600
* Simple p_ucred -> td_ucred changes to start using the per-thread ucredJohn Baldwin2002-02-271-2/+2
| | | | | | | reference. Notes: svn path=/head/; revision=91406
* o Modify open() and close() for /dev/random to use securelevel_gt() insteadRobert Watson2001-09-261-6/+16
| | | | | | | | | of direct securelevel variable checks. Obtained from: TrustedBSD Project Notes: svn path=/head/; revision=83976
* Use the passed in thread to selrecord() instead of curthread.John Baldwin2001-09-211-1/+1
| | | | Notes: svn path=/head/; revision=83805
* KSE Milestone 2Julian Elischer2001-09-121-7/+8
| | | | | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha Notes: svn path=/head/; revision=83366
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inMark Murray2001-05-011-6/+8
| | | | | | | | | | | | | | other "system" header files. Also help the deprecation of lockmgr.h by making it a sub-include of sys/lock.h and removing sys/lockmgr.h form kernel .c files. Sort sys/*.h includes where possible in affected files. OK'ed by: bde (with reservations) Notes: svn path=/head/; revision=76166
* Send the remains (such as I have located) of "block major numbers" toPoul-Henning Kamp2001-03-261-1/+0
| | | | | | | the bit-bucket. Notes: svn path=/head/; revision=74810
* Allow bog-standard ioctls through. There are really handled inMark Murray2001-03-251-1/+9
| | | | | | | higher layers, but there needs to be a "no-error" return here. Notes: svn path=/head/; revision=74771
* Very large makeover of the /dev/random driver.Mark Murray2001-03-101-91/+244
| | | | | | | | | | | | | | | | | | | | | | | | | | | o Separate the kernel stuff from the Yarrow algorithm. Yarrow is now well contained in one source file and one header. o Replace the Blowfish-based crypto routines with Rijndael-based ones. (Rijndael is the new AES algorithm). The huge improvement in Rijndael's key-agility over Blowfish means that this is an extremely dramatic improvement in speed, and makes a heck of a difference in its (lack of) CPU load. o Clean up the sysctl's. At BDE's prompting, I have gone back to static sysctls. o Bug fixes. The streamlining of the crypto stuff enabled me to find and fix some bugs. DES also found a bug in the reseed routine which is fixed. o Change the way reseeds clear "used" entropy. Previously, only the source(s) that caused a reseed were cleared. Now all sources in the relevant pool(s) are cleared. o Code tidy-up. Mostly to make it (nearly) 80-column compliant. Notes: svn path=/head/; revision=74072
* Provide the infrastructure for sysadmins to select the broad classMark Murray2001-02-181-1/+13
| | | | | | | | of entropy harvesting they wish to perform: "ethernet" (LAN), point-to-point and interrupt. Notes: svn path=/head/; revision=72667
* Remove NOBLOCKRANDOM as a compile-time option. Instead, provideMark Murray2001-01-141-19/+52
| | | | | | | | | | | | | | | | | | | exactly the same functionality via a sysctl, making this feature a run-time option. The default is 1(ON), which means that /dev/random device will NOT block at startup. setting kern.random.sys.seeded to 0(OFF) will cause /dev/random to block until the next reseed, at which stage the sysctl will be changed back to 1(ON). While I'm here, clean up the sysctls, and make them dynamic. Reviewed by: des Tested on Alpha by: obrien Notes: svn path=/head/; revision=71037
* select() DKI is now in <sys/selinfo.h>.Garrett Wollman2001-01-091-1/+1
| | | | Notes: svn path=/head/; revision=70834
* D'uh. The explicit reseed was happening at the wrong security/priveligeMark Murray2000-11-251-1/+1
| | | | | | | levels. Notes: svn path=/head/; revision=69174
* Greatly improve the boot-up unblocking time of the entropy device.Mark Murray2000-11-251-1/+10
| | | | Notes: svn path=/head/; revision=69172
* Move suser() and suser_xxx() prototypes and a related #define fromPoul-Henning Kamp2000-10-291-1/+0
| | | | | | | | | | | | <sys/proc.h> to <sys/systm.h>. Correctly document the #includes needed in the manpage. Add one now needed #include of <sys/systm.h>. Remove the consequent 48 unused #includes of <sys/proc.h>. Notes: svn path=/head/; revision=67893
* As the blocking model has seems to be troublesome for many, disableMark Murray2000-10-271-0/+5
| | | | | | | | | | it for now with an option. This option is already deprecated, and will be removed when the entropy-harvesting code is fast enough to warrant it. Notes: svn path=/head/; revision=67689
* Attempt to fix the random read blocking. The old code slept atPeter Wemm2000-10-181-14/+13
| | | | | | | | | | | priority "0" and without PCATCH, so it was uninterruptable. And even when it did wake up after entropy arrived, it exited after the wakeup without actually reading the freshly arrived entropy. I sent this to Mark before but it seems he is in transit. Mark: feel free to replace this if it gets in your way. Notes: svn path=/head/; revision=67286
* After some complaints about the dir names, the random device isMark Murray2000-10-141-9/+37
| | | | | | | | | | | | | | | | | | | | | | | now in dirs called sys/*/random/ instead of sys/*/randomdev/*. Introduce blocking, but only at startup; the random device will block until the first reseed happens to prevent clients from using untrustworthy output. Provide a read_random() call for the rest of the kernel so that the entropy device does not need to be present. This means that things like IPX no longer need to have "device random" hardcoded into thir kernel config. The downside is that read_random() will provide very poor output until the entropy device is loaded and reseeded. It is recommended that developers do NOT use the read_random() call; instead, they should use arc4random() which internally uses read_random(). Clean up the mutex and locking code a bit; this makes it possible to unload the module again. Notes: svn path=/head/; revision=67112
* Remove unneeded includes.Mark Murray2000-09-211-2/+0
| | | | | | | Submitted by: phk Notes: svn path=/head/; revision=66155
* Include <sys/proc.h> to silence suser() compiler warning.Robert Watson2000-09-181-0/+1
| | | | | | | Approved by: markm Notes: svn path=/head/; revision=66044