-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Description
- Version: All
- Platform: All supported platforms
- Subsystem:
This issue is created separately to track the Data Relocation and Protection flag from the issue #18671 to make it independent and more clear to track as #18671 contains several compile flags.
The flag is for linker: -z relro -z now
The RELRO flag was a mitigation technique to harden the data sections of an ELF binary/process and could prevent the modification of GOT entries of a process. Thus able to make node more secure.
I made some investigation and tests based on the flag, It passed the builtin functional tests and have no obvious performance impact on the builtin benchmark tests.
I also made a performance test by loading some native add-ons (all enabled the -z relro -z now
flag), and the result shows that the time spend on loading add-ons only increased 0.54%. Below is my testing steps:
- My machine is:
cpu: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz with 8 cores
memory: 32G
os: Ubuntu 16.04 - Get the code of node-librealsense, node-glfw-3, and opencv4nodejs. Then made minor changes to enable
-z relro -z now
on them. Opencv4nodejs and node-librealsense totally exported about 600 methods and total library size is about 4MB. - time the duration of below command with relro enabled node and 3 relro enabled add-ons as TR1 by:
time /path/to/relro/enabled/node -e "require('node-librealsense');require('node-glfw-3');require('opencv4nodejs');
- time the duration of below command with relro enabled node and only 1 relro enabled add-on as TR2 by:
time /path/to/relro/enabled/node -e "require('node-glfw-3')
- time the duration of below command with default built node and 3 default built add-ons as TD1 by:
time /path/to/default/node -e "require('node-librealsense');require('node-glfw-3');require('opencv4nodejs');
- time the duration of below command with default built node and only 1 default built add-on as TD2 by:
time /path/to/default/node -e "require('node-glfw-3')
- run the above test 1000 times, extract the real time and get the average result:
TR1 (node-librealsense+opencv4nodejs+node-glfw-3): 140.23 ms
TR2 (node-glfw-3): 45.804 ms
TD1 (node-librealsense+opencv4nodejs+node-glfw-3): 139.331 ms
TD2 (node-glfw-3): 45.415 ms
So the time spent on loading node-librealsense+opencv4nodejs is:
when relro enabled: DR1 = TR1 - TR2 = 94.426 ms
when relro not enabled(default built): DD1 = TD1 - TD2 = 93.916 ms
Time increased rate for loading node-librealsense+opencv4nodejs is: (DR1 - DD1)/DD1 = 0.0054. It's 0.54%.
Besides, I compared the time of running: time /path/to/node -e ""
. And result shows a 0.68% time increase.
Based on the above result, it seems to me that adding '-z relro -z now' doesn't impact the performance a lot and we can get more security, what do you think guys?