tedu
37a5836398
oops, i deleted the wrong word
10 years ago
tedu
13ffbefb0f
remove a lie spotted by guenther
10 years ago
tedu
d3e68c8356
once srandomdev() is called, switch to using arc4random() but mask off the
high bit as required by posix. wouldn't want to break any standards.
idea and ok deraadt
10 years ago
beck
6289d57278
While we thought this would make portable life easier it actually
makes it much harder.
ok bcook@ kettenis@
10 years ago
deraadt
30150934f0
Wrap "thread_private.h" with #ifdef __OpenBSD__ so that other systems
can copy this file (plus chacha_private.h) directly and reuse it
trivially. Well, as long as they have a getentropy() as well..
ok beck
10 years ago
deraadt
3f9dd576c8
Split arc4random_uniform into it's own file, to assist other projects
now using this as upstream code. The particular problem is systems
that contain older arc4random derivations lacking arc4random_uniform().
ok tedu miod
10 years ago
kettenis
78bf858a52
Add locking for __cxa_finalize() as it modifies the page permissions of the
__atexit tables and touches global variables. From Srinavasa Nagaraju
through Android/Elliott Hughes.
ok tedu@, guenther@
10 years ago
tedu
ae7f8bb30d
better document perils of setuid getenv and xr with issetugid
ok deraadt
10 years ago
tedu
beacb71783
as noted by google/android via kettenis, atexit handlers can install new
handlers. if this happens, restart the loop.
ok kettenis matthew millert miod
10 years ago
tedu
705f1bf46e
reduce obvious dependency on global g_pool by moving to local aliases
ok otto
10 years ago
naddy
33c9c303eb
rephrase the stpcpy() warning
new wording agreed by at least kettenis@ millert@ otto@
10 years ago
beck
97abe91297
Clean up after arc4random u_int32_t uint32_t change
ok jsing@
10 years ago
bcook
165f09edc7
changes to improve portability
ok beck@ deraadt@ jsing@ guenther@
10 years ago
deraadt
b3e0f519ff
re-init and init code paths are now more shared, so the getpid()-based
portable code path must handle that; with brent cook
10 years ago
deraadt
df559b50e4
extra evil spaces snuck in over the last while
10 years ago
otto
08ecfcb5b8
Move to a smaller rbytes buffer and skip a random part. Not to
improve the random stream itself (it doesn't), but to introduce
noise in the arc4random calling pattern. Thanks to matthew@ who
pointed out bias in a previous diff, ok deraadt@ matthew@
10 years ago
deraadt
b6b255face
Add back an #ifndef MAP_INHERIT_ZERO chunk to support the old getpid()
mechanism, to aid in portability to other systems as requested.
ok matthew
10 years ago
deraadt
db13a3eef8
document why we explicit_bzero
10 years ago
tedu
f0d4f91f14
loosen the spec for timingsafe functions slightly, so as to not
artificially constrain alternative implementations. ok deraadt
10 years ago
matthew
f198222e04
Protect explicit_bzero() from link-time optimization
Modern compiler toolchains are capable of optimizing even across
translation unit boundaries, so simply moving the memory clearing into
a separate function is not guaranteed to clear memory.
To avoid this, we take advantage of ELF weak symbol semantics, and
insert a call to an empty, weakly named function. The semantics of
calling this function aren't determinable until load time, so the
compiler and linker need to keep the memset() call.
There are still ways a toolchain might defeat this trick (e.g.,
optimistically expecting the weak symbol to not be overloaded, and
only calling memset() if it is; promoting weak symbols to strong
symbols at link-time when emitting a static binary because they won't
be interposed; implementing load-time optimizations). But at least
for the foreseeable future, these seem unlikely.
ok deraadt
10 years ago
matthew
16792c29e6
arc4random: hard fail with raise(SIGKILL) if getentropy() returns -1
Allow other non-zero return values in case we change our mind to
return an ssize_t byte count instead of simple success/fail.
ok deraadt, djm
10 years ago
matthew
5374ff9a6b
Move rs_chacha and rs_buf into the same memory page and don't mark it
MAP_INHERIT_ZERO anymore. This restores arc4random's previous
behavior where fork children would mix in some randomness from the
parent process.
New behavior noticed by deraadt
ok deraadt, tedu
10 years ago
kettenis
32ba0b02ca
Always call atexit handlers as if they were registered with __cxa_atexit.
The extra argument doesn't hurt genuine atexit handlers and this fixes a
bug where we didn't provide the argument (effectively passing garbage) for
functions registered with __cxa_atexit in the main executable.
Pointed out by Dmitriy Ivanov <dimitry@google.com> and Elliott Hughes
<enh@google.com>.
ok matthew@
10 years ago
matthew
932467241e
Use MAP_INHERIT_ZERO in arc4random(3)
Now instead of calling getpid() each time a user invokes arc4random(),
we're able to rely on the kernel zero'ing out the RNG state if the
process forks.
ok deraadt, djm
10 years ago
deraadt
dbf34e5830
oops, typo. James Hartley is fast at trying -current
10 years ago
deraadt
6343e8d14f
In srandomdev(), use arc4random_buf() instead of from the kernel.
discussion with matthew
10 years ago
deraadt
45b700d2c0
For now... assume success of getentropy() just like we assumed success
of sysctl(). Mark it with XXX while we consider.
10 years ago
deraadt
42da378a93
use getgentropy() call. If it fails, things are pretty bad --
call abort().
this direction discussed at length with miod beck tedu matthew etc
10 years ago
deraadt
4bc984f92a
use getentropy; from matthew
10 years ago
matthew
f82197f5b3
Add timingsafe_memcmp().
ok deraadt, jmc, tedu
10 years ago
millert
3c0d2bba38
Disable the "switch to insertion sort" optimization to avoid quadratic
behavior for certain inputs. From NetBSD. OK tedu@
10 years ago
deraadt
f909f7742d
mop up ifndef KERNEL goo; ok miod
10 years ago
otto
7626939dd1
move random bytes buffer to be part of mmaped pages; ok tedu@
10 years ago
jca
43205a26de
Delete the extraneous "return" statement at the end of a void function.
From Fritjof Bornebusch.
10 years ago
otto
547175abed
move all stats collecting under MALLOC_STATS; ok krw@
10 years ago
otto
17d6cb272d
fix MALLOC_STATS (not compiled in by default); ok tedu@
10 years ago
tedu
118f2caf23
factor out a bit of the chunk index code and use it to make sure that a
freed chunk is actually freeable immediately. catch more errors.
hints/ok otto
10 years ago
chl
3acff291fd
Add missing header needed by isdigit().
While there, sort headers.
ok tedu@
10 years ago
tedu
1653fb274d
refactor some of the des crypt code to use fewer globals.
ok miod
10 years ago
jmc
e2130d28c0
update NAME and MLINKS for previous;
10 years ago
tedu
f5ab287545
document crypt_checkpass
10 years ago
sthen
b1478de08d
use $2b in the bcrypt example, ok tedu
10 years ago
tedu
4514bdd79a
stop flushing streams in abort(). it's hackish and unsafe, and no longer
required. try to document this fact and some of the history.
with feedback from deraadt guenther millert
10 years ago
tedu
5d44aecec4
remove md5crypt.
while changing things, add a crypt_checkpass wrapper that handles most of
the edge cases. (not quite ready for production, though.)
ok deraadt
10 years ago
tedu
508b771a99
change to having four freelists per size, to reduce another source of
deterministic behavior. four selected because it's more than three, less
than five. i.e., no particular reason.
10 years ago
otto
d7088c5a04
fix MALLOC_STATS code that was broken in rev 1.159, not compiled in by default
10 years ago
deraadt
a14ce349c7
move reallocarray() to a seperate file so that -portable applications
can avoid reinventing the wheel
ok guenther schwarze
10 years ago
halex
3a717658e6
comment style fix
ok crickets@
10 years ago
tedu
a894866510
missing NULL checks to see if init is needed. found hard way by deraadt.
10 years ago
tedu
7100c7debd
fix stupid commit
10 years ago