|
|
f7210c |
From 5b1d2144ebd47ea768ca5b3cfcda830433c88efe Mon Sep 17 00:00:00 2001
|
|
|
f7210c |
From: "T.C. Hollingsworth" <tchollingsworth@gmail.com>
|
|
|
f7210c |
Date: Thu, 21 Mar 2013 17:34:19 -0700
|
|
|
f7210c |
Subject: [PATCH] backport fix for CVE-2013-2632 from SVN r13964
|
|
|
f7210c |
|
|
|
f7210c |
---
|
|
|
f7210c |
src/objects-inl.h | 3 ++-
|
|
|
f7210c |
src/objects.h | 7 +++++--
|
|
|
f7210c |
src/parser.cc | 4 ++--
|
|
|
f7210c |
src/parser.h | 5 -----
|
|
|
f7210c |
src/stub-cache.cc | 8 ++++----
|
|
|
f7210c |
5 files changed, 13 insertions(+), 14 deletions(-)
|
|
|
f7210c |
|
|
|
f7210c |
diff --git a/src/objects-inl.h b/src/objects-inl.h
|
|
|
f7210c |
index ea5a93f..4834fa6 100644
|
|
|
f7210c |
--- a/src/objects-inl.h
|
|
|
f7210c |
+++ b/src/objects-inl.h
|
|
|
f7210c |
@@ -3500,8 +3500,9 @@ Code::Flags Code::ComputeFlags(Kind kind,
|
|
|
f7210c |
kind == CALL_IC ||
|
|
|
f7210c |
kind == STORE_IC ||
|
|
|
f7210c |
kind == KEYED_STORE_IC);
|
|
|
f7210c |
+ ASSERT(argc <= Code::kMaxArguments);
|
|
|
f7210c |
// Compute the bit mask.
|
|
|
f7210c |
- int bits = KindField::encode(kind)
|
|
|
f7210c |
+ unsigned int bits = KindField::encode(kind)
|
|
|
f7210c |
| ICStateField::encode(ic_state)
|
|
|
f7210c |
| TypeField::encode(type)
|
|
|
f7210c |
| ExtraICStateField::encode(extra_ic_state)
|
|
|
f7210c |
diff --git a/src/objects.h b/src/objects.h
|
|
|
f7210c |
index 755dd42..47d7757 100644
|
|
|
f7210c |
--- a/src/objects.h
|
|
|
f7210c |
+++ b/src/objects.h
|
|
|
f7210c |
@@ -4180,8 +4180,8 @@ class Code: public HeapObject {
|
|
|
f7210c |
// FLAGS_MIN_VALUE and FLAGS_MAX_VALUE are specified to ensure that
|
|
|
f7210c |
// enumeration type has correct value range (see Issue 830 for more details).
|
|
|
f7210c |
enum Flags {
|
|
|
f7210c |
- FLAGS_MIN_VALUE = kMinInt,
|
|
|
f7210c |
- FLAGS_MAX_VALUE = kMaxInt
|
|
|
f7210c |
+ FLAGS_MIN_VALUE = 0,
|
|
|
f7210c |
+ FLAGS_MAX_VALUE = kMaxUInt32
|
|
|
f7210c |
};
|
|
|
f7210c |
|
|
|
f7210c |
#define CODE_KIND_LIST(V) \
|
|
|
f7210c |
@@ -4644,6 +4644,9 @@ class Code: public HeapObject {
|
|
|
f7210c |
// Signed field cannot be encoded using the BitField class.
|
|
|
f7210c |
static const int kArgumentsCountShift = 14;
|
|
|
f7210c |
static const int kArgumentsCountMask = ~((1 << kArgumentsCountShift) - 1);
|
|
|
f7210c |
+ static const int kArgumentsBits =
|
|
|
f7210c |
+ PlatformSmiTagging::kSmiValueSize - Code::kArgumentsCountShift + 1;
|
|
|
f7210c |
+ static const int kMaxArguments = (1 << kArgumentsBits) - 1;
|
|
|
f7210c |
|
|
|
f7210c |
// This constant should be encodable in an ARM instruction.
|
|
|
f7210c |
static const int kFlagsNotUsedInLookup =
|
|
|
f7210c |
diff --git a/src/parser.cc b/src/parser.cc
|
|
|
f7210c |
index 03e4b03..6da414a 100644
|
|
|
f7210c |
--- a/src/parser.cc
|
|
|
f7210c |
+++ b/src/parser.cc
|
|
|
f7210c |
@@ -4243,7 +4243,7 @@ ZoneList<Expression*>* Parser::ParseArguments(bool* ok) {
|
|
|
f7210c |
while (!done) {
|
|
|
f7210c |
Expression* argument = ParseAssignmentExpression(true, CHECK_OK);
|
|
|
f7210c |
result->Add(argument, zone());
|
|
|
f7210c |
- if (result->length() > kMaxNumFunctionParameters) {
|
|
|
f7210c |
+ if (result->length() > Code::kMaxArguments) {
|
|
|
f7210c |
ReportMessageAt(scanner().location(), "too_many_arguments",
|
|
|
f7210c |
Vector<const char*>::empty());
|
|
|
f7210c |
*ok = false;
|
|
|
f7210c |
@@ -4420,7 +4420,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
|
|
|
f7210c |
|
|
|
f7210c |
top_scope_->DeclareParameter(param_name, VAR);
|
|
|
f7210c |
num_parameters++;
|
|
|
f7210c |
- if (num_parameters > kMaxNumFunctionParameters) {
|
|
|
f7210c |
+ if (num_parameters > Code::kMaxArguments) {
|
|
|
f7210c |
ReportMessageAt(scanner().location(), "too_many_parameters",
|
|
|
f7210c |
Vector<const char*>::empty());
|
|
|
f7210c |
*ok = false;
|
|
|
f7210c |
diff --git a/src/parser.h b/src/parser.h
|
|
|
f7210c |
index 93fd1b8..e36a9b3 100644
|
|
|
f7210c |
--- a/src/parser.h
|
|
|
f7210c |
+++ b/src/parser.h
|
|
|
f7210c |
@@ -449,11 +449,6 @@ class Parser {
|
|
|
f7210c |
Vector<Handle<String> > args);
|
|
|
f7210c |
|
|
|
f7210c |
private:
|
|
|
f7210c |
- // Limit on number of function parameters is chosen arbitrarily.
|
|
|
f7210c |
- // Code::Flags uses only the low 17 bits of num-parameters to
|
|
|
f7210c |
- // construct a hashable id, so if more than 2^17 are allowed, this
|
|
|
f7210c |
- // should be checked.
|
|
|
f7210c |
- static const int kMaxNumFunctionParameters = 32766;
|
|
|
f7210c |
static const int kMaxNumFunctionLocals = 131071; // 2^17-1
|
|
|
f7210c |
|
|
|
f7210c |
enum Mode {
|
|
|
f7210c |
diff --git a/src/stub-cache.cc b/src/stub-cache.cc
|
|
|
f7210c |
index 4119147..8490c7e 100644
|
|
|
f7210c |
--- a/src/stub-cache.cc
|
|
|
f7210c |
+++ b/src/stub-cache.cc
|
|
|
f7210c |
@@ -617,7 +617,7 @@ Handle StubCache::ComputeCallConstant(int argc,
|
|
|
f7210c |
Handle code =
|
|
|
f7210c |
compiler.CompileCallConstant(object, holder, function, name, check);
|
|
|
f7210c |
code->set_check_type(check);
|
|
|
f7210c |
- ASSERT_EQ(flags, code->flags());
|
|
|
f7210c |
+ ASSERT(flags == code->flags());
|
|
|
f7210c |
PROFILE(isolate_,
|
|
|
f7210c |
CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name));
|
|
|
f7210c |
GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code));
|
|
|
f7210c |
@@ -655,7 +655,7 @@ Handle StubCache::ComputeCallField(int argc,
|
|
|
f7210c |
Handle code =
|
|
|
f7210c |
compiler.CompileCallField(Handle<JSObject>::cast(object),
|
|
|
f7210c |
holder, index, name);
|
|
|
f7210c |
- ASSERT_EQ(flags, code->flags());
|
|
|
f7210c |
+ ASSERT(flags == code->flags());
|
|
|
f7210c |
PROFILE(isolate_,
|
|
|
f7210c |
CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name));
|
|
|
f7210c |
GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code));
|
|
|
f7210c |
@@ -692,7 +692,7 @@ Handle StubCache::ComputeCallInterceptor(int argc,
|
|
|
f7210c |
Handle code =
|
|
|
f7210c |
compiler.CompileCallInterceptor(Handle<JSObject>::cast(object),
|
|
|
f7210c |
holder, name);
|
|
|
f7210c |
- ASSERT_EQ(flags, code->flags());
|
|
|
f7210c |
+ ASSERT(flags == code->flags());
|
|
|
f7210c |
PROFILE(isolate(),
|
|
|
f7210c |
CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name));
|
|
|
f7210c |
GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code));
|
|
|
f7210c |
@@ -721,7 +721,7 @@ Handle StubCache::ComputeCallGlobal(int argc,
|
|
|
f7210c |
CallStubCompiler compiler(isolate(), argc, kind, extra_state, cache_holder);
|
|
|
f7210c |
Handle code =
|
|
|
f7210c |
compiler.CompileCallGlobal(receiver, holder, cell, function, name);
|
|
|
f7210c |
- ASSERT_EQ(flags, code->flags());
|
|
|
f7210c |
+ ASSERT(flags == code->flags());
|
|
|
f7210c |
PROFILE(isolate(),
|
|
|
f7210c |
CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name));
|
|
|
f7210c |
GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code));
|
|
|
f7210c |
--
|
|
|
f7210c |
1.8.1.4
|
|
|
f7210c |
|