Changeset 263283 in webkit


Ignore:
Timestamp:
Jun 19, 2020 2:00:21 PM (4 years ago)
Author:
mark.lam@apple.com
Message:

Make $vm properties non-configurable, non-enumerable, and non-writable.
https://bugs.webkit.org/show_bug.cgi?id=213395

Reviewed by Saam Barati and Yusuke Suzuki.

JSTests:

  • stress/dollarVM-properties-should-not-be-enumerable.js: Added.

Source/JavaScriptCore:

$vm provides functions for test development and VM debugging. There's no reason
for them to be configurable, enumerable, and writable.

We particularly don't want them to be enumerable as this can trip up some fuzzers.
Fuzzers should not be fuzzing the $vm object which doesn't exist in real world
uses of JavaScriptCore.

  • tools/JSDollarVM.cpp:

(JSC::JSDollarVM::finishCreation):
(JSC::JSDollarVM::addFunction):
(JSC::JSDollarVM::addConstructibleFunction):

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r263240 r263283  
     12020-06-19  Mark Lam  <mark.lam@apple.com>
     2
     3        Make $vm properties non-configurable, non-enumerable, and non-writable.
     4        https://bugs.webkit.org/show_bug.cgi?id=213395
     5
     6        Reviewed by Saam Barati and Yusuke Suzuki.
     7
     8        * stress/dollarVM-properties-should-not-be-enumerable.js: Added.
     9
    1102020-06-18  Saam Barati  <sbarati@apple.com>
    211
  • trunk/Source/JavaScriptCore/ChangeLog

    r263277 r263283  
     12020-06-19  Mark Lam  <mark.lam@apple.com>
     2
     3        Make $vm properties non-configurable, non-enumerable, and non-writable.
     4        https://bugs.webkit.org/show_bug.cgi?id=213395
     5
     6        Reviewed by Saam Barati and Yusuke Suzuki.
     7
     8        $vm provides functions for test development and VM debugging.  There's no reason
     9        for them to be configurable, enumerable, and writable.
     10
     11        We particularly don't want them to be enumerable as this can trip up some fuzzers.
     12        Fuzzers should not be fuzzing the $vm object which doesn't exist in real world
     13        uses of JavaScriptCore.
     14
     15        * tools/JSDollarVM.cpp:
     16        (JSC::JSDollarVM::finishCreation):
     17        (JSC::JSDollarVM::addFunction):
     18        (JSC::JSDollarVM::addConstructibleFunction):
     19
    1202020-06-19  Tuomas Karkkainen  <tuomas.webkit@apple.com>
    221
  • trunk/Source/JavaScriptCore/tools/JSDollarVM.cpp

    r263277 r263283  
    30953095}
    30963096
     3097constexpr unsigned jsDollarVMPropertyAttributes = PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete;
     3098
    30973099void JSDollarVM::finishCreation(VM& vm)
    30983100{
     
    31153117    addFunction(vm, "breakpoint", functionBreakpoint, 0);
    31163118
    3117     putDirectNativeFunction(vm, globalObject, Identifier::fromString(vm, "dfgTrue"), 0, functionDFGTrue, DFGTrueIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum));
    3118     putDirectNativeFunction(vm, globalObject, Identifier::fromString(vm, "ftlTrue"), 0, functionFTLTrue, FTLTrueIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum));
    3119 
    3120     putDirectNativeFunction(vm, globalObject, Identifier::fromString(vm, "cpuMfence"), 0, functionCpuMfence, CPUMfenceIntrinsic, 0);
    3121     putDirectNativeFunction(vm, globalObject, Identifier::fromString(vm, "cpuRdtsc"), 0, functionCpuRdtsc, CPURdtscIntrinsic, 0);
    3122     putDirectNativeFunction(vm, globalObject, Identifier::fromString(vm, "cpuCpuid"), 0, functionCpuCpuid, CPUCpuidIntrinsic, 0);
    3123     putDirectNativeFunction(vm, globalObject, Identifier::fromString(vm, "cpuPause"), 0, functionCpuPause, CPUPauseIntrinsic, 0);
     3119    putDirectNativeFunction(vm, globalObject, Identifier::fromString(vm, "dfgTrue"), 0, functionDFGTrue, DFGTrueIntrinsic, jsDollarVMPropertyAttributes);
     3120    putDirectNativeFunction(vm, globalObject, Identifier::fromString(vm, "ftlTrue"), 0, functionFTLTrue, FTLTrueIntrinsic, jsDollarVMPropertyAttributes);
     3121
     3122    putDirectNativeFunction(vm, globalObject, Identifier::fromString(vm, "cpuMfence"), 0, functionCpuMfence, CPUMfenceIntrinsic, jsDollarVMPropertyAttributes);
     3123    putDirectNativeFunction(vm, globalObject, Identifier::fromString(vm, "cpuRdtsc"), 0, functionCpuRdtsc, CPURdtscIntrinsic, jsDollarVMPropertyAttributes);
     3124    putDirectNativeFunction(vm, globalObject, Identifier::fromString(vm, "cpuCpuid"), 0, functionCpuCpuid, CPUCpuidIntrinsic, jsDollarVMPropertyAttributes);
     3125    putDirectNativeFunction(vm, globalObject, Identifier::fromString(vm, "cpuPause"), 0, functionCpuPause, CPUPauseIntrinsic, jsDollarVMPropertyAttributes);
    31243126    addFunction(vm, "cpuClflush", functionCpuClflush, 2);
    31253127
     
    32443246    DollarVMAssertScope assertScope;
    32453247    Identifier identifier = Identifier::fromString(vm, name);
    3246     putDirect(vm, identifier, JSFunction::create(vm, globalObject, arguments, identifier.string(), function));
     3248    putDirect(vm, identifier, JSFunction::create(vm, globalObject, arguments, identifier.string(), function), jsDollarVMPropertyAttributes);
    32473249}
    32483250
     
    32513253    DollarVMAssertScope assertScope;
    32523254    Identifier identifier = Identifier::fromString(vm, name);
    3253     putDirect(vm, identifier, JSFunction::create(vm, globalObject, arguments, identifier.string(), function, NoIntrinsic, function));
     3255    putDirect(vm, identifier, JSFunction::create(vm, globalObject, arguments, identifier.string(), function, NoIntrinsic, function), jsDollarVMPropertyAttributes);
    32543256}
    32553257
Note: See TracChangeset for help on using the changeset viewer.