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

Changeset 242861 in webkit


Ignore:
Timestamp:
Mar 13, 2019, 1:24:54 AM (7 years ago)
Author:
bshafiei@apple.com
Message:

Cherry-pick r242749. rdar://problem/48839358

[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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242749 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-607-branch
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-607-branch/LayoutTests/ChangeLog

    r242858 r242861  
     12019-03-13  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Cherry-pick r242749. rdar://problem/48839358
     4
     5    [macOS] Dispatching reentrant "contextmenu" events may cause crashes
     6    https://bugs.webkit.org/show_bug.cgi?id=195571
     7    <rdar://problem/48086046>
     8   
     9    Reviewed by Andy Estes.
     10   
     11    Source/WebCore:
     12   
     13    Make ContextMenuController::handleContextMenuEvent robust against reentrancy by guarding it with a boolean flag.
     14    As demonstrated in the test case, it is currently possible to force WebKit into a bad state by dispatching a
     15    synthetic "contextmenu" event from within the scope of one of the "before(copy|cut|paste)" events triggered as
     16    a result of handling a context menu event.
     17   
     18    Test: fast/events/contextmenu-reentrancy-crash.html
     19   
     20    * page/ContextMenuController.cpp:
     21    (WebCore::ContextMenuController::handleContextMenuEvent):
     22    * page/ContextMenuController.h:
     23   
     24    LayoutTests:
     25   
     26    Add a test to verify that triggering reentrant "contextmenu" events from script does not cause a crash.
     27   
     28    * fast/events/contextmenu-reentrancy-crash-expected.txt: Added.
     29    * fast/events/contextmenu-reentrancy-crash.html: Added.
     30   
     31    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     32
     33    2019-03-11  Wenson Hsieh  <wenson_hsieh@apple.com>
     34
     35            [macOS] Dispatching reentrant "contextmenu" events may cause crashes
     36            https://bugs.webkit.org/show_bug.cgi?id=195571
     37            <rdar://problem/48086046>
     38
     39            Reviewed by Andy Estes.
     40
     41            Add a test to verify that triggering reentrant "contextmenu" events from script does not cause a crash.
     42
     43            * fast/events/contextmenu-reentrancy-crash-expected.txt: Added.
     44            * fast/events/contextmenu-reentrancy-crash.html: Added.
     45
    1462019-03-13  Babak Shafiei  <bshafiei@apple.com>
    247
  • branches/safari-607-branch/Source/WebCore/ChangeLog

    r242858 r242861  
     12019-03-13  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Cherry-pick r242749. rdar://problem/48839358
     4
     5    [macOS] Dispatching reentrant "contextmenu" events may cause crashes
     6    https://bugs.webkit.org/show_bug.cgi?id=195571
     7    <rdar://problem/48086046>
     8   
     9    Reviewed by Andy Estes.
     10   
     11    Source/WebCore:
     12   
     13    Make ContextMenuController::handleContextMenuEvent robust against reentrancy by guarding it with a boolean flag.
     14    As demonstrated in the test case, it is currently possible to force WebKit into a bad state by dispatching a
     15    synthetic "contextmenu" event from within the scope of one of the "before(copy|cut|paste)" events triggered as
     16    a result of handling a context menu event.
     17   
     18    Test: fast/events/contextmenu-reentrancy-crash.html
     19   
     20    * page/ContextMenuController.cpp:
     21    (WebCore::ContextMenuController::handleContextMenuEvent):
     22    * page/ContextMenuController.h:
     23   
     24    LayoutTests:
     25   
     26    Add a test to verify that triggering reentrant "contextmenu" events from script does not cause a crash.
     27   
     28    * fast/events/contextmenu-reentrancy-crash-expected.txt: Added.
     29    * fast/events/contextmenu-reentrancy-crash.html: Added.
     30   
     31    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     32
     33    2019-03-11  Wenson Hsieh  <wenson_hsieh@apple.com>
     34
     35            [macOS] Dispatching reentrant "contextmenu" events may cause crashes
     36            https://bugs.webkit.org/show_bug.cgi?id=195571
     37            <rdar://problem/48086046>
     38
     39            Reviewed by Andy Estes.
     40
     41            Make ContextMenuController::handleContextMenuEvent robust against reentrancy by guarding it with a boolean flag.
     42            As demonstrated in the test case, it is currently possible to force WebKit into a bad state by dispatching a
     43            synthetic "contextmenu" event from within the scope of one of the "before(copy|cut|paste)" events triggered as
     44            a result of handling a context menu event.
     45
     46            Test: fast/events/contextmenu-reentrancy-crash.html
     47
     48            * page/ContextMenuController.cpp:
     49            (WebCore::ContextMenuController::handleContextMenuEvent):
     50            * page/ContextMenuController.h:
     51
    1522019-03-13  Babak Shafiei  <bshafiei@apple.com>
    253
  • branches/safari-607-branch/Source/WebCore/page/ContextMenuController.cpp

    r238894 r242861  
    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)
  • branches/safari-607-branch/Source/WebCore/page/ContextMenuController.h

    r211033 r242861  
    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.