Skip to content

Commit 2fa8dc4

Browse files
committed
build: enable v8's siphash for hash seed creation
Triggers the V8_USE_SIPHASH to switch from the internal custom V8 hash seed generation function to an implementation of SipHash. Final step needed to clear up HashWick. PR-URL: #26367 Refs: #23259 Refs: https://darksi.de/12.hashwick-v8-vulnerability/ Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yang Guo <yangguo@chromium.org> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
1 parent e1cd8ac commit 2fa8dc4

File tree

5 files changed

+16
-0
lines changed

5 files changed

+16
-0
lines changed

common.gypi

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
# Old time default, now explicitly stated.
4545
'v8_use_snapshot': 'true',
4646

47+
# Turn on SipHash for hash seed generation, addresses HashWick
48+
'v8_use_siphash': 'true',
49+
4750
# These are more relevant for V8 internal development.
4851
# Refs: https://github.com/nodejs/node/issues/23122
4952
# Refs: https://github.com/nodejs/node/issues/23167

configure.py

+6
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,11 @@
477477
dest='without_snapshot',
478478
help=optparse.SUPPRESS_HELP)
479479

480+
parser.add_option('--without-siphash',
481+
action='store_true',
482+
dest='without_siphash',
483+
help=optparse.SUPPRESS_HELP)
484+
480485
parser.add_option('--code-cache-path',
481486
action='store',
482487
dest='code_cache_path',
@@ -1122,6 +1127,7 @@ def configure_v8(o):
11221127
o['variables']['v8_random_seed'] = 0 # Use a random seed for hash tables.
11231128
o['variables']['v8_promise_internal_field_count'] = 1 # Add internal field to promises for async hooks.
11241129
o['variables']['v8_use_snapshot'] = 'false' if options.without_snapshot else 'true'
1130+
o['variables']['v8_use_siphash'] = 'false' if options.without_siphash else 'true'
11251131
o['variables']['v8_trace_maps'] = 1 if options.trace_maps else 0
11261132
o['variables']['node_use_v8_platform'] = b(not options.without_v8_platform)
11271133
o['variables']['node_use_bundled_v8'] = b(not options.without_bundled_v8)

deps/v8/gypfiles/features.gypi

+3
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@
178178
['v8_use_snapshot=="true" and v8_use_external_startup_data==1', {
179179
'defines': ['V8_USE_EXTERNAL_STARTUP_DATA',],
180180
}],
181+
['v8_use_siphash=="true"', {
182+
'defines': ['V8_USE_SIPHASH',],
183+
}],
181184
['dcheck_always_on!=0', {
182185
'defines': ['DEBUG',],
183186
}],

deps/v8/gypfiles/v8.gyp

+3
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
'v8_enable_verify_predictable=<(v8_enable_verify_predictable)',
131131
'v8_target_cpu=<(v8_target_arch)',
132132
'v8_use_snapshot=<(v8_use_snapshot)',
133+
'v8_use_siphash=<(v8_use_siphash)',
133134
]
134135
},
135136
'conditions': [
@@ -1528,6 +1529,8 @@
15281529
'../src/string-stream.h',
15291530
'../src/strtod.cc',
15301531
'../src/strtod.h',
1532+
'../src/third_party/siphash/halfsiphash.cc',
1533+
'../src/third_party/siphash/halfsiphash.h',
15311534
'../src/third_party/utf8-decoder/utf8-decoder.h',
15321535
'../src/torque-assembler.h',
15331536
'../src/tracing/trace-event.cc',

node.gyp

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
'variables': {
33
'v8_use_snapshot%': 'false',
4+
'v8_use_siphash%': 'true',
45
'v8_trace_maps%': 0,
56
'node_use_dtrace%': 'false',
67
'node_use_etw%': 'false',

0 commit comments

Comments
 (0)