-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Add signature to SET_PROTOTYPE_METHOD and use args.Holder() in methods. #7261
Conversation
Thank you for contributing this pull request! Here are a few pointers to make sure your submission will be considered for inclusion. Commit cscott/node@37f8296 has the following error(s):
The following commiters were not found in the CLA:
You can fix all these things without opening another issue. Please see CONTRIBUTING.md for more information |
I think this may have serious impact on performance of crossing C++/JS boundary... cc @trevnorris |
It may (or may not) have a performance impact, but it has serious security |
@cscott you should never directly expose C++ methods to JS if you care about security, they should always be wrapped in a javascript objects. And another note, if you give access to C++ stuff to the untrusted code - application is already vulnerable. |
It generally does but this looks okay. Upstream V8 won't inline API function calls that have non-trivial signatures but here the only restriction is on the receiver. |
@bnoordhuis Is there going to be much performance difference between the following two snippets? template<typename T>
Local<Object> FunctionCallbackInfo<T>::This() const {
return Local<Object>(reinterpret_cast<Object*>(values_ + 1));
}
template<typename T>
Local<Object> FunctionCallbackInfo<T>::Holder() const {
return Local<Object>(reinterpret_cast<Object*>(
&implicit_args_[kHolderIndex]));
} |
@@ -196,7 +196,7 @@ void UDPWrap::Bind6(const FunctionCallbackInfo<Value>& args) { | |||
#define X(name, fn) \ | |||
void UDPWrap::name(const FunctionCallbackInfo<Value>& args) { \ | |||
HandleScope scope(args.GetIsolate()); \ | |||
UDPWrap* wrap = Unwrap<UDPWrap>(args.This()); \ | |||
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder()); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: forgot to remove a space before the \
. makes the line exceed 80 chars.
@indutny If this is added, can we add a custom cpplint check like |
There should be no measurable difference, they're both bitcasts of a stack slot. That's assuming they're in the same cache line but even if that isn't the case, I'd be pretty amazed if you could make that show up during profiling. |
Well, I haven't been able to find any noticeable performance impact. So I'm fine with this. THB I only half get how |
@trevnorris about linter: go for it :) |
Rebased on current HEAD; fixed style issues flagged by @trevnorris above. |
The test failures appear to be due to #7309, not this patch. |
This prevents segfaults when a native method is reassigned to a different object (which corrupts `args.This()`). When unwrapping, clients should use `args.Holder()` instead of `args.This()`. Closes nodejs#6690.
Rebased on current Note that b = new Buffer(8);
o = { fill: b.fill };
o.fill(0); // segfaults |
@cscott True. The reason for that is |
Merged in 08a5b44. |
Thanks! |
This prevents segfaults when a native method is reassigned to a different
object to corrupt
args.This()
.Closes #6690.