Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upsrc: perform integrity checks on built-in code cache #22152
Conversation
This comment has been minimized.
This comment has been minimized.
nodejs-github-bot
added
C++
lib / src
labels
Aug 6, 2018
This comment has been minimized.
This comment has been minimized.
devsnek
reviewed
Aug 6, 2018
lib/internal/bootstrap/cache.js
Outdated
| @@ -48,6 +52,7 @@ module.exports = { | |||
| ), | |||
| builtinSource: Object.assign({}, NativeModule._source), | |||
| getCodeCache, | |||
| getSource, | |||
This comment has been minimized.
This comment has been minimized.
lib/internal/bootstrap/loaders.js
Outdated
| // But that should be rare and can be eased once we make the | ||
| // two bootstrappers cached and checked as well. | ||
| const cache = codeCacheHash[id] && (codeCacheHash[id] === sourceHash[id]) ? | ||
| codeCache[this.id] : undefined; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
The wrapper issue should disappear once we switch to CompileFunctionInContext (enabled by #21571) |
tools/js2c.py
Outdated
| HASH_INITIALIZER = """\ | ||
| CHECK(target->Set(env->context(), | ||
| FIXED_ONE_BYTE_STRING(env->isolate(), "{key}"), | ||
| OneByteString(env->isolate(), "{value}")).FromJust()); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Thanks for the reviews. Addressed the comments. |
TimothyGu
approved these changes
Aug 9, 2018
jasnell
approved these changes
Aug 9, 2018
devsnek
approved these changes
Aug 9, 2018
This comment has been minimized.
This comment has been minimized.
joyeecheung
referenced this pull request
Aug 10, 2018
Closed
Investigate flaky test-module-loading-globalpaths with --worker on #22228
This comment has been minimized.
This comment has been minimized.
|
CI again on custom-suites: https://ci.nodejs.org/job/node-test-commit-custom-suites/622/ |
This comment has been minimized.
This comment has been minimized.
|
Rebuild with freestyle custom suites: https://ci.nodejs.org/job/node-test-pull-request/16368/ |
This comment has been minimized.
This comment has been minimized.
joyeecheung
force-pushed the
joyeecheung:hash-cache-check
branch
from
6c4e775
to
42e79aa
Aug 17, 2018
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
CI is green |
joyeecheung
added
the
author ready
label
Aug 17, 2018
This comment has been minimized.
This comment has been minimized.
|
Landed in 7cbbb27, thanks! |
joyeecheung
closed this
Aug 17, 2018
joyeecheung
added a commit
that referenced
this pull request
Aug 17, 2018
targos
added a commit
that referenced
this pull request
Aug 19, 2018
targos
added a commit
that referenced
this pull request
Sep 3, 2018
This was referenced Sep 6, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
joyeecheung commentedAug 6, 2018
Currently V8 only checks that the length of the source code is the
same as the code used to generate the hash, so we add an additional
check here:
node_code_cache.cc, we compute and include the hash of the
(unwrapped) JavaScript source in both.
and the hash of the code used to generate the cache
(inside the wrapper) is the same.
This is based on the assumptions:
internalBinding('code_cache_hash')must be in sync withinternalBinding('code_cache')(same C++ file)internalBinding('natives_hash')must be in sync withprocess.binding('natives')(same C++ file)internalBinding('natives_hash')is in sync withinternalBinding('natives_hash'), then the (unwrapped)code used to generate
internalBinding('code_cache')should be in sync with the (unwrapped) code in
process.binding('natives')There will be, however, false positives if the wrapper used
to generate the cache is different from the one used at run time,
and the length of the wrapper somehow stays the same.
But that should be rare and can be eased once we make the
two bootstrappers cached and checked as well.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes