aboutsummaryrefslogtreecommitdiff
path: root/contrib/devtools
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2020-03-25 08:11:20 +0800
committerfanquake <fanquake@gmail.com>2020-03-26 11:39:34 +0800
commitedaca2dd123cef958699c07ab248cf0ffc71af07 (patch)
tree74b0acce3a4276ffd5dea1338514c1b7672780bc /contrib/devtools
parent1a4e9f32efcc5f6a74290446dc58784fd85c7b31 (diff)
downloadbitcoin-edaca2dd123cef958699c07ab248cf0ffc71af07.tar.xz
scripts: add MACHO NX check to security-check.py
Diffstat (limited to 'contrib/devtools')
-rwxr-xr-xcontrib/devtools/security-check.py10
-rwxr-xr-xcontrib/devtools/test-security-check.py2
2 files changed, 12 insertions, 0 deletions
diff --git a/contrib/devtools/security-check.py b/contrib/devtools/security-check.py
index 21d64e893d..c05c38d513 100755
--- a/contrib/devtools/security-check.py
+++ b/contrib/devtools/security-check.py
@@ -197,6 +197,15 @@ def check_MACHO_NOUNDEFS(executable) -> bool:
return True
return False
+def check_MACHO_NX(executable) -> bool:
+ '''
+ Check for no stack execution
+ '''
+ flags = get_MACHO_executable_flags(executable)
+ if 'ALLOW_STACK_EXECUTION' in flags:
+ return False
+ return True
+
CHECKS = {
'ELF': [
('PIE', check_ELF_PIE),
@@ -212,6 +221,7 @@ CHECKS = {
'MACHO': [
('PIE', check_MACHO_PIE),
('NOUNDEFS', check_MACHO_NOUNDEFS),
+ ('NX', check_MACHO_NX)
]
}
diff --git a/contrib/devtools/test-security-check.py b/contrib/devtools/test-security-check.py
index d65e75f12d..1ca0314f3e 100755
--- a/contrib/devtools/test-security-check.py
+++ b/contrib/devtools/test-security-check.py
@@ -60,6 +60,8 @@ class TestSecurityChecks(unittest.TestCase):
cc = 'clang'
write_testcode(source)
+ self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace', '-Wl,-allow_stack_execute']),
+ (1, executable+': failed PIE NOUNDEFS NX'))
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace']),
(1, executable+': failed PIE NOUNDEFS'))
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie']),