GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-143756: Fix potential data race in SSLContext.load_cert_chain by colesbury · Pull Request #143818 · python/cpython Conversation
|
| do { (save) = PyEval_SaveThread(); } while(0) | ||
| #define PySSL_END_ALLOW_THREADS_S(save) \ | ||
| do { PyEval_RestoreThread(save); _PySSL_FIX_ERRNO; } while(0) | ||
| #define PySSL_BEGIN_ALLOW_THREADS(self) { \ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
While you are it, can you use a do-while construct? (here we would just have the do {) In addition can you make it multiline with line continuations aligned on a tab multiple? (like PEP-7) TiA.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ditto
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| do { (save) = PyEval_SaveThread(); PyMutex_Lock(mutex); } while(0) | ||
| #define PySSL_END_ALLOW_THREADS_S(save, mutex) \ | ||
| do { PyMutex_Unlock(mutex); PyEval_RestoreThread(save); _PySSL_FIX_ERRNO; } while(0) | ||
| #define PySSL_BEGIN_ALLOW_THREADS_S(save) \ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you use uppercase letters for the macro parameters please?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Let's not do a bunch of extra refactoring in a bugfix PR
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Oh right you want to backport this. I think there will be anyway conflicts so yeah let's not make it more complicate
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (keyfile == Py_None) | ||
| keyfile = NULL; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think this can be added in the if (keyfile) check instead.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ditto; this is existing code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (password != Py_None) { | ||
| if (PyCallable_Check(password)) { | ||
| pw_info.callable = password; | ||
| } else if (!_pwinfo_set(&pw_info, password, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| } else if (!_pwinfo_set(&pw_info, password, | |
| } | |
| else if (!_pwinfo_set(&pw_info, password, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ditto
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (PyCallable_Check(password)) { | ||
| pw_info.callable = password; | ||
| } else if (!_pwinfo_set(&pw_info, password, | ||
| "password should be a string or callable")) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
And realign this adter putting the elseif on its own line
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ditto
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (!PyUnicode_FSConverter(certfile, &certfile_bytes)) { | ||
| if (PyErr_ExceptionMatches(PyExc_TypeError)) { | ||
| PyErr_SetString(PyExc_TypeError, | ||
| "certfile should be a valid filesystem path"); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
For a follow-up: This is a bit misleading. For me such message usually implies a ValueError instead of TypeError. Do we use this formulation for other occurrences of FSConverter?
Maybe: "expecting a path-like object for 'certfile', got ..."
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ditto
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Tests already exist. #143752 runs it with TSan |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry as I was on mobile I didn't see that it was just moving code around. We can refactor this later (I really want to split ssl.c because it is messy to maintain but it is also annoying to create more files...)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
pythongh-143818) Concurrent calls to `load_cert_chain` caused data races in OpenSSL code.
Concurrent calls to SSLContext.load_cert_chain on the same context race on the SSL_CTX default password callback. This is fixed in 3.15 (pythonGH-143818), but under TSAN with instrumented OpenSSL the race is now reported on 3.14, so skip the test that triggers it.
This test spawns 8 threads calling load_cert_chain on the same context, directly triggering the data race on the SSL_CTX default password callback (fixed in 3.15 by pythonGH-143818). It was the test that failed both TSan CI jobs.
…53355) Compile OpenSSL with TSan in the TSan CI job so that data races between Python code and OpenSSL internals are visible to the sanitizer. Also skip test_ssl_in_multiple_threads under TSan: concurrent calls to SSLContext.load_cert_chain on the same context race on the SSL_CTX default password callback. The race is fixed in 3.15+ (GH-143818), but with TSan-instrumented OpenSSL it is now reported on 3.14. (cherry picked from commit fc19ad7) Co-authored-by: Sam Gross <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.