⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 242749 in webkit


Ignore:
Timestamp:
Mar 11, 2019, 3:46:32 PM (7 years ago)
Author:
Wenson Hsieh
Message:

[macOS] Dispatching reentrant "contextmenu" events may cause crashes
https://bugs.webkit.org/show_bug.cgi?id=195571
<rdar://problem/48086046>

Reviewed by Andy Estes.

Source/WebCore:

Make ContextMenuController::handleContextMenuEvent robust against reentrancy by guarding it with a boolean flag.
As demonstrated in the test case, it is currently possible to force WebKit into a bad state by dispatching a
synthetic "contextmenu" event from within the scope of one of the "before(copy|cut|paste)" events triggered as
a result of handling a context menu event.

Test: fast/events/contextmenu-reentrancy-crash.html

  • page/ContextMenuController.cpp:

(WebCore::ContextMenuController::handleContextMenuEvent):

  • page/ContextMenuController.h:

LayoutTests:

Add a test to verify that triggering reentrant "contextmenu" events from script does not cause a crash.

  • fast/events/contextmenu-reentrancy-crash-expected.txt: Added.
  • fast/events/contextmenu-reentrancy-crash.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r242744 r242749  
     12019-03-11  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [macOS] Dispatching reentrant "contextmenu" events may cause crashes
     4        https://bugs.webkit.org/show_bug.cgi?id=195571
     5        <rdar://problem/48086046>
     6
     7        Reviewed by Andy Estes.
     8
     9        Add a test to verify that triggering reentrant "contextmenu" events from script does not cause a crash.
     10
     11        * fast/events/contextmenu-reentrancy-crash-expected.txt: Added.
     12        * fast/events/contextmenu-reentrancy-crash.html: Added.
     13
    1142019-03-11  Truitt Savell  <tsavell@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r242748 r242749  
     12019-03-11  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [macOS] Dispatching reentrant "contextmenu" events may cause crashes
     4        https://bugs.webkit.org/show_bug.cgi?id=195571
     5        <rdar://problem/48086046>
     6
     7        Reviewed by Andy Estes.
     8
     9        Make ContextMenuController::handleContextMenuEvent robust against reentrancy by guarding it with a boolean flag.
     10        As demonstrated in the test case, it is currently possible to force WebKit into a bad state by dispatching a
     11        synthetic "contextmenu" event from within the scope of one of the "before(copy|cut|paste)" events triggered as
     12        a result of handling a context menu event.
     13
     14        Test: fast/events/contextmenu-reentrancy-crash.html
     15
     16        * page/ContextMenuController.cpp:
     17        (WebCore::ContextMenuController::handleContextMenuEvent):
     18        * page/ContextMenuController.h:
     19
    1202019-03-11  Andy Estes  <aestes@apple.com>
    221
  • trunk/Source/WebCore/page/ContextMenuController.cpp

    r240641 r242749  
    6969#include "WindowFeatures.h"
    7070#include "markup.h"
     71#include <wtf/SetForScope.h>
    7172#include <wtf/WallTime.h>
    7273#include <wtf/unicode/CharacterNames.h>
     
    9899void ContextMenuController::handleContextMenuEvent(Event& event)
    99100{
     101    if (m_isHandlingContextMenuEvent)
     102        return;
     103
     104    SetForScope<bool> isHandlingContextMenuEventForScope(m_isHandlingContextMenuEvent, true);
     105
    100106    m_contextMenu = maybeCreateContextMenu(event);
    101107    if (!m_contextMenu)
  • trunk/Source/WebCore/page/ContextMenuController.h

    r211033 r242749  
    9494    RefPtr<ContextMenuProvider> m_menuProvider;
    9595    ContextMenuContext m_context;
     96    bool m_isHandlingContextMenuEvent { false };
    9697};
    9798
Note: See TracChangeset for help on using the changeset viewer.