diff options
author | bcook <> | 2016-01-04 02:04:56 +0000 |
---|---|---|
committer | bcook <> | 2016-01-04 02:04:56 +0000 |
commit | 22d4dbcaf1865fd8350ef5930ed1c8b375cbef42 (patch) | |
tree | 301d6c8f4507972102a4f8fd3f8365395280a1b8 /src/lib | |
parent | 3c78bc879ca4a6912fae9f0dcf0053c399e44a69 (diff) | |
download | openbsd-22d4dbcaf1865fd8350ef5930ed1c8b375cbef42.tar.gz openbsd-22d4dbcaf1865fd8350ef5930ed1c8b375cbef42.tar.bz2 openbsd-22d4dbcaf1865fd8350ef5930ed1c8b375cbef42.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')
-rw-r--r-- | src/lib/libcrypto/arc4random/arc4random_linux.h | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/crypto/arc4random_linux.h | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/libcrypto/arc4random/arc4random_linux.h b/src/lib/libcrypto/arc4random/arc4random_linux.h index 3296fdeca1..303deb5786 100644 --- a/src/lib/libcrypto/arc4random/arc4random_linux.h +++ b/src/lib/libcrypto/arc4random/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) |
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) |