summaryrefslogtreecommitdiff
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-12-30 17:59:19 -0800
committerGregory P. Smith <greg@krypto.org>2018-12-30 17:59:19 -0800
commit01b9664740307b39c2907bd84cbb0b2c35be9df4 (patch)
tree983c88561c514057388cfdd3298a8e35ceff3447 /Modules/socketmodule.c
parentc74061d49b2b8275b376e212cccf2922d022e607 (diff)
downloadcpython-git-01b9664740307b39c2907bd84cbb0b2c35be9df4.tar.gz
bpo-35214: MSan workarounds for socket, time, and test_faulthandler. (GH-11375) (GH-11378)
Add Clang Memory Sanitizer build instrumentation to work around false positives from the socket and time modules as well as skipping a couple test_faulthandler tests. (cherry picked from commit b474e6774d60fa67d5373e361a0ed53c18b24f53) Co-authored-by: Gregory P. Smith <greg@krypto.org>
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index e6d3f8be6e..661e1bdf57 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -100,6 +100,10 @@ Local naming conventions:
#include "Python.h"
#include "structmember.h"
+#ifdef _Py_MEMORY_SANITIZER
+# include <sanitizer/msan_interface.h>
+#endif
+
/* Socket object documentation */
PyDoc_STRVAR(sock_doc,
"socket(family=AF_INET, type=SOCK_STREAM, proto=0) -> socket object\n\
@@ -6463,7 +6467,23 @@ socket_if_nameindex(PyObject *self, PyObject *arg)
return NULL;
}
+#ifdef _Py_MEMORY_SANITIZER
+ __msan_unpoison(ni, sizeof(ni));
+ __msan_unpoison(&ni[0], sizeof(ni[0]));
+#endif
for (i = 0; ni[i].if_index != 0 && i < INT_MAX; i++) {
+#ifdef _Py_MEMORY_SANITIZER
+ /* This one isn't the end sentinel, the next one must exist. */
+ __msan_unpoison(&ni[i+1], sizeof(ni[0]));
+ /* Otherwise Py_BuildValue internals are flagged by MSan when
+ they access the not-msan-tracked if_name string data. */
+ {
+ char *to_sanitize = ni[i].if_name;
+ do {
+ __msan_unpoison(to_sanitize, 1);
+ } while (*to_sanitize++ != '\0');
+ }
+#endif
PyObject *ni_tuple = Py_BuildValue("IO&",
ni[i].if_index, PyUnicode_DecodeFSDefault, ni[i].if_name);