Skip to content

Commit 4f68369

Browse files
committed
build: disable v8 snapshots
Snapshots speed up start-up by a few milliseconds but are potentially dangerous because of the fixed hash seed that is used for strings and dictionaries, making collision denial-of-service attacks possible. Release builds on iojs.org have snapshots disabled but source builds did not, until now. The risk for individual source builds is low; the binary gets a random 32 bits hash seed that should be hard to guess by an external attacker. It's when binaries are distributed by, for example, a distro vendor that the fixed hash seed becomes a vulnerability, because then it's possible to target a large group of people at once. People that really need the faster start-up time can use the new --with-snapshot configure flag. PR-URL: #585 Reviewed-By: Bert Belder <[email protected]> Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Rod Vagg <[email protected]>
1 parent c0a9d1b commit 4f68369

File tree

5 files changed

+28
-22
lines changed

5 files changed

+28
-22
lines changed

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ pkg: $(PKG)
266266
$(PKG): release-only
267267
rm -rf $(PKGDIR)
268268
rm -rf out/deps out/Release
269-
$(PYTHON) ./configure --without-snapshot --dest-cpu=ia32 --tag=$(TAG)
269+
$(PYTHON) ./configure --dest-cpu=ia32 --tag=$(TAG)
270270
$(MAKE) install V=$(V) DESTDIR=$(PKGDIR)/32
271271
rm -rf out/deps out/Release
272-
$(PYTHON) ./configure --without-snapshot --dest-cpu=x64 --tag=$(TAG)
272+
$(PYTHON) ./configure --dest-cpu=x64 --tag=$(TAG)
273273
$(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
274274
SIGN="$(APP_SIGN)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
275275
lipo $(PKGDIR)/32/usr/local/bin/iojs \
@@ -307,7 +307,7 @@ tar: $(TARBALL)
307307
$(BINARYTAR): release-only
308308
rm -rf $(BINARYNAME)
309309
rm -rf out/deps out/Release
310-
$(PYTHON) ./configure --prefix=/ --without-snapshot --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
310+
$(PYTHON) ./configure --prefix=/ --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
311311
$(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1
312312
cp README.md $(BINARYNAME)
313313
cp LICENSE $(BINARYNAME)
@@ -324,7 +324,7 @@ binary: $(BINARYTAR)
324324

325325
$(PKGSRC): release-only
326326
rm -rf dist out
327-
$(PYTHON) configure --prefix=/ --without-snapshot \
327+
$(PYTHON) configure --prefix=/ \
328328
--dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
329329
$(MAKE) install DESTDIR=dist
330330
(cd dist; find * -type f | sort) > packlist

android-configure

-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ export CXX=arm-linux-androideabi-g++
1414
export LINK=arm-linux-androideabi-g++
1515

1616
./configure \
17-
--without-snapshot \
1817
--dest-cpu=arm \
1918
--dest-os=android

configure

+18-11
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,16 @@ parser.add_option('--without-perfctr',
269269
dest='without_perfctr',
270270
help='build without performance counters')
271271

272+
parser.add_option('--with-snapshot',
273+
action='store_true',
274+
dest='with_snapshot',
275+
help=optparse.SUPPRESS_HELP)
276+
277+
# Dummy option for backwards compatibility.
272278
parser.add_option('--without-snapshot',
273279
action='store_true',
274-
dest='without_snapshot',
275-
help='build without snapshotting V8 libraries. You might want to set'
276-
' this for cross-compiling. [Default: False]')
280+
dest='unused_without_snapshot',
281+
help=optparse.SUPPRESS_HELP)
277282

278283
parser.add_option('--without-ssl',
279284
action='store_true',
@@ -290,6 +295,12 @@ parser.add_option('--xcode',
290295
# set up auto-download list
291296
auto_downloads = nodedownload.parse(options.download_list)
292297

298+
299+
def warn(msg):
300+
prefix = '\033[1m\033[91mWARNING\033[0m' if os.isatty(1) else 'WARNING'
301+
print('%s: %s' % (prefix, msg))
302+
303+
293304
def b(value):
294305
"""Returns the string 'true' if value is truthy, 'false' otherwise."""
295306
if value:
@@ -338,10 +349,6 @@ def check_compiler():
338349
if sys.platform == 'win32':
339350
return
340351

341-
def warn(msg):
342-
prefix = '\033[1m\033[91mWARNING\033[0m' if os.isatty(1) else 'WARNING'
343-
print('%s: %s' % (prefix, msg))
344-
345352
ok, is_clang, clang_version, gcc_version = try_check_compiler(CXX, 'c++')
346353
if not ok:
347354
warn('failed to autodetect C++ compiler version (CXX=%s)' % CXX)
@@ -473,8 +480,8 @@ def configure_arm(o):
473480
o['variables']['arm_float_abi'] = arm_float_abi
474481

475482
# Print warning when snapshot is enabled and building on armv6
476-
if is_arch_armv6() and not options.without_snapshot:
477-
print '\033[1;33mWarning!! When building on ARMv6 use --without-snapshot\033[1;m'
483+
if is_arch_armv6() and options.with_snapshot:
484+
warn('when building on ARMv6, don\'t use --with-snapshot')
478485

479486

480487
def configure_node(o):
@@ -489,7 +496,7 @@ def configure_node(o):
489496
o['variables']['host_arch'] = host_arch
490497
o['variables']['target_arch'] = target_arch
491498

492-
if target_arch != host_arch and not options.without_snapshot:
499+
if target_arch != host_arch and options.with_snapshot:
493500
o['variables']['want_separate_host_toolset'] = 1
494501
else:
495502
o['variables']['want_separate_host_toolset'] = 0
@@ -601,7 +608,7 @@ def configure_v8(o):
601608
o['variables']['v8_no_strict_aliasing'] = 1 # Work around compiler bugs.
602609
o['variables']['v8_optimized_debug'] = 0 # Compile with -O0 in debug builds.
603610
o['variables']['v8_random_seed'] = 0 # Use a random seed for hash tables.
604-
o['variables']['v8_use_snapshot'] = b(not options.without_snapshot)
611+
o['variables']['v8_use_snapshot'] = b(options.with_snapshot)
605612

606613
# assume shared_v8 if one of these is set?
607614
if options.shared_v8_libpath:

node.gyp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
'variables': {
3-
'v8_use_snapshot%': 'true',
3+
'v8_use_snapshot%': 'false',
44
'node_use_dtrace%': 'false',
55
'node_use_etw%': 'false',
66
'node_use_perfctr%': 'false',

vcbuild.bat

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ set msiplatform=x86
1717
set target=Build
1818
set target_arch=ia32
1919
set debug_arg=
20-
set nosnapshot_arg=
20+
set snapshot_arg=
2121
set noprojgen=
2222
set nobuild=
2323
set nosign=
24-
set nosnapshot=
24+
set snapshot=
2525
set test=
2626
set test_args=
2727
set msi=
@@ -48,7 +48,7 @@ if /i "%1"=="x64" set target_arch=x64&goto arg-ok
4848
if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok
4949
if /i "%1"=="nobuild" set nobuild=1&goto arg-ok
5050
if /i "%1"=="nosign" set nosign=1&goto arg-ok
51-
if /i "%1"=="nosnapshot" set nosnapshot=1&goto arg-ok
51+
if /i "%1"=="snapshot" set snapshot=1&goto arg-ok
5252
if /i "%1"=="noetw" set noetw=1&goto arg-ok
5353
if /i "%1"=="noperfctr" set noperfctr=1&goto arg-ok
5454
if /i "%1"=="licensertf" set licensertf=1&goto arg-ok
@@ -79,7 +79,7 @@ if defined jslint goto jslint
7979

8080
if "%config%"=="Debug" set debug_arg=--debug
8181
if "%target_arch%"=="x64" set msiplatform=x64
82-
if defined nosnapshot set nosnapshot_arg=--without-snapshot
82+
if defined snapshot set snapshot_arg=--with-snapshot
8383
if defined noetw set noetw_arg=--without-etw& set noetw_msi_arg=/p:NoETW=1
8484
if defined noperfctr set noperfctr_arg=--without-perfctr& set noperfctr_msi_arg=/p:NoPerfCtr=1
8585

@@ -96,7 +96,7 @@ if defined NIGHTLY set TAG=nightly-%NIGHTLY%
9696
@rem Generate the VS project.
9797
SETLOCAL
9898
if defined VS100COMNTOOLS call "%VS100COMNTOOLS%\VCVarsQueryRegistry.bat"
99-
python configure %download_arg% %i18n_arg% %debug_arg% %nosnapshot_arg% %noetw_arg% %noperfctr_arg% --dest-cpu=%target_arch% --tag=%TAG%
99+
python configure %download_arg% %i18n_arg% %debug_arg% %snapshot_arg% %noetw_arg% %noperfctr_arg% --dest-cpu=%target_arch% --tag=%TAG%
100100
if errorlevel 1 goto create-msvs-files-failed
101101
if not exist node.sln goto create-msvs-files-failed
102102
echo Project files generated.

0 commit comments

Comments
 (0)