Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 8d71b72447bbb496e34da88b62804db96401bed6
https://github.com/WebKit/WebKit/commit/8d71b72447bbb496e34da88b62804db96401bed6
Author: Chris Dumez <[email protected]>
Date: 2026-06-15 (Mon, 15 Jun 2026)
Changed paths:
M Source/WebCore/bindings/js/JSAttrCustom.cpp
M Source/WebCore/dom/Attr.cpp
M Source/WebCore/dom/Attr.h
Log Message:
-----------
Potential use-after-free under JSAttr::visitAdditionalChildren()
https://bugs.webkit.org/show_bug.cgi?id=311242
rdar://173693441
Reviewed by Ryosuke Niwa.
The GC thread was dereferncing Attr::m_element to call opaqueRoot() on
it. This could lead to use-after-free when the Attr's element gets
destroyed concurrently by the main thread.
Address the issue by making the following two changes:
- Make Attr::m_element a CheckedPtr instead of a WeakPtr, to make it clear
it only gets nulled out by Attr::detachFromElementWithValue().
- Introduce a Lock that gets acquired by m_element gets updated on the
main thread and then the GC thread is accessing it.
* Source/WebCore/bindings/js/JSAttrCustom.cpp:
(WebCore::JSAttr::visitAdditionalChildren):
* Source/WebCore/dom/Attr.cpp:
(WebCore::Attr::detachFromElementWithValue):
(WebCore::Attr::attachToElement):
(WebCore::Attr::visitOwnerElementInGCThread):
* Source/WebCore/dom/Attr.h:
Originally-landed-as: 305413.607@rapid/safari-7624.2.5.110-branch
(58480401ef67). rdar://176061076
Canonical link: https://commits.webkit.org/315255@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications