Changeset 175967 in webkit


Ignore:
Timestamp:
Nov 11, 2014 12:36:11 PM (9 years ago)
Author:
commit-queue@webkit.org
Message:

Handle cases in StackVisitor::Frame::existingArguments() when lexicalEnvironment and/or unmodifiedArgumentsRegister is not set up yet
https://bugs.webkit.org/show_bug.cgi?id=138543

Patch by Akos Kiss <akiss@inf.u-szeged.hu> on 2014-11-11
Reviewed by Geoffrey Garen.

Exception fuzzing may may raise exceptions in places where they would be
otherwise impossible. Therefore, a callFrame may lack activation even if
the codeBlock signals need of activation. Also, even if codeBlock
signals the use of arguments, the unmodifiedArgumentsRegister may not be
initialized yet (neither locally nor in lexicalEnvironment).

If codeBlock()->needsActivation() is false, unmodifiedArgumentsRegister
is already checked for Undefined. This patch applies the same check when
the condition is true (and also checks whether
callFrame()->hasActivation()).

  • interpreter/CallFrame.h:

(JSC::ExecState::hasActivation):
Moved to interpreter/CallFrameInlines.h.

  • interpreter/CallFrameInlines.h:

(JSC::CallFrame::hasActivation):
Fixed to verify that the JSValue returned by uncheckedActivation() is a
cell.

  • interpreter/StackVisitor.cpp:

(JSC::StackVisitor::Frame::existingArguments):

Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r175880 r175967  
     12014-11-11  Akos Kiss  <akiss@inf.u-szeged.hu>
     2
     3        Handle cases in StackVisitor::Frame::existingArguments() when lexicalEnvironment and/or unmodifiedArgumentsRegister is not set up yet
     4        https://bugs.webkit.org/show_bug.cgi?id=138543
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Exception fuzzing may may raise exceptions in places where they would be
     9        otherwise impossible. Therefore, a callFrame may lack activation even if
     10        the codeBlock signals need of activation. Also, even if codeBlock
     11        signals the use of arguments, the unmodifiedArgumentsRegister may not be
     12        initialized yet (neither locally nor in lexicalEnvironment).
     13
     14        If codeBlock()->needsActivation() is false, unmodifiedArgumentsRegister
     15        is already checked for Undefined. This patch applies the same check when
     16        the condition is true (and also checks whether
     17        callFrame()->hasActivation()).
     18
     19        * interpreter/CallFrame.h:
     20        (JSC::ExecState::hasActivation):
     21        Moved to interpreter/CallFrameInlines.h.
     22        * interpreter/CallFrameInlines.h:
     23        (JSC::CallFrame::hasActivation):
     24        Fixed to verify that the JSValue returned by uncheckedActivation() is a
     25        cell.
     26        * interpreter/StackVisitor.cpp:
     27        (JSC::StackVisitor::Frame::existingArguments):
     28
    1292014-11-11  Andreas Kling  <akling@apple.com>
    230
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.h

    r173517 r175967  
    5252        }
    5353
    54         bool hasActivation() const { return !!uncheckedActivation(); }
     54        bool hasActivation() const;
    5555        JSLexicalEnvironment* lexicalEnvironment() const;
    5656        JSValue uncheckedActivation() const;
  • trunk/Source/JavaScriptCore/interpreter/CallFrameInlines.h

    r173410 r175967  
    140140}
    141141
     142inline bool CallFrame::hasActivation() const
     143{
     144    JSValue activation = uncheckedActivation();
     145    return !!activation && activation.isCell();
     146}
     147
    142148inline JSValue CallFrame::uncheckedActivation() const
    143149{
  • trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp

    r174821 r175967  
    298298        reg = codeBlock()->argumentsRegister();
    299299
    300     if (codeBlock()->needsActivation())
    301         return jsCast<Arguments*>(callFrame()->lexicalEnvironment()->registerAt(unmodifiedArgumentsRegister(reg).offset()).get());
    302    
    303     JSValue result = callFrame()->r(unmodifiedArgumentsRegister(reg).offset()).jsValue();
    304     if (!result || !result.isCell()) // Protect against Undefined in case we throw in op_enter.
     300    // Care should be taken here since exception fuzzing may raise exceptions in
     301    // places where they would be otherwise impossible. Therefore, callFrame may
     302    // lack activation even if the codeBlock signals need of activation. Also,
     303    // even if codeBlock signals the use of arguments, the
     304    // unmodifiedArgumentsRegister may not be initialized yet (neither locally
     305    // nor in lexicalEnvironment).
     306    JSValue result = jsUndefined();
     307    if (codeBlock()->needsActivation() && callFrame()->hasActivation())
     308        result = callFrame()->lexicalEnvironment()->registerAt(unmodifiedArgumentsRegister(reg).offset()).get();
     309    if (!result || !result.isCell()) // Try local unmodifiedArgumentsRegister if lexicalEnvironment is not present (generally possible) or has not set up registers yet (only possible if fuzzing exceptions).
     310        result = callFrame()->r(unmodifiedArgumentsRegister(reg).offset()).jsValue();
     311    if (!result || !result.isCell()) // Protect against the case when exception fuzzing throws when unmodifiedArgumentsRegister is not set up yet (e.g., in op_enter).
    305312        return 0;
    306313    return jsCast<Arguments*>(result);
Note: See TracChangeset for help on using the changeset viewer.