summaryrefslogtreecommitdiffstats
path: root/sys/dev/random
Commit message (Collapse)AuthorAgeFilesLines
* Device megapatch 4/6:phk2004-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.
* Correct the cleanup of the alias dev_t for /dev/urandom: being anphk2004-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>
* Fix a major faux pas of mine. I was causing 2 very bad things tomarkm2003-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: *
* Overhaul the entropy device:markm2003-11-175-123/+101
| | | | | | | | | | | | | | | | | | 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.
* - Implement selwakeuppri() which allows raising the priority of atanimura2003-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
* Make sure we get all user-written input. This simplifies themarkm2003-11-021-14/+5
| | | | | | | code considerably. Submitted by: (forgotten) [I'll happily acknowledge the submitter if he owns up!]
* Use __FBSDID().obrien2003-08-244-4/+12
| | | | Also some minor style cleanups.
* Change the sleep identifier to "-" where random normally sleeps.phk2003-07-021-1/+1
|
* Gigacommit to improve device-driver source compatibility betweenphk2003-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)
* Back out M_* changes, per decision of the TRB.imp2003-02-191-2/+2
| | | | Approved by: trb
* Remove srandom():ache2003-02-051-6/+1
| | | | | | | | 1) It is already called in init_main.c:proc0_post() 2) It is called each time read_random_phony() called, because "initialized" variable is never set to 1. Approved by: markm
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-2/+2
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Fix a buffer overrun in /dev/random which, due to the nature of themarkm2002-12-121-3/+4
| | | | | | | | | kernel memory allocator, is harmless. This could be a problem for other systems, though. I've modified Darren's patch a little. Original patch by: Darren Schack, Isilon Systems, Inc <darrens@isilon.com> Also analysed by: SGI, and in particular Divy Le Ray of SGI OK'ed by: re(rwatson)
* Some kernel threads try to do significant work, and the default KSTACK_PAGESscottl2002-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
* Remove #ifdef'ed Giant mutex wrappers round debugging statements.markm2002-09-212-10/+0
|
* No functional change. Fix comments and whitespace.markm2002-09-211-4/+3
|
* Upgrade the random device to use a "real" hash instead of buildingmarkm2002-07-153-54/+11
| | | | | | | | | | one out of a block cipher. This has 2 advantages: 1) The code is _much_ simpler 2) We aren't committing our security to one algorithm (much as we may think we trust AES). While I'm here, make an explicit reseed do a slow reseed instead of a fast; this is in line with what the original paper suggested.
* Fix really dumb braino of mine; cast a sizeof() to an int, which it ismarkm2002-04-211-1/+1
| | | | being compared to, not size_t, which it already is.
* Change callers of mtx_init() to pass in an appropriate lock type name. Injhb2002-04-041-1/+1
| | | | | | | most cases NULL is passed, but in some cases such as network driver locks (which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used. Tested on: i386, alpha, sparc64
* Change the suser() API to take advantage of td_ucred as well as do ajhb2002-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@
* Provide infrastructure for harvesting SWI entropy.markm2002-03-031-0/+3
|
* Massive lint-inspired cleanup.markm2002-03-036-70/+84
| | | | | | | Remove unneeded includes. Deal with unused function arguments. Resolve a boatload of signed/unsigned imcompatabilities. Etc.
* Simple p_ucred -> td_ucred changes to start using the per-thread ucredjhb2002-02-271-2/+2
| | | | reference.
* Staticise the random_state array.msmith2002-01-102-5/+3
| | | | Reviewed by: markm
* o Modify open() and close() for /dev/random to use securelevel_gt() insteadrwatson2001-09-261-6/+16
| | | | | | of direct securelevel variable checks. Obtained from: TrustedBSD Project
* Use the passed in thread to selrecord() instead of curthread.jhb2001-09-211-1/+1
|
* KSE Milestone 2julian2001-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
* Fix a minor buglet/typo here that gcc3 complains about.peter2001-09-101-1/+1
|
* Fix type warnings.markm2001-07-201-4/+8
| | | | PR: 29101
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inmarkm2001-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)
* Catch up to header include changes:jhb2001-03-282-0/+2
| | | | | - <sys/mutex.h> now requires <sys/systm.h> - <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h>
* Fix nasty corruption problem where a 64bit variable was being usedmarkm2001-03-281-8/+6
| | | | | | (overflowed) to catch a 256bit result. Hard work done by: jhb
* Send the remains (such as I have located) of "block major numbers" tophk2001-03-261-1/+0
| | | | the bit-bucket.
* Allow bog-standard ioctls through. There are really handled inmarkm2001-03-251-1/+9
| | | | higher layers, but there needs to be a "no-error" return here.
* Silence (harmless) warnings.markm2001-03-241-0/+1
|
* Very large makeover of the /dev/random driver.markm2001-03-107-459/+505
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Take down a comment that is no longer true.markm2001-03-031-4/+0
| | | | /dev/random is ready for prime time!
* Provide the infrastructure for sysadmins to select the broad classmarkm2001-02-182-1/+16
| | | | | of entropy harvesting they wish to perform: "ethernet" (LAN), point-to-point and interrupt.
* Make a big improvement to entropy-harvesting speed by not having anymarkm2001-02-112-66/+41
| | | | locks (only atomic assigns) in the harvest ringbuffer.
* Change and clean the mutex lock interface.bmilekic2001-02-092-37/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order)
* Fix typos: initalise -> initialise.asmodai2001-02-081-5/+5
| | | | Initalise is not an english word.
* Remove NOBLOCKRANDOM as a compile-time option. Instead, providemarkm2001-01-143-20/+58
| | | | | | | | | | | | | | | | 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
* select() DKI is now in <sys/selinfo.h>.wollman2001-01-093-3/+3
|
* Major speedup to /dev/random and the kernel thread that reseeds it.markm2000-12-022-93/+103
| | | | | | | | | | | | | | There is no more TAILQ fifo to harvest the entropy; instead, there is a circular buffer of constant size (changeable by macro) that pretty dramatically improves the speed and fixes potential slowdowns- by-locking. Also gone are a slew of malloc(9) and free(9) calls; all harvesting buffers are static. All-in-all, this is a good performance improvement. Thanks-to: msmith for the circular buffer concept-code.
* Fix safety-net code. While technically a bug, I'm delighted to seemarkm2000-11-261-1/+1
| | | | | | that it has never (apparently) been invoked. Submitted by: ache
* D'uh. The explicit reseed was happening at the wrong security/priveligemarkm2000-11-251-1/+1
| | | | levels.
* Greatly improve the boot-up unblocking time of the entropy device.markm2000-11-253-4/+19
|
* More comment changing. Keep documentation in one place.markm2000-11-251-4/+2
|
* Correct a comment. This represents a very minor policy change of mymarkm2000-11-251-2/+0
| | | | intentions with this code.
* Stop explicitly using nanotime(9) and use the new get_cyclecounter(9)markm2000-11-254-37/+34
| | | | | | | | | call instead. This makes a pretty dramatic difference to the amount of work that the harvester needs to do - it is much friendlier on the system. (80386 and 80486 class machines will notice little, as the new get_cyclecounter() call is a wrapper round nanotime(9) for them).
OpenPOWER on IntegriCloud