From 4fae2356d105e394115188a814097c4a95ae0c5d Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 3 May 2014 03:55:35 +0200 Subject: [PATCH] freebsd,linux,sunos: make stack non-executable Link with -z,noexecstack to make stack memory non-executable. Makes shellcode injection through buffer overflows more difficult. Fixes: https://github.com/joyent/node/issues/7542 PR-URL: https://github.com/node-forward/node/pull/8 Reviewed-By: Trevor Norris --- node.gyp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/node.gyp b/node.gyp index daf06c7a7a..2f5cf0e565 100644 --- a/node.gyp +++ b/node.gyp @@ -365,6 +365,12 @@ 'PLATFORM="sunos"', ], }], + [ 'OS=="freebsd" or OS=="linux"', { + 'ldflags': [ '-Wl,-z,noexecstack' ], + }], + [ 'OS=="sunos"', { + 'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ], + }], [ 'OS in "linux freebsd" and node_shared_v8=="false"', { 'ldflags': [