diff options
author | bcook <> | 2016-01-04 02:04:56 +0000 |
---|---|---|
committer | bcook <> | 2016-01-04 02:04:56 +0000 |
commit | 0f894628446dec0db2f00dac168dac6bcb7dd705 (patch) | |
tree | 301d6c8f4507972102a4f8fd3f8365395280a1b8 /src/lib/libcrypto/crypto/arc4random_linux.h | |
parent | fc1b61ff7d2b1dfc2853e6759ce2780b4a72f280 (diff) | |
download | openbsd-0f894628446dec0db2f00dac168dac6bcb7dd705.tar.gz openbsd-0f894628446dec0db2f00dac168dac6bcb7dd705.tar.bz2 openbsd-0f894628446dec0db2f00dac168dac6bcb7dd705.zip |
Calling clone(2) with CLONE_NEWPID yields multiple processes with pid=1.
Work around this particular case by reseeding whenever pid=1, but as guenther@
notes, directly calling clone(2), and then forking to match another pid,
provides other ways to bypass new process detection on Linux.
Hopefully at some point Linux implements something like MAP_INHERIT_ZERO, and
does not invent a corresponding mechanism to subvert it.
Noted by Sebastian Krahmer and the opmsg team.
See http://stealth.openwall.net/crypto/randup.c for a test program.
ok beck@
Diffstat (limited to 'src/lib/libcrypto/crypto/arc4random_linux.h')
-rw-r--r-- | src/lib/libcrypto/crypto/arc4random_linux.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/libcrypto/crypto/arc4random_linux.h b/src/lib/libcrypto/crypto/arc4random_linux.h index 3296fdeca1..303deb5786 100644 --- a/src/lib/libcrypto/crypto/arc4random_linux.h +++ b/src/lib/libcrypto/crypto/arc4random_linux.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: arc4random_linux.h,v 1.9 2015/01/15 06:57:18 deraadt Exp $ */ | 1 | /* $OpenBSD: arc4random_linux.h,v 1.10 2016/01/04 02:04:56 bcook Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> | 4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> |
@@ -60,7 +60,8 @@ _rs_forkdetect(void) | |||
60 | static pid_t _rs_pid = 0; | 60 | static pid_t _rs_pid = 0; |
61 | pid_t pid = getpid(); | 61 | pid_t pid = getpid(); |
62 | 62 | ||
63 | if (_rs_pid == 0 || _rs_pid != pid || _rs_forked) { | 63 | /* XXX unusual calls to clone() can bypass checks */ |
64 | if (_rs_pid == 0 || _rs_pid == 1 || _rs_pid != pid || _rs_forked) { | ||
64 | _rs_pid = pid; | 65 | _rs_pid = pid; |
65 | _rs_forked = 0; | 66 | _rs_forked = 0; |
66 | if (rs) | 67 | if (rs) |