Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2b22093a
Commit
2b22093a
authored
Oct 27, 2013
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #19227: Try to fix deadlocks caused by re-seeding then OpenSSL
pseudo-random number generator on fork().
parent
0059d9ff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_ssl.c
Modules/_ssl.c
+8
-7
No files found.
Misc/NEWS
View file @
2b22093a
...
...
@@ -81,6 +81,9 @@ Core and Builtins
Library
-------
-
Issue
#
19227
:
Try
to
fix
deadlocks
caused
by
re
-
seeding
then
OpenSSL
pseudo
-
random
number
generator
on
fork
().
-
Issue
#
16037
:
HTTPMessage
.
readheaders
()
raises
an
HTTPException
when
more
than
100
headers
are
read
.
Adapted
from
patch
by
Jyrki
Pulliainen
.
...
...
Modules/_ssl.c
View file @
2b22093a
...
...
@@ -2586,7 +2586,7 @@ fails or if it does not provide enough data to seed PRNG.");
/* Seed OpenSSL's PRNG at fork(), http://bugs.python.org/issue18747
*
* The p
arent
handler seeds the PRNG from pseudo-random data like pid, the
* The p
repare
handler seeds the PRNG from pseudo-random data like pid, the
* current time (miliseconds or seconds) and an uninitialized array.
* The array contains stack variables that are impossible to predict
* on most systems, e.g. function return address (subject to ASLR), the
...
...
@@ -2595,16 +2595,17 @@ fails or if it does not provide enough data to seed PRNG.");
*
* Note:
* The code uses pthread_atfork() until Python has a proper atfork API. The
* handlers are not removed from the child process. A p
arent
handler is used
* handlers are not removed from the child process. A p
repare
handler is used
* instead of a child handler because fork() is supposed to be async-signal
* safe but the handler calls unsafe functions.
* safe but the handler calls unsafe functions. A parent handler has caused
* other problems, see issue #19227.
*/
#if defined(HAVE_PTHREAD_ATFORK) && defined(WITH_THREAD)
#define PYSSL_RAND_ATFORK 1
static
void
PySSL_RAND_atfork_p
arent
(
void
)
PySSL_RAND_atfork_p
repare
(
void
)
{
struct
{
char
stack
[
128
];
/* uninitialized (!) stack data, 128 is an
...
...
@@ -2630,9 +2631,9 @@ PySSL_RAND_atfork(void)
if
(
registered
)
return
0
;
retval
=
pthread_atfork
(
NULL
,
/* prepare */
PySSL_RAND_atfork_parent
,
/* parent */
NULL
);
/* child */
retval
=
pthread_atfork
(
PySSL_RAND_atfork_prepare
,
/* prepare */
NULL
,
/* parent */
NULL
);
/* child */
if
(
retval
!=
0
)
{
PyErr_SetFromErrno
(
PyExc_OSError
);
return
-
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment