Skip to content

Commit

Permalink
Backwards compatibility fixes
Browse files Browse the repository at this point in the history
- Older pythons don't know EXT_SUFFIX
- Linux 4.17-4.19 know PR_GET_SPECULATION_CTRL but not
  PR_SPEC_INDIRECT_BRANCH
  • Loading branch information
seveas committed Nov 2, 2020
1 parent 4668eea commit 9709940
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions _prctlmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ prctl_prctl(PyObject *self, PyObject *args)
#endif
#ifdef PR_GET_SPECULATION_CTRL
case(PR_SET_SPECULATION_CTRL):
#ifdef PR_SPEC_INDIRECT_BRANCH
if(arg != PR_SPEC_STORE_BYPASS && arg != PR_SPEC_INDIRECT_BRANCH) {
#else
if(arg != PR_SPEC_STORE_BYPASS) {
#endif
PyErr_SetString(PyExc_ValueError, "Invalid speculation control setting");
return NULL;
}
Expand All @@ -193,7 +197,11 @@ prctl_prctl(PyObject *self, PyObject *args)
}
/* Intentionally not breaking */
case(PR_GET_SPECULATION_CTRL):
#ifdef PR_SPEC_INDIRECT_BRANCH
if(arg != PR_SPEC_STORE_BYPASS && arg != PR_SPEC_INDIRECT_BRANCH) {
#else
if(arg != PR_SPEC_STORE_BYPASS) {
#endif
PyErr_SetString(PyExc_ValueError, "Invalid speculation control setting");
return NULL;
}
Expand Down Expand Up @@ -793,7 +801,9 @@ PyInit__prctl(void)
#ifdef PR_SET_SPECULATION_CTRL
namedattribute(SPECULATION_CTRL);
namedconstant(PR_SPEC_STORE_BYPASS);
#ifdef PR_SPEC_INDIRECT_BRANCH
namedconstant(PR_SPEC_INDIRECT_BRANCH);
#endif
namedconstant(PR_SPEC_PRCTL);
namedconstant(PR_SPEC_ENABLE);
namedconstant(PR_SPEC_DISABLE);
Expand Down
2 changes: 1 addition & 1 deletion test_prctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
so = '.so'
try:
import sysconfig
so = sysconfig.get_config_var('EXT_SUFFIX')
so = sysconfig.get_config_var('EXT_SUFFIX') or sysconfig.get_config_var('SO')
except ImportError:
pass

Expand Down

0 comments on commit 9709940

Please sign in to comment.