python3.11/00187-remove-pthread-atfork.patch
Bohuslav Kabrda f5250ecae7 Update to Python 3.4 alpha 4.
- Refreshed patches: 55 (systemtap), 102 (lib64), 111 (no static lib),
114 (statvfs flags), 132 (unittest rpmbuild hooks), 134 (fix COUNT_ALLOCS in
test_sys), 143 (tsc on ppc64), 146 (hashlib fips), 153 (test gdb noise),
157 (UID+GID overflows), 173 (ENOPROTOOPT in bind_port), 186 (dont raise
from py_compile)
- Removed patches: 129 (test_subprocess nonreadable dir - no longer fails in
Koji), 142 (the mock issue that caused this is fixed)
- Added patch 187 (remove thread atfork) - will be in next version
- Refreshed script for checking pyc and pyo timestamps with new ignored files.
- The fips patch is disabled for now until upstream makes a final decision
what to do with sha3 implementation for 3.4.0.
2013-11-05 12:40:00 +01:00

90 lines
2.7 KiB
Diff

diff -r 6fdbb81b4020 -r 705f2addd0f0 Modules/_ssl.c
--- a/Modules/_ssl.c Tue Oct 29 12:14:55 2013 +0100
+++ b/Modules/_ssl.c Tue Oct 29 21:11:55 2013 +0100
@@ -19,9 +19,6 @@
#ifdef WITH_THREAD
#include "pythread.h"
-#ifdef HAVE_PTHREAD_ATFORK
-# include <pthread.h>
-#endif
#define PySSL_BEGIN_ALLOW_THREADS_S(save) \
do { if (_ssl_locks_count>0) { (save) = PyEval_SaveThread(); } } while (0)
@@ -2950,64 +2947,6 @@
Returns number of bytes read. Raises SSLError if connection to EGD\n\
fails or if it does not provide enough data to seed PRNG.");
-/* Seed OpenSSL's PRNG at fork(), http://bugs.python.org/issue18747
- *
- * The parent 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
- * stack protection canary and automatic variables.
- * The code is inspired by Apache's ssl_rand_seed() function.
- *
- * Note:
- * The code uses pthread_atfork() until Python has a proper atfork API. The
- * handlers are not removed from the child process. A parent handler is used
- * instead of a child handler because fork() is supposed to be async-signal
- * safe but the handler calls unsafe functions.
- */
-
-#if defined(HAVE_PTHREAD_ATFORK) && defined(WITH_THREAD)
-#define PYSSL_RAND_ATFORK 1
-
-static void
-PySSL_RAND_atfork_parent(void)
-{
- struct {
- char stack[128]; /* uninitialized (!) stack data, 128 is an
- arbitrary number. */
- pid_t pid; /* current pid */
- _PyTime_timeval tp; /* current time */
- } seed;
-
-#ifdef WITH_VALGRIND
- VALGRIND_MAKE_MEM_DEFINED(seed.stack, sizeof(seed.stack));
-#endif
- seed.pid = getpid();
- _PyTime_gettimeofday(&(seed.tp));
- RAND_add((unsigned char *)&seed, sizeof(seed), 0.0);
-}
-
-static int
-PySSL_RAND_atfork(void)
-{
- static int registered = 0;
- int retval;
-
- if (registered)
- return 0;
-
- retval = pthread_atfork(NULL, /* prepare */
- PySSL_RAND_atfork_parent, /* parent */
- NULL); /* child */
- if (retval != 0) {
- PyErr_SetFromErrno(PyExc_OSError);
- return -1;
- }
- registered = 1;
- return 0;
-}
-#endif /* HAVE_PTHREAD_ATFORK */
-
#endif /* HAVE_OPENSSL_RAND */
@@ -3623,10 +3561,5 @@
if (r == NULL || PyModule_AddObject(m, "_OPENSSL_API_VERSION", r))
return NULL;
-#ifdef PYSSL_RAND_ATFORK
- if (PySSL_RAND_atfork() == -1)
- return NULL;
-#endif
-
return m;
}