Changeset 216953 in webkit


Ignore:
Timestamp:
May 16, 2017, 4:06:53 PM (8 years ago)
Author:
mark.lam@apple.com
Message:

WorkerRunLoop::Task::performTask() needs to null check context->script() before use.
https://bugs.webkit.org/show_bug.cgi?id=172193
<rdar://problem/32225346>

Reviewed by Filip Pizlo.

According to https://build-safari.apple.com/results/Trunk%20Fuji%20GuardMalloc%20Production%20WK2%20Tests/r216929_459760e0918316187c8e52c6585a3a9ba9181204%20(12066)/results.html,
we see a crash with this crash trace:

Thread 13 Crashed:: WebCore: Worker
0 com.apple.WebCore 0x00000001099607b2 WebCore::WorkerScriptController::isTerminatingExecution() const + 18
1 com.apple.WebCore 0x000000010995ebbf WebCore::WorkerRunLoop::runCleanupTasks(WebCore::WorkerGlobalScope*) + 143
2 com.apple.WebCore 0x000000010995e80f WebCore::WorkerRunLoop::run(WebCore::WorkerGlobalScope*) + 111
3 com.apple.WebCore 0x00000001099621b6 WebCore::WorkerThread::workerThread() + 742
4 com.apple.JavaScriptCore 0x000000010a964b92 WTF::threadEntryPoint(void*) + 178
5 com.apple.JavaScriptCore 0x000000010a964a69 WTF::wtfThreadEntryPoint(void*) + 121
6 libsystem_pthread.dylib 0x00007fffbdb5caab _pthread_body + 180
7 libsystem_pthread.dylib 0x00007fffbdb5c9f7 _pthread_start + 286
8 libsystem_pthread.dylib 0x00007fffbdb5c1fd thread_start + 13

... and the crashing address is:

Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000022

0x0000000000000022 is the offset of m_scheduledTerminationMutex in the
WorkerScriptController. This means that WorkerScriptController::isTerminatingExecution()
is passed a NULL this pointer. This means that it's possible to have a race
where a WorkerRunLoop::Task gets enqueued beyond the Cleanup task that deletes the
context->script(). As a result, WorkerRunLoop::Task::performTask() (called by
runCleanupTasks()) may see a null context->script().

Hence, WorkerRunLoop::Task::performTask() should null check context->script()
before invoking the isTerminatingExecution() query on it.

No new tests because this is already covered by existing tests.

  • workers/WorkerRunLoop.cpp:

(WebCore::WorkerRunLoop::Task::performTask):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r216952 r216953  
     12017-05-16  Mark Lam  <mark.lam@apple.com>
     2
     3        WorkerRunLoop::Task::performTask() needs to null check context->script() before use.
     4        https://bugs.webkit.org/show_bug.cgi?id=172193
     5        <rdar://problem/32225346>
     6
     7        Reviewed by Filip Pizlo.
     8
     9        According to https://build-safari.apple.com/results/Trunk%20Fuji%20GuardMalloc%20Production%20WK2%20Tests/r216929_459760e0918316187c8e52c6585a3a9ba9181204%20(12066)/results.html,
     10        we see a crash with this crash trace:
     11
     12        Thread 13 Crashed:: WebCore: Worker
     13        0 com.apple.WebCore        0x00000001099607b2 WebCore::WorkerScriptController::isTerminatingExecution() const + 18
     14        1 com.apple.WebCore        0x000000010995ebbf WebCore::WorkerRunLoop::runCleanupTasks(WebCore::WorkerGlobalScope*) + 143
     15        2 com.apple.WebCore        0x000000010995e80f WebCore::WorkerRunLoop::run(WebCore::WorkerGlobalScope*) + 111
     16        3 com.apple.WebCore        0x00000001099621b6 WebCore::WorkerThread::workerThread() + 742
     17        4 com.apple.JavaScriptCore 0x000000010a964b92 WTF::threadEntryPoint(void*) + 178
     18        5 com.apple.JavaScriptCore 0x000000010a964a69 WTF::wtfThreadEntryPoint(void*) + 121
     19        6 libsystem_pthread.dylib  0x00007fffbdb5caab _pthread_body + 180
     20        7 libsystem_pthread.dylib  0x00007fffbdb5c9f7 _pthread_start + 286
     21        8 libsystem_pthread.dylib  0x00007fffbdb5c1fd thread_start + 13
     22
     23        ... and the crashing address is:
     24
     25        Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000022
     26
     27        0x0000000000000022 is the offset of m_scheduledTerminationMutex in the
     28        WorkerScriptController.  This means that WorkerScriptController::isTerminatingExecution()
     29        is passed a NULL this pointer.  This means that it's possible to have a race
     30        where a WorkerRunLoop::Task gets enqueued beyond the Cleanup task that deletes the
     31        context->script().  As a result, WorkerRunLoop::Task::performTask() (called by
     32        runCleanupTasks()) may see a null context->script().
     33
     34        Hence, WorkerRunLoop::Task::performTask() should null check context->script()
     35        before invoking the isTerminatingExecution() query on it.
     36
     37        No new tests because this is already covered by existing tests.
     38
     39        * workers/WorkerRunLoop.cpp:
     40        (WebCore::WorkerRunLoop::Task::performTask):
     41
    1422017-05-16  Youenn Fablet  <youenn@apple.com>
    243
  • trunk/Source/WebCore/workers/WorkerRunLoop.cpp

    r216876 r216953  
    255255void WorkerRunLoop::Task::performTask(WorkerGlobalScope* context)
    256256{
    257     ASSERT(context->script());
    258     if ((!context->isClosing() && !context->script()->isTerminatingExecution()) || m_task.isCleanupTask())
     257    if ((!context->isClosing() && context->script() && !context->script()->isTerminatingExecution()) || m_task.isCleanupTask())
    259258        m_task.performTask(*context);
    260259}
Note: See TracChangeset for help on using the changeset viewer.