Thomas Anderson would like Phil Yan to review this change.
wayland: Fix UAF in OnTabletToolProximityIn
Synchronous event dispatch during OnTabletToolProximityOut can trigger
a nested message loop, which may result in the destruction of the
WaylandWindow. Using a raw pointer after this call leads to a
Use-After-Free.
This CL fixes this by using a WeakPtr to re-validate the window's
existence before proceeding with the event dispatch.
R=phi...@chromium.org
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
if (!window_weak) {Should this be immediately after line 589? i.e. If that line doesn't run, then the WeakPtr should stay valid.
// Set up delegate1 to destroy window2 when it receives kMouseExited.Wrap variable names in backticks.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +0 |
| Commit-Queue | +2 |
Should this be immediately after line 589? i.e. If that line doesn't run, then the WeakPtr should stay valid.
Done
// Set up delegate1 to destroy window2 when it receives kMouseExited.Wrap variable names in backticks.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
3 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: ui/ozone/platform/wayland/host/wayland_event_source_unittest.cc
Insertions: 6, Deletions: 5.
@@ -383,14 +383,15 @@
auto window2 = CreateWaylandWindowWithParams(PlatformWindowType::kWindow,
kDefaultBounds, &delegate2);
- // Set window1 as focused.
+ // Set `window1` as focused.
event_source->OnTabletToolProximityIn(window1.get(), gfx::PointF(), {},
base::TimeTicks::Now());
- // Set up delegate1 to destroy window2 when it receives kMouseExited.
- // When window1 is the tablet_tool_focused_window_, calling
- // OnTabletToolProximityIn(window2) will call OnTabletToolProximityOut(),
- // which dispatches kMouseExited to window1.
+ // Set up `delegate1` to destroy `window2` when it receives `kMouseExited`.
+ // When `window1` is the `tablet_tool_focused_window_`, calling
+ // `OnTabletToolProximityIn(window2)` will call `OnTabletToolProximityOut()`,
+ // which dispatches `kMouseExited` to `window1`.
+
EXPECT_CALL(delegate1, DispatchEvent(::testing::_))
.WillOnce([&](Event* event) {
if (event->type() == EventType::kMouseExited) {
```
```
The name of the file: ui/ozone/platform/wayland/host/wayland_event_source.cc
Insertions: 1, Deletions: 1.
@@ -583,8 +583,8 @@
const gfx::PointF& location,
const PointerDetails& details,
base::TimeTicks time) {
- base::WeakPtr<WaylandWindow> window_weak = window->AsWeakPtr();
WaylandWindow* old_focus = tablet_tool_focused_window_.get();
+ base::WeakPtr<WaylandWindow> window_weak = window->AsWeakPtr();
if (old_focus && old_focus != window) {
OnTabletToolProximityOut(time);
}
```
wayland: Fix UAF in OnTabletToolProximityIn
Synchronous event dispatch during OnTabletToolProximityOut can trigger
a nested message loop, which may result in the destruction of the
WaylandWindow. Using a raw pointer after this call leads to a
Use-After-Free.
This CL fixes this by using a WeakPtr to re-validate the window's
existence before proceeding with the event dispatch.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |