The NetBSD Project

CVS log for src/sys/dev/Attic/rndpseudo.c

[BACK] Up to [cvs.NetBSD.org] / src / sys / dev

Request diff between arbitrary revisions


Keyword substitution: kv
Default branch: MAIN


Revision 1.39
Thu Apr 30 03:28:18 2020 UTC (5 years ago) by riastradh
Branches: MAIN
CVS tags: thorpej-futex-base, perseant-exfatfs-base-20240630, perseant-exfatfs-base, perseant-exfatfs, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, bouyer-sunxi-drm-base, bouyer-sunxi-drm, HEAD
FILE REMOVED
Changes since revision 1.38: +2 -2 lines
Rewrite entropy subsystem.

Primary goals:

1. Use cryptography primitives designed and vetted by cryptographers.
2. Be honest about entropy estimation.
3. Propagate full entropy as soon as possible.
4. Simplify the APIs.
5. Reduce overhead of rnd_add_data and cprng_strong.
6. Reduce side channels of HWRNG data and human input sources.
7. Improve visibility of operation with sysctl and event counters.

Caveat: rngtest is no longer used generically for RND_TYPE_RNG
rndsources.  Hardware RNG devices should have hardware-specific
health tests.  For example, checking for two repeated 256-bit outputs
works to detect AMD's 2019 RDRAND bug.  Not all hardware RNGs are
necessarily designed to produce exactly uniform output.

ENTROPY POOL

- A Keccak sponge, with test vectors, replaces the old LFSR/SHA-1
  kludge as the cryptographic primitive.

- `Entropy depletion' is available for testing purposes with a sysctl
  knob kern.entropy.depletion; otherwise it is disabled, and once the
  system reaches full entropy it is assumed to stay there as far as
  modern cryptography is concerned.

- No `entropy estimation' based on sample values.  Such `entropy
  estimation' is a contradiction in terms, dishonest to users, and a
  potential source of side channels.  It is the responsibility of the
  driver author to study the entropy of the process that generates
  the samples.

- Per-CPU gathering pools avoid contention on a global queue.

- Entropy is occasionally consolidated into global pool -- as soon as
  it's ready, if we've never reached full entropy, and with a rate
  limit afterward.  Operators can force consolidation now by running
  sysctl -w kern.entropy.consolidate=1.

- rndsink(9) API has been replaced by an epoch counter which changes
  whenever entropy is consolidated into the global pool.
  . Usage: Cache entropy_epoch() when you seed.  If entropy_epoch()
    has changed when you're about to use whatever you seeded, reseed.
  . Epoch is never zero, so initialize cache to 0 if you want to reseed
    on first use.
  . Epoch is -1 iff we have never reached full entropy -- in other
    words, the old rnd_initial_entropy is (entropy_epoch() != -1) --
    but it is better if you check for changes rather than for -1, so
    that if the system estimated its own entropy incorrectly, entropy
    consolidation has the opportunity to prevent future compromise.

- Sysctls and event counters provide operator visibility into what's
  happening:
  . kern.entropy.needed - bits of entropy short of full entropy
  . kern.entropy.pending - bits known to be pending in per-CPU pools,
    can be consolidated with sysctl -w kern.entropy.consolidate=1
  . kern.entropy.epoch - number of times consolidation has happened,
    never 0, and -1 iff we have never reached full entropy

CPRNG_STRONG

- A cprng_strong instance is now a collection of per-CPU NIST
  Hash_DRBGs.  There are only two in the system: user_cprng for
  /dev/urandom and sysctl kern.?random, and kern_cprng for kernel
  users which may need to operate in interrupt context up to IPL_VM.

  (Calling cprng_strong in interrupt context does not strike me as a
  particularly good idea, so I added an event counter to see whether
  anything actually does.)

- Event counters provide operator visibility into when reseeding
  happens.

INTEL RDRAND/RDSEED, VIA C3 RNG (CPU_RNG)

- Unwired for now; will be rewired in a subsequent commit.

Revision 1.36.4.2: download - view: text, markup, annotated - select for diffs
Mon Apr 13 08:04:18 2020 UTC (5 years ago) by martin
Branches: phil-wifi
Diff to: previous 1.36.4.1: preferred, colored; branchpoint 1.36: preferred, colored; next MAIN 1.37: preferred, colored
Changes since revision 1.36.4.1: +5 -4 lines
Mostly merge changes from HEAD upto 20200411

Revision 1.21.2.1.2.1: download - view: text, markup, annotated - select for diffs
Tue Sep 3 12:30:46 2019 UTC (5 years, 8 months ago) by martin
Branches: netbsd-7-0
Diff to: previous 1.21.2.1: preferred, colored; next MAIN 1.21.2.2: preferred, colored
Changes since revision 1.21.2.1: +5 -4 lines
Pull up following revision(s) (requested by riastradh in ticket #1705):

	sys/crypto/nist_hash_drbg/nist_hash_drbg.c: revision 1.1
	sys/crypto/nist_hash_drbg/nist_hash_drbg.h: revision 1.1
	sys/rump/kern/lib/libcrypto/Makefile: revision 1.5
	sys/crypto/nist_hash_drbg/files.nist_hash_drbg: revision 1.1
	sys/rump/librump/rumpkern/Makefile.rumpkern: revision 1.176
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_aes256.h: file removal
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_config.h: file removal
	sys/conf/files: revision 1.1238
	sys/dev/rndpseudo.c: revision 1.38
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg.c: file removal
	sys/sys/cprng.h: revision 1.13 - 1.15
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg.h: file removal
	sys/crypto/nist_ctr_drbg/nist_ctr_aes_rijndael.h: file removal
	sys/crypto/nist_ctr_drbg/files.nist_ctr_drbg: file removal
	sys/kern/subr_cprng.c: revision 1.31
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_aes128.h: file removal

cprng.h: use static __inline for consistency with other include
headers and remove an unused function.

 -

Switch from NIST CTR_DRBG with AES to NIST Hash_DRBG with SHA-256.

Benefits:
- larger seeds -- a 128-bit key alone is not enough for `128-bit security'
- better resistance to timing side channels than AES
- a better-understood security story (<a  rel="nofollow" href="https://eprint.iacr.org/2018/349">https://eprint.iacr.org/2018/349</a>)
- no loss in compliance with US government standards that nobody ever
  got fired for choosing, at least in the US-dominated western world
- no dirty endianness tricks
- self-tests

Drawbacks:
- performance hit: throughput is reduced to about 1/3 in naive measurements
  => possible to mitigate by using hardware SHA-256 instructions
  => all you really need is 32 bytes to seed a userland PRNG anyway
  => if we just used ChaCha this would go away...

Revision 1.21.2.1.6.1: download - view: text, markup, annotated - select for diffs
Tue Sep 3 12:28:31 2019 UTC (5 years, 8 months ago) by martin
Branches: netbsd-7-1
Diff to: previous 1.21.2.1: preferred, colored; next MAIN 1.21.2.2: preferred, colored
Changes since revision 1.21.2.1: +5 -4 lines
Pull up following revision(s) (requested by riastradh in ticket #1705):

	sys/crypto/nist_hash_drbg/nist_hash_drbg.c: revision 1.1
	sys/crypto/nist_hash_drbg/nist_hash_drbg.h: revision 1.1
	sys/rump/kern/lib/libcrypto/Makefile: revision 1.5
	sys/crypto/nist_hash_drbg/files.nist_hash_drbg: revision 1.1
	sys/rump/librump/rumpkern/Makefile.rumpkern: revision 1.176
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_aes256.h: file removal
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_config.h: file removal
	sys/conf/files: revision 1.1238
	sys/dev/rndpseudo.c: revision 1.38
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg.c: file removal
	sys/sys/cprng.h: revision 1.13 - 1.15
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg.h: file removal
	sys/crypto/nist_ctr_drbg/nist_ctr_aes_rijndael.h: file removal
	sys/crypto/nist_ctr_drbg/files.nist_ctr_drbg: file removal
	sys/kern/subr_cprng.c: revision 1.31
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_aes128.h: file removal

cprng.h: use static __inline for consistency with other include
headers and remove an unused function.

 -

Switch from NIST CTR_DRBG with AES to NIST Hash_DRBG with SHA-256.

Benefits:
- larger seeds -- a 128-bit key alone is not enough for `128-bit security'
- better resistance to timing side channels than AES
- a better-understood security story (<a  rel="nofollow" href="https://eprint.iacr.org/2018/349">https://eprint.iacr.org/2018/349</a>)
- no loss in compliance with US government standards that nobody ever
  got fired for choosing, at least in the US-dominated western world
- no dirty endianness tricks
- self-tests

Drawbacks:
- performance hit: throughput is reduced to about 1/3 in naive measurements
  => possible to mitigate by using hardware SHA-256 instructions
  => all you really need is 32 bytes to seed a userland PRNG anyway
  => if we just used ChaCha this would go away...

Revision 1.21.2.2: download - view: text, markup, annotated - select for diffs
Tue Sep 3 12:20:43 2019 UTC (5 years, 8 months ago) by martin
Branches: netbsd-7
Diff to: previous 1.21.2.1: preferred, colored; branchpoint 1.21: preferred, colored; next MAIN 1.22: preferred, colored
Changes since revision 1.21.2.1: +5 -4 lines
Pull up following revision(s) (requested by riastradh in ticket #1705):

	sys/crypto/nist_hash_drbg/nist_hash_drbg.c: revision 1.1
	sys/crypto/nist_hash_drbg/nist_hash_drbg.h: revision 1.1
	sys/rump/kern/lib/libcrypto/Makefile: revision 1.5
	sys/crypto/nist_hash_drbg/files.nist_hash_drbg: revision 1.1
	sys/rump/librump/rumpkern/Makefile.rumpkern: revision 1.176
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_aes256.h: file removal
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_config.h: file removal
	sys/conf/files: revision 1.1238
	sys/dev/rndpseudo.c: revision 1.38
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg.c: file removal
	sys/sys/cprng.h: revision 1.13 - 1.15
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg.h: file removal
	sys/crypto/nist_ctr_drbg/nist_ctr_aes_rijndael.h: file removal
	sys/crypto/nist_ctr_drbg/files.nist_ctr_drbg: file removal
	sys/kern/subr_cprng.c: revision 1.31
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_aes128.h: file removal

cprng.h: use static __inline for consistency with other include
headers and remove an unused function.

 -

Switch from NIST CTR_DRBG with AES to NIST Hash_DRBG with SHA-256.

Benefits:
- larger seeds -- a 128-bit key alone is not enough for `128-bit security'
- better resistance to timing side channels than AES
- a better-understood security story (<a  rel="nofollow" href="https://eprint.iacr.org/2018/349">https://eprint.iacr.org/2018/349</a>)
- no loss in compliance with US government standards that nobody ever
  got fired for choosing, at least in the US-dominated western world
- no dirty endianness tricks
- self-tests

Drawbacks:
- performance hit: throughput is reduced to about 1/3 in naive measurements
  => possible to mitigate by using hardware SHA-256 instructions
  => all you really need is 32 bytes to seed a userland PRNG anyway
  => if we just used ChaCha this would go away...

Revision 1.35.10.1: download - view: text, markup, annotated - select for diffs
Tue Sep 3 12:08:22 2019 UTC (5 years, 8 months ago) by martin
Branches: netbsd-8
CVS tags: netbsd-8-3-RELEASE, netbsd-8-2-RELEASE
Diff to: previous 1.35: preferred, colored; next MAIN 1.36: preferred, colored
Changes since revision 1.35: +5 -4 lines
Pull up following revision(s) (requested by riastradh in ticket #1365):

	sys/crypto/nist_hash_drbg/nist_hash_drbg.c: revision 1.1
	sys/crypto/nist_hash_drbg/nist_hash_drbg.h: revision 1.1
	sys/rump/kern/lib/libcrypto/Makefile: revision 1.5
	sys/crypto/nist_hash_drbg/files.nist_hash_drbg: revision 1.1
	sys/rump/librump/rumpkern/Makefile.rumpkern: revision 1.176
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_aes256.h: file removal
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_config.h: file removal
	sys/conf/files: revision 1.1238
	sys/dev/rndpseudo.c: revision 1.38
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg.c: file removal
	sys/sys/cprng.h: revision 1.13 - 1.15
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg.h: file removal
	sys/crypto/nist_ctr_drbg/nist_ctr_aes_rijndael.h: file removal
	sys/crypto/nist_ctr_drbg/files.nist_ctr_drbg: file removal
	sys/kern/subr_cprng.c: revision 1.31
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_aes128.h: file removal

cprng.h: use static __inline for consistency with other include
headers and remove an unused function.

 -

Switch from NIST CTR_DRBG with AES to NIST Hash_DRBG with SHA-256.

Benefits:
- larger seeds -- a 128-bit key alone is not enough for `128-bit security'
- better resistance to timing side channels than AES
- a better-understood security story (<a  rel="nofollow" href="https://eprint.iacr.org/2018/349">https://eprint.iacr.org/2018/349</a>)
- no loss in compliance with US government standards that nobody ever
  got fired for choosing, at least in the US-dominated western world
- no dirty endianness tricks
- self-tests

Drawbacks:
- performance hit: throughput is reduced to about 1/3 in naive measurements
  => possible to mitigate by using hardware SHA-256 instructions
  => all you really need is 32 bytes to seed a userland PRNG anyway
  => if we just used ChaCha this would go away...

Revision 1.37.4.1: download - view: text, markup, annotated - select for diffs
Tue Sep 3 07:48:00 2019 UTC (5 years, 8 months ago) by martin
Branches: netbsd-9
CVS tags: netbsd-9-4-RELEASE, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1
Diff to: previous 1.37: preferred, colored; next MAIN 1.38: preferred, colored
Changes since revision 1.37: +5 -4 lines
Pull up following revision(s) (requested by riastradh in ticket #173):

	sys/crypto/nist_hash_drbg/nist_hash_drbg.c: revision 1.1
	sys/crypto/nist_hash_drbg/nist_hash_drbg.h: revision 1.1
	sys/rump/kern/lib/libcrypto/Makefile: revision 1.5
	sys/crypto/nist_hash_drbg/files.nist_hash_drbg: revision 1.1
	sys/rump/librump/rumpkern/Makefile.rumpkern: revision 1.176
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_aes256.h: file removal
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_config.h: file removal
	sys/conf/files: revision 1.1238
	sys/dev/rndpseudo.c: revision 1.38
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg.c: file removal
	sys/sys/cprng.h: revision 1.15
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg.h: file removal
	sys/crypto/nist_ctr_drbg/nist_ctr_aes_rijndael.h: file removal
	sys/crypto/nist_ctr_drbg/files.nist_ctr_drbg: file removal
	sys/kern/subr_cprng.c: revision 1.31
	sys/crypto/nist_ctr_drbg/nist_ctr_drbg_aes128.h: file removal

Switch from NIST CTR_DRBG with AES to NIST Hash_DRBG with SHA-256.

Benefits:
- larger seeds -- a 128-bit key alone is not enough for `128-bit security'
- better resistance to timing side channels than AES
- a better-understood security story (<a  rel="nofollow" href="https://eprint.iacr.org/2018/349">https://eprint.iacr.org/2018/349</a>)
- no loss in compliance with US government standards that nobody ever
  got fired for choosing, at least in the US-dominated western world
- no dirty endianness tricks
- self-tests

Drawbacks:
- performance hit: throughput is reduced to about 1/3 in naive measurements
  => possible to mitigate by using hardware SHA-256 instructions
  => all you really need is 32 bytes to seed a userland PRNG anyway
  => if we just used ChaCha this would go away...

XXX pullup-7
XXX pullup-8
XXX pullup-9

Revision 1.38: download - view: text, markup, annotated - select for diffs
Mon Sep 2 20:09:30 2019 UTC (5 years, 8 months ago) by riastradh
Branches: MAIN
CVS tags: phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, is-mlppp-base, is-mlppp, bouyer-xenpvh-base2, bouyer-xenpvh-base1, bouyer-xenpvh-base, bouyer-xenpvh, ad-namecache-base3, ad-namecache-base2, ad-namecache-base1, ad-namecache-base, ad-namecache
Diff to: previous 1.37: preferred, colored
Changes since revision 1.37: +5 -4 lines
Switch from NIST CTR_DRBG with AES to NIST Hash_DRBG with SHA-256.

Benefits:

- larger seeds -- a 128-bit key alone is not enough for `128-bit security'
- better resistance to timing side channels than AES
- a better-understood security story (https://eprint.iacr.org/2018/349)
- no loss in compliance with US government standards that nobody ever
  got fired for choosing, at least in the US-dominated western world
- no dirty endianness tricks
- self-tests

Drawbacks:

- performance hit: throughput is reduced to about 1/3 in naive measurements
  => possible to mitigate by using hardware SHA-256 instructions
  => all you really need is 32 bytes to seed a userland PRNG anyway
  => if we just used ChaCha this would go away...

XXX pullup-7
XXX pullup-8
XXX pullup-9

Revision 1.36.4.1: download - view: text, markup, annotated - select for diffs
Mon Jun 10 22:07:04 2019 UTC (5 years, 11 months ago) by christos
Branches: phil-wifi
Diff to: previous 1.36: preferred, colored
Changes since revision 1.36: +3 -3 lines
Sync with HEAD

Revision 1.36.2.1: download - view: text, markup, annotated - select for diffs
Thu Sep 6 06:55:48 2018 UTC (6 years, 8 months ago) by pgoyette
Branches: pgoyette-compat
CVS tags: pgoyette-compat-merge-20190127
Diff to: previous 1.36: preferred, colored; next MAIN 1.37: preferred, colored
Changes since revision 1.36: +3 -3 lines
Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)

Revision 1.37: download - view: text, markup, annotated - select for diffs
Mon Sep 3 16:29:30 2018 UTC (6 years, 8 months ago) by riastradh
Branches: MAIN
CVS tags: phil-wifi-20190609, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, netbsd-9-base, isaki-audio2-base, isaki-audio2
Branch point for: netbsd-9
Diff to: previous 1.36: preferred, colored
Changes since revision 1.36: +3 -3 lines
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

	#define min(a, b)	((a) < (b) ? (a) : (b))
	#define max(a, b)	((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX.  Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)

Revision 1.6.2.4: download - view: text, markup, annotated - select for diffs
Sat Mar 3 20:44:38 2018 UTC (7 years, 2 months ago) by snj
Branches: netbsd-6
Diff to: previous 1.6.2.3: preferred, colored; branchpoint 1.6: preferred, colored; next MAIN 1.7: preferred, colored
Changes since revision 1.6.2.3: +18 -6 lines
Apply patch (requested by riastradh in ticket #1512):
Fix panic when waiting with kqueue/kevent for a read from
/dev/random.

Revision 1.6.2.3.6.1: download - view: text, markup, annotated - select for diffs
Sat Mar 3 20:44:35 2018 UTC (7 years, 2 months ago) by snj
Branches: netbsd-6-1
Diff to: previous 1.6.2.3: preferred, colored; next MAIN 1.6.2.4: preferred, colored
Changes since revision 1.6.2.3: +18 -6 lines
Apply patch (requested by riastradh in ticket #1512):
Fix panic when waiting with kqueue/kevent for a read from
/dev/random.

Revision 1.6.2.3.4.1: download - view: text, markup, annotated - select for diffs
Sat Mar 3 20:44:32 2018 UTC (7 years, 2 months ago) by snj
Branches: netbsd-6-0
Diff to: previous 1.6.2.3: preferred, colored; next MAIN 1.6.2.4: preferred, colored
Changes since revision 1.6.2.3: +18 -6 lines
Apply patch (requested by riastradh in ticket #1512):
Fix panic when waiting with kqueue/kevent for a read from
/dev/random.

Revision 1.10.2.4: download - view: text, markup, annotated - select for diffs
Sun Dec 3 11:36:58 2017 UTC (7 years, 5 months ago) by jdolecek
Branches: tls-maxphys
Diff to: previous 1.10.2.3: preferred, colored; branchpoint 1.10: preferred, colored; next MAIN 1.11: preferred, colored
Changes since revision 1.10.2.3: +54 -359 lines
update from HEAD

Revision 1.36: download - view: text, markup, annotated - select for diffs
Thu Nov 30 20:25:54 2017 UTC (7 years, 5 months ago) by christos
Branches: MAIN
CVS tags: tls-maxphys-base-20171202, phil-wifi-base, pgoyette-compat-base, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, jdolecek-ncqfixes-base, jdolecek-ncqfixes
Branch point for: phil-wifi, pgoyette-compat
Diff to: previous 1.35: preferred, colored
Changes since revision 1.35: +3 -2 lines
add fo_name so we can identify the fileops in a simple way.

Revision 1.35.8.2: download - view: text, markup, annotated - select for diffs
Sat Apr 29 11:12:14 2017 UTC (8 years ago) by pgoyette
Branches: prg-localcount2
Diff to: previous 1.35.8.1: preferred, colored; branchpoint 1.35: preferred, colored; next MAIN 1.36: preferred, colored
Changes since revision 1.35.8.1: +2 -3 lines
Remove more unnecessary #include for sys/localcount.h

Revision 1.35.8.1: download - view: text, markup, annotated - select for diffs
Thu Apr 27 05:36:35 2017 UTC (8 years ago) by pgoyette
Branches: prg-localcount2
Diff to: previous 1.35: preferred, colored
Changes since revision 1.35: +4 -2 lines
Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita.  There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.

Revision 1.35.2.3: download - view: text, markup, annotated - select for diffs
Tue Jul 26 05:54:39 2016 UTC (8 years, 9 months ago) by pgoyette
Branches: pgoyette-localcount
Diff to: previous 1.35.2.2: preferred, colored; branchpoint 1.35: preferred, colored; next MAIN 1.36: preferred, colored
Changes since revision 1.35.2.2: +3 -3 lines
Rename LOCALCOUNT_INITIALIZER to DEVSW_MODULE_INIT.  This better describes
what we're doing, and why.

Revision 1.35.2.2: download - view: text, markup, annotated - select for diffs
Tue Jul 19 06:26:58 2016 UTC (8 years, 9 months ago) by pgoyette
Branches: pgoyette-localcount
Diff to: previous 1.35.2.1: preferred, colored; branchpoint 1.35: preferred, colored
Changes since revision 1.35.2.1: +3 -9 lines
Instead of repeatedly typing the conditional initialization of the
.d_localcount members in the various {b,c}devsw, define an initializer
macro and use it.  This also removes the need for defining new symbols
for each 'struct localcount'.

As suggested by riastradh@

Revision 1.35.2.1: download - view: text, markup, annotated - select for diffs
Mon Jul 18 03:49:59 2016 UTC (8 years, 9 months ago) by pgoyette
Branches: pgoyette-localcount
Diff to: previous 1.35: preferred, colored
Changes since revision 1.35: +10 -2 lines
Rump drivers are always installed via devsw_attach() so we need to
always allocate a 'struct localcount' for these drivers whenever they
are built as modules.

Revision 1.24.2.2: download - view: text, markup, annotated - select for diffs
Tue Sep 22 12:05:56 2015 UTC (9 years, 7 months ago) by skrll
Branches: nick-nhusb
Diff to: previous 1.24.2.1: preferred, colored; branchpoint 1.24: preferred, colored; next MAIN 1.25: preferred, colored
Changes since revision 1.24.2.1: +5 -4 lines
Sync with HEAD

Revision 1.35: download - view: text, markup, annotated - select for diffs
Thu Aug 20 14:40:17 2015 UTC (9 years, 8 months ago) by christos
Branches: MAIN
CVS tags: prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, perseant-stdc-iso10646-base, perseant-stdc-iso10646, nick-nhusb-base-20170825, nick-nhusb-base-20170204, nick-nhusb-base-20161204, nick-nhusb-base-20161004, nick-nhusb-base-20160907, nick-nhusb-base-20160529, nick-nhusb-base-20160422, nick-nhusb-base-20160319, nick-nhusb-base-20151226, nick-nhusb-base-20150921, netbsd-8-base, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, jdolecek-ncq-base, jdolecek-ncq, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan
Branch point for: prg-localcount2, pgoyette-localcount, netbsd-8
Diff to: previous 1.34: preferred, colored
Changes since revision 1.34: +5 -4 lines
include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.

Revision 1.24.2.1: download - view: text, markup, annotated - select for diffs
Sat Jun 6 14:40:06 2015 UTC (9 years, 11 months ago) by skrll
Branches: nick-nhusb
Diff to: previous 1.24: preferred, colored
Changes since revision 1.24: +39 -365 lines
Sync with HEAD

Revision 1.34: download - view: text, markup, annotated - select for diffs
Tue Apr 21 12:57:03 2015 UTC (10 years ago) by riastradh
Branches: MAIN
CVS tags: nick-nhusb-base-20150606
Diff to: previous 1.33: preferred, colored
Changes since revision 1.33: +5 -5 lines
Mark some variables __read_mostly.

Revision 1.33: download - view: text, markup, annotated - select for diffs
Tue Apr 21 12:51:53 2015 UTC (10 years ago) by riastradh
Branches: MAIN
Diff to: previous 1.32: preferred, colored
Changes since revision 1.32: +17 -18 lines
Sort includes.

Revision 1.32: download - view: text, markup, annotated - select for diffs
Tue Apr 21 12:07:31 2015 UTC (10 years ago) by riastradh
Branches: MAIN
Diff to: previous 1.31: preferred, colored
Changes since revision 1.31: +5 -5 lines
Xor, not ior, to combine bits of binuptime for rnd_counter.

Revision 1.31: download - view: text, markup, annotated - select for diffs
Tue Apr 14 12:51:30 2015 UTC (10 years, 1 month ago) by riastradh
Branches: MAIN
Diff to: previous 1.30: preferred, colored
Changes since revision 1.30: +4 -312 lines
Move substantive part of rnd_ioctl to kern_rndq.c.

Revision 1.30: download - view: text, markup, annotated - select for diffs
Tue Apr 14 12:27:02 2015 UTC (10 years, 1 month ago) by riastradh
Branches: MAIN
Diff to: previous 1.29: preferred, colored
Changes since revision 1.29: +4 -4 lines
Eliminate last two cases of u_int*_t in rndpseudo.c.

Revision 1.29: download - view: text, markup, annotated - select for diffs
Tue Apr 14 12:25:41 2015 UTC (10 years, 1 month ago) by riastradh
Branches: MAIN
Diff to: previous 1.28: preferred, colored
Changes since revision 1.28: +14 -8 lines
Use binuptime, not microtime/nanotime as substitute cycle counter.

Revision 1.28: download - view: text, markup, annotated - select for diffs
Tue Apr 14 12:21:12 2015 UTC (10 years, 1 month ago) by riastradh
Branches: MAIN
Diff to: previous 1.27: preferred, colored
Changes since revision 1.27: +4 -2 lines
Include rndpool.h, rndsource.h here because we use them.

Revision 1.27: download - view: text, markup, annotated - select for diffs
Tue Apr 14 12:14:09 2015 UTC (10 years, 1 month ago) by riastradh
Branches: MAIN
Diff to: previous 1.26: preferred, colored
Changes since revision 1.26: +4 -8 lines
Use rnd_add_data, not rndpool_mtx and rndpool_add_data.

Revision 1.26: download - view: text, markup, annotated - select for diffs
Mon Apr 13 15:13:50 2015 UTC (10 years, 1 month ago) by riastradh
Branches: MAIN
Diff to: previous 1.25: preferred, colored
Changes since revision 1.25: +3 -24 lines
Gather rnd-private declarations into <dev/rnd_private.h>.

Let's try to avoid putting externs in .c files where the compiler
can't check them.

Revision 1.25: download - view: text, markup, annotated - select for diffs
Mon Apr 13 14:56:22 2015 UTC (10 years, 1 month ago) by riastradh
Branches: MAIN
Diff to: previous 1.24: preferred, colored
Changes since revision 1.24: +15 -15 lines
If we're going to use the queue macros, use them as intended.

Revision 1.24: download - view: text, markup, annotated - select for diffs
Sun Nov 9 20:29:58 2014 UTC (10 years, 6 months ago) by christos
Branches: MAIN
CVS tags: nick-nhusb-base-20150406, nick-nhusb-base
Branch point for: nick-nhusb
Diff to: previous 1.23: preferred, colored
Changes since revision 1.23: +12 -2 lines
add a couple of event counters.

Revision 1.21.2.1: download - view: text, markup, annotated - select for diffs
Sun Nov 2 09:47:04 2014 UTC (10 years, 6 months ago) by martin
Branches: netbsd-7
CVS tags: netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE
Branch point for: netbsd-7-1, netbsd-7-0
Diff to: previous 1.21: preferred, colored
Changes since revision 1.21: +20 -11 lines
Pull up following revision(s) (requested by tls in ticket #173):
	doc/CHANGES: revision 1.2004
	sys/sys/rnd.h: revision 1.43
	sys/kern/kern_rndq.c: revision 1.28
	sys/kern/kern_rndsink.c: revision 1.10
	sys/dev/rndpseudo.c: revision 1.23
Fixes and enhancements for polled entropy sources:
	Add explicit enable/disable hooks for callout-driven sources (be more
	power friendly).
	Make "skew" source polled so it runs only when there is entropy
	demand.
	Adjust entropy collection from polled sources so it's processed
	sooner.

Revision 1.23: download - view: text, markup, annotated - select for diffs
Sun Oct 26 18:22:32 2014 UTC (10 years, 6 months ago) by tls
Branches: MAIN
Diff to: previous 1.22: preferred, colored
Changes since revision 1.22: +20 -11 lines
Fixes and enhancements for polled entropy sources:
	Add explicit enable/disable hooks for callout-driven sources (be more
	power friendly).

	Make "skew" source polled so it runs only when there is entropy
	demand.

	Adjust entropy collection from polled sources so it's processed
	sooner.

Revision 1.22: download - view: text, markup, annotated - select for diffs
Fri Sep 5 09:23:14 2014 UTC (10 years, 8 months ago) by matt
Branches: MAIN
Diff to: previous 1.21: preferred, colored
Changes since revision 1.21: +8 -8 lines
Try not to use f_data, use f_rndctx to get a correctly typed pointer.

Revision 1.10.2.3: download - view: text, markup, annotated - select for diffs
Wed Aug 20 00:03:35 2014 UTC (10 years, 8 months ago) by tls
Branches: tls-maxphys
Diff to: previous 1.10.2.2: preferred, colored; branchpoint 1.10: preferred, colored
Changes since revision 1.10.2.2: +332 -240 lines
Rebase to HEAD as of a few days ago.

Revision 1.21: download - view: text, markup, annotated - select for diffs
Sun Aug 10 16:44:35 2014 UTC (10 years, 9 months ago) by tls
Branches: MAIN
CVS tags: tls-maxphys-base, netbsd-7-base
Branch point for: netbsd-7
Diff to: previous 1.20: preferred, colored
Changes since revision 1.20: +80 -4 lines
Merge tls-earlyentropy branch into HEAD.

Revision 1.19.2.3: download - view: text, markup, annotated - select for diffs
Sun Aug 10 06:54:50 2014 UTC (10 years, 9 months ago) by tls
Branches: tls-earlyentropy
Diff to: previous 1.19.2.2: preferred, colored; branchpoint 1.19: preferred, colored; next MAIN 1.20: preferred, colored
Changes since revision 1.19.2.2: +3 -2 lines
Rebase.

Revision 1.20: download - view: text, markup, annotated - select for diffs
Fri Jul 25 08:10:35 2014 UTC (10 years, 9 months ago) by dholland
Branches: MAIN
CVS tags: tls-earlyentropy-base
Diff to: previous 1.19: preferred, colored
Changes since revision 1.19: +3 -2 lines
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.

Revision 1.19.2.2: download - view: text, markup, annotated - select for diffs
Thu Jul 17 14:03:33 2014 UTC (10 years, 9 months ago) by tls
Branches: tls-earlyentropy
Diff to: previous 1.19.2.1: preferred, colored; branchpoint 1.19: preferred, colored
Changes since revision 1.19.2.1: +2 -4 lines
Adjustments to the "earlyentropy" branch in response to the various
discussions beginning with my initial proposal
http://mail-index.netbsd.org/tech-kern/2014/04/08/msg016876.html and
particularly the long discussion of cprng_fast() performance (e.g.
https://mail-index.netbsd.org/tech-crypto/2014/04/21/msg000642.html).

In particular:

	* Per-CPU, lockless cprng_fast replacement using Dennis Ferguson's
	  "ccrand" implementation of ChaCha8.

	* libkern arc4random() is gone, gone, gone.

	* Entropy estimator reverted to 32-bit recordkeeping and timestamps
	  per Dennis' comments and analysis.

	* LZF entropy estimator removed: it required a great deal of state,
	  and rejected only truly pathological input.

	I have not yet reverted the changes that provide LZF in the kernel
	as generic functionality; I will likely revert those changes prior
	to any merge of this branch to HEAD.

Revision 1.7.2.5: download - view: text, markup, annotated - select for diffs
Thu May 22 11:40:19 2014 UTC (10 years, 11 months ago) by yamt
Branches: yamt-pagecache
Diff to: previous 1.7.2.4: preferred, colored; branchpoint 1.7: preferred, colored; next MAIN 1.8: preferred, colored
Changes since revision 1.7.2.4: +255 -224 lines
sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")

Revision 1.13.2.2: download - view: text, markup, annotated - select for diffs
Sun May 18 17:45:35 2014 UTC (10 years, 11 months ago) by rmind
Branches: rmind-smpnet
Diff to: previous 1.13.2.1: preferred, colored; next MAIN 1.14: preferred, colored
Changes since revision 1.13.2.1: +38 -15 lines
sync with head

Revision 1.19.2.1: download - view: text, markup, annotated - select for diffs
Mon Apr 7 02:54:53 2014 UTC (11 years, 1 month ago) by tls
Branches: tls-earlyentropy
Diff to: previous 1.19: preferred, colored
Changes since revision 1.19: +82 -4 lines
Whups.  It'd help to check in the ioctl changes needed to support that
rndctl change just prior... ;-)

Revision 1.19: download - view: text, markup, annotated - select for diffs
Sun Mar 16 05:20:26 2014 UTC (11 years, 1 month ago) by dholland
Branches: MAIN
CVS tags: yamt-pagecache-base9, rmind-smpnet-nbase, rmind-smpnet-base, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3
Branch point for: tls-earlyentropy
Diff to: previous 1.18: preferred, colored
Changes since revision 1.18: +13 -4 lines
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.

Revision 1.18: download - view: text, markup, annotated - select for diffs
Tue Mar 11 20:35:47 2014 UTC (11 years, 2 months ago) by pooka
Branches: MAIN
Diff to: previous 1.17: preferred, colored
Changes since revision 1.17: +4 -4 lines
kill _RUMPKERNEL ifdef

Revision 1.17: download - view: text, markup, annotated - select for diffs
Wed Sep 25 03:14:55 2013 UTC (11 years, 7 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.16: preferred, colored
Changes since revision 1.16: +25 -11 lines
Fix spurious kassert on interrupted blocking read from /dev/random.

Return EINTR in this case instead.  While here, clarify comment.

Fixes PR kern/48119, simpler than the patch attached there, per
discussion with tls@, who had this right in the earlier version
of rndpseudo.c before I broke it (oops!).

Revision 1.13.2.1: download - view: text, markup, annotated - select for diffs
Wed Aug 28 23:59:24 2013 UTC (11 years, 8 months ago) by rmind
Branches: rmind-smpnet
Diff to: previous 1.13: preferred, colored
Changes since revision 1.13: +227 -182 lines
sync with head

Revision 1.15.2.1: download - view: text, markup, annotated - select for diffs
Tue Jul 23 21:07:35 2013 UTC (11 years, 9 months ago) by riastradh
Branches: riastradh-drm2
Diff to: previous 1.15: preferred, colored; next MAIN 1.16: preferred, colored
Changes since revision 1.15: +18 -2 lines
sync with HEAD

Revision 1.16: download - view: text, markup, annotated - select for diffs
Sun Jul 21 22:30:19 2013 UTC (11 years, 9 months ago) by riastradh
Branches: MAIN
CVS tags: riastradh-drm2-base2, riastradh-drm2-base1
Diff to: previous 1.15: preferred, colored
Changes since revision 1.15: +18 -2 lines
When reading from /dev/random, block at most once in cprng_strong.

We are not obligated to return exactly as many bytes as requested,
and many applications -- notably those that use stdio or otherwise
buffered I/O to read from /dev/random -- try to read many more than
32 bytes at a time from /dev/random even if all they are about to use
is 32 bytes.

In this case, blocking until we have enough entropy to fill a large
buffer causes needless application delays, e.g. causing cgdconfig
(which reads from /dev/random with stdio) to hang at boot when trying
to configure a random-keyed device for swap.

Patch tested by Aran Clauson.  Fixes PR kern/48028.

Revision 1.15: download - view: text, markup, annotated - select for diffs
Tue Jul 2 13:27:42 2013 UTC (11 years, 10 months ago) by pgoyette
Branches: MAIN
CVS tags: riastradh-drm2-base
Branch point for: riastradh-drm2
Diff to: previous 1.14: preferred, colored
Changes since revision 1.14: +4 -4 lines
Initialize some variables to make the vax build happy.

XXX Not sure why this problem only showed up on vax builds.

Revision 1.14: download - view: text, markup, annotated - select for diffs
Mon Jul 1 15:22:00 2013 UTC (11 years, 10 months ago) by riastradh
Branches: MAIN
Diff to: previous 1.13: preferred, colored
Changes since revision 1.13: +214 -185 lines
Fix races in /dev/u?random initialization and accounting.

- Push /dev/random `information-theoretic' accounting into cprng(9).
- Use percpu(9) for the per-CPU CPRNGs.
- Use atomics with correct memory barriers for lazy CPRNG creation.
- Remove /dev/random file kmem grovelling from fstat(1).

Revision 1.10.2.2: download - view: text, markup, annotated - select for diffs
Sun Jun 23 06:20:16 2013 UTC (11 years, 10 months ago) by tls
Branches: tls-maxphys
Diff to: previous 1.10.2.1: preferred, colored; branchpoint 1.10: preferred, colored
Changes since revision 1.10.2.1: +23 -7 lines
resync from head

Revision 1.13: download - view: text, markup, annotated - select for diffs
Sun Jun 23 02:35:24 2013 UTC (11 years, 10 months ago) by riastradh
Branches: MAIN
Branch point for: rmind-smpnet
Diff to: previous 1.12: preferred, colored
Changes since revision 1.12: +6 -59 lines
Rework rndsink(9) abstraction and adapt arc4random(9) and cprng(9).

rndsink(9):
- Simplify API.
- Simplify locking scheme.
- Add a man page.
- Avoid races in destruction.
- Avoid races in requesting entropy now and scheduling entropy later.

Periodic distribution of entropy to sinks reduces the need for the
last one, but this way we don't need to rely on periodic distribution
(e.g., in a future tickless NetBSD).

rndsinks_lock should probably eventually merge with the rndpool lock,
but we'll put that off for now.

cprng(9):
- Make struct cprng_strong opaque.
- Move rndpseudo.c parts that futz with cprng guts to subr_cprng.c.
- Fix kevent locking.  (Is kevent locking documented anywhere?)
- Stub out rump cprng further until we can rumpify rndsink instead.
- Strip code to grovel through struct cprng_strong in fstat.

Revision 1.12: download - view: text, markup, annotated - select for diffs
Thu Jun 13 00:55:01 2013 UTC (11 years, 11 months ago) by tls
Branches: MAIN
Diff to: previous 1.11: preferred, colored
Changes since revision 1.11: +23 -7 lines
Convert the entropy pool framework from pseudo-callout-driven to
soft interrupt driven operation.

Add a polling mode of operation -- now we can ask hardware random number
generators to top us up just when we need it (bcm2835_rng and amdpm
converted as examples).

Fix a stall noticed with repeated reads from /dev/random while testing.

Revision 1.10.2.1: download - view: text, markup, annotated - select for diffs
Mon Feb 25 00:29:11 2013 UTC (12 years, 2 months ago) by tls
Branches: tls-maxphys
Diff to: previous 1.10: preferred, colored
Changes since revision 1.10: +2 -12 lines
resync with head

Revision 1.7.2.4: download - view: text, markup, annotated - select for diffs
Wed Jan 16 05:33:13 2013 UTC (12 years, 3 months ago) by yamt
Branches: yamt-pagecache
CVS tags: yamt-pagecache-tag8
Diff to: previous 1.7.2.3: preferred, colored; branchpoint 1.7: preferred, colored
Changes since revision 1.7.2.3: +2 -12 lines
sync with (a bit old) head

Revision 1.11: download - view: text, markup, annotated - select for diffs
Sun Nov 25 15:29:24 2012 UTC (12 years, 5 months ago) by christos
Branches: MAIN
CVS tags: yamt-pagecache-base8, yamt-pagecache-base7, khorben-n900, agc-symver-base, agc-symver
Diff to: previous 1.10: preferred, colored
Changes since revision 1.10: +2 -12 lines
move context struct to a header for the benefit of fstat.

Revision 1.6.4.5: download - view: text, markup, annotated - select for diffs
Sat Jun 2 11:09:16 2012 UTC (12 years, 11 months ago) by mrg
Branches: jmcneill-usbmp
Diff to: previous 1.6.4.4: preferred, colored; branchpoint 1.6: preferred, colored; next MAIN 1.7: preferred, colored
Changes since revision 1.6.4.4: +13 -10 lines
sync to latest -current.

Revision 1.7.2.3: download - view: text, markup, annotated - select for diffs
Wed May 23 10:07:55 2012 UTC (12 years, 11 months ago) by yamt
Branches: yamt-pagecache
Diff to: previous 1.7.2.2: preferred, colored; branchpoint 1.7: preferred, colored
Changes since revision 1.7.2.2: +50 -15 lines
sync with head.

Revision 1.6.2.3: download - view: text, markup, annotated - select for diffs
Mon May 21 16:49:54 2012 UTC (12 years, 11 months ago) by jdc
Branches: netbsd-6
CVS tags: netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus
Branch point for: netbsd-6-1, netbsd-6-0
Diff to: previous 1.6.2.2: preferred, colored; branchpoint 1.6: preferred, colored
Changes since revision 1.6.2.2: +13 -10 lines
Pull up:

  revision 1.10 src/sys/dev/rndpseudo.c
  revision 1.9  src/sys/kern/subr_cprng.c

(requested by tls in ticket 273).

  Fix two problems that could cause /dev/random to not wake up readers when
  entropy became available.

Revision 1.10: download - view: text, markup, annotated - select for diffs
Sat May 19 16:00:41 2012 UTC (12 years, 11 months ago) by tls
Branches: MAIN
CVS tags: yamt-pagecache-base6, yamt-pagecache-base5, jmcneill-usbmp-base10
Branch point for: tls-maxphys
Diff to: previous 1.9: preferred, colored
Changes since revision 1.9: +13 -10 lines

Fix two problems that could cause /dev/random to not wake up readers when entropy became available.

Revision 1.6.4.4: download - view: text, markup, annotated - select for diffs
Sun Apr 29 23:04:48 2012 UTC (13 years ago) by mrg
Branches: jmcneill-usbmp
Diff to: previous 1.6.4.3: preferred, colored; branchpoint 1.6: preferred, colored
Changes since revision 1.6.4.3: +41 -9 lines
sync to latest -current.

Revision 1.6.2.2: download - view: text, markup, annotated - select for diffs
Fri Apr 20 23:35:20 2012 UTC (13 years ago) by riz
Branches: netbsd-6
Diff to: previous 1.6.2.1: preferred, colored; branchpoint 1.6: preferred, colored
Changes since revision 1.6.2.1: +41 -9 lines
Pull up following revision(s) (requested by tls in ticket #190):
	sys/sys/rnd.h: revision 1.31
	sys/sys/rnd.h: revision 1.32
	sys/sys/cprng.h: revision 1.5
	sys/kern/subr_cprng.c: revision 1.8
	share/man/man4/rnd.4: revision 1.19
	sys/kern/kern_rndq.c: revision 1.3
	sys/dev/rndpseudo.c: revision 1.8
	sys/dev/rndpseudo.c: revision 1.9
	sys/kern/kern_rndpool.c: revision 1.2
Address multiple problems with rnd(4)/cprng(9):
1) Add a per-cpu CPRNG to handle short reads from /dev/urandom so that
   programs like perl don't drain the entropy pool dry by repeatedly
   opening, reading 4 bytes, closing.
2) Really fix the locking around reseeds and destroys.
3) Fix the opportunistic-reseed strategy so it actually works, reseeding
   existing RNGs once each (as they are used, so idle RNGs don't get
   reseeded) until the pool is half empty or newly full again.
Fix a bug and a compilation problem.  Bug: spin mutexes don't have owners,
so KASSERT(!mutex_owned()) shouldn't be used to assert that the current
LWP does not have the mutex.  Compilation problem: explicitly include
sys/mutex.h from rnd.h so evbarm builds again.

Revision 1.9: download - view: text, markup, annotated - select for diffs
Fri Apr 20 21:57:33 2012 UTC (13 years ago) by tls
Branches: MAIN
CVS tags: jmcneill-usbmp-base9
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +3 -5 lines
Fix a bug and a compilation problem.  Bug: spin mutexes don't have owners,
so KASSERT(!mutex_owned()) shouldn't be used to assert that the current
LWP does not have the mutex.  Compilation problem: explicitly include
sys/mutex.h from rnd.h so evbarm builds again.

Revision 1.6.2.1: download - view: text, markup, annotated - select for diffs
Thu Apr 19 19:59:11 2012 UTC (13 years ago) by riz
Branches: netbsd-6
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +6 -7 lines
Pull up following revision(s) (requested by tls in ticket #185):
	sys/kern/subr_cprng.c: revision 1.6
	sys/kern/subr_cprng.c: revision 1.7
	sys/lib/libkern/arc4random.c: revision 1.32
	sys/kern/kern_rndq.c: revision 1.2
	sys/dev/rndpseudo.c: revision 1.7
	sys/sys/rnd.h: revision 1.30
Add a spin mutex to the rndsink structure; it is used to avoid lock
ordering and sleep-holding-locks problems when rekeying, and thus
to avoid a nasty race between cprng destruction and reseeding.
Fix LOCKDEBUG problems pointed out by drochner@
1) Lock ordering in cprng_strong_destroy had us take a spin mutex then
   an adaptive mutex.  Can't do that.  Reordering this requires changing
   cprng_strong_reseed to tryenter the cprng's own mutex and skip the
   reseed on failure, or we could deadlock.
2) Can't free memory with a valid mutex in it.
reorder initialization to improve error handling in case the system
runs out of file descriptors, avoids LOCKDEBUG panic due to double
mutex initialization

Revision 1.8: download - view: text, markup, annotated - select for diffs
Tue Apr 17 02:50:38 2012 UTC (13 years ago) by tls
Branches: MAIN
Diff to: previous 1.7: preferred, colored
Changes since revision 1.7: +43 -9 lines
Address multiple problems with rnd(4)/cprng(9):

1) Add a per-cpu CPRNG to handle short reads from /dev/urandom so that
   programs like perl don't drain the entropy pool dry by repeatedly
   opening, reading 4 bytes, closing.

2) Really fix the locking around reseeds and destroys.

3) Fix the opportunistic-reseed strategy so it actually works, reseeding
   existing RNGs once each (as they are used, so idle RNGs don't get
   reseeded) until the pool is half empty or newly full again.

Revision 1.7.2.2: download - view: text, markup, annotated - select for diffs
Tue Apr 17 00:07:26 2012 UTC (13 years ago) by yamt
Branches: yamt-pagecache
Diff to: previous 1.7.2.1: preferred, colored; branchpoint 1.7: preferred, colored
Changes since revision 1.7.2.1: +749 -0 lines
sync with head

Revision 1.6.4.3: download - view: text, markup, annotated - select for diffs
Thu Apr 5 21:33:24 2012 UTC (13 years, 1 month ago) by mrg
Branches: jmcneill-usbmp
Diff to: previous 1.6.4.2: preferred, colored; branchpoint 1.6: preferred, colored
Changes since revision 1.6.4.2: +6 -7 lines
sync to latest -current.

Revision 1.7.2.1
Fri Mar 30 20:15:18 2012 UTC (13 years, 1 month ago) by yamt
Branches: yamt-pagecache
FILE REMOVED
Changes since revision 1.7: +0 -749 lines
file rndpseudo.c was added on branch yamt-pagecache on 2012-04-17 00:07:26 +0000

Revision 1.7: download - view: text, markup, annotated - select for diffs
Fri Mar 30 20:15:18 2012 UTC (13 years, 1 month ago) by drochner
Branches: MAIN
CVS tags: yamt-pagecache-base4, jmcneill-usbmp-base8
Branch point for: yamt-pagecache
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +6 -7 lines
reorder initialization to improve error handling in case the system
runs out of file descriptors, avoids LOCKDEBUG panic due to double
mutex initialization

Revision 1.6.4.2: download - view: text, markup, annotated - select for diffs
Sat Feb 18 07:34:06 2012 UTC (13 years, 2 months ago) by mrg
Branches: jmcneill-usbmp
Diff to: previous 1.6.4.1: preferred, colored; branchpoint 1.6: preferred, colored
Changes since revision 1.6.4.1: +750 -0 lines
merge to -current.

Revision 1.6.4.1
Tue Dec 20 13:42:19 2011 UTC (13 years, 4 months ago) by mrg
Branches: jmcneill-usbmp
FILE REMOVED
Changes since revision 1.6: +0 -750 lines
file rndpseudo.c was added on branch jmcneill-usbmp on 2012-02-18 07:34:06 +0000

Revision 1.6: download - view: text, markup, annotated - select for diffs
Tue Dec 20 13:42:19 2011 UTC (13 years, 4 months ago) by apb
Branches: MAIN
CVS tags: netbsd-6-base, jmcneill-usbmp-base7, jmcneill-usbmp-base6, jmcneill-usbmp-base5, jmcneill-usbmp-base4, jmcneill-usbmp-base3, jmcneill-usbmp-base2
Branch point for: netbsd-6, jmcneill-usbmp
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +2 -6 lines
Revert previous; the #include was already present, and I got confused
by a merge error.

Revision 1.5: download - view: text, markup, annotated - select for diffs
Tue Dec 20 12:45:00 2011 UTC (13 years, 4 months ago) by apb
Branches: MAIN
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +6 -2 lines
#include "opt_compat_netbsd.h"

Revision 1.4: download - view: text, markup, annotated - select for diffs
Mon Dec 19 21:53:52 2011 UTC (13 years, 4 months ago) by apb
Branches: MAIN
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +17 -5 lines
Add COMPAT_50 and COMPAT_NETBSD32 compatibility code for rnd(4)
ioctl commands.

Tested with "rndctl -ls" using an old 32-bit version of rndctl(8)
(built for NetBSD-5.99.56/i386) and a new 64-bit kernel
(NetBSD-5.99.59/amd64).

Revision 1.3: download - view: text, markup, annotated - select for diffs
Mon Dec 19 21:44:08 2011 UTC (13 years, 4 months ago) by apb
Branches: MAIN
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +4 -4 lines
Return ENOTTY, not EINVAL, when the ioctl command is unrecognised.

Revision 1.2: download - view: text, markup, annotated - select for diffs
Mon Dec 19 11:10:08 2011 UTC (13 years, 4 months ago) by drochner
Branches: MAIN
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +4 -4 lines
make this build with RND_DEBUG

Revision 1.1: download - view: text, markup, annotated - select for diffs
Sat Dec 17 20:05:39 2011 UTC (13 years, 4 months ago) by tls
Branches: MAIN

Separate /dev/random pseudodevice implemenation from kernel entropy pool
implementation.  Rewrite pseudodevice code to use cprng_strong(9).

The new pseudodevice is cloning, so each caller gets bits from a stream
generated with its own key.  Users of /dev/urandom get their generators
keyed on a "best effort" basis -- the kernel will rekey generators
whenever the entropy pool hits the high water mark -- while users of
/dev/random get their generators rekeyed every time key-length bits
are output.

The underlying cprng_strong API can use AES-256 or AES-128, but we use
AES-128 because of concerns about related-key attacks on AES-256.  This
improves performance (and reduces entropy pool depletion) significantly
for users of /dev/urandom but does cause users of /dev/random to rekey
twice as often.

Also fixes various bugs (including some missing locking and a reseed-counter
overflow in the CTR_DRBG code) found while testing this.

For long reads, this generator is approximately 20 times as fast as the
old generator (dd with bs=64K yields 53MB/sec on 2Ghz Core2 instead of
2.5MB/sec) and also uses a separate mutex per instance so concurrency
is greatly improved.  For reads of typical key sizes for modern
cryptosystems (16-32 bytes) performance is about the same as the old
code: a little better for 32 bytes, a little worse for 16 bytes.

Diff request

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

Log view options

CVSweb <webmaster@jp.NetBSD.org>