Skip to content

Commit fa89a70

Browse files
atulkattiAtul Katti
authored andcommitted
[CVE-2018-8287] Edge - Chakra Internet Explorer - Use after free in jscript9.dll after closing WebBrowserControl - Internal.
1 parent 3ad284a commit fa89a70

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/Runtime/Base/ThreadServiceWrapperBase.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ bool ThreadServiceWrapperBase::ScheduleIdleCollect(uint ticks, bool scheduleAsTa
7878

7979
bool ThreadServiceWrapperBase::IdleCollect()
8080
{
81+
// Tracking service does not AddRef/Release the thread service and only keeps a function pointer and context parameter (this pointer)
82+
// to execute the IdleCollect callback. It is possible that the tracking service gets destroyed as part of the collection
83+
// during this IdleCollect. If that happens then we need to make sure ThreadService (which may be owned by the tracking service)
84+
// is kept alive until this callback completes. Any pending timer is killed in the thread service destructor so we should not get
85+
// any new callbacks after the thread service is destroyed.
86+
AutoAddRefReleaseThreadService autoThreadServiceKeepAlive(this);
87+
8188
Assert(hasScheduledIdleCollect);
8289
IDLE_COLLECT_VERBOSE_TRACE(_u("IdleCollect- reset hasScheduledIdleCollect\n"));
8390
hasScheduledIdleCollect = false;

lib/Runtime/Base/ThreadServiceWrapperBase.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,29 @@ class ThreadServiceWrapperBase : public ThreadServiceWrapper
4141
virtual bool OnScheduleIdleCollect(uint delta, bool scheduleAsTask) = 0;
4242
virtual void OnFinishIdleCollect() = 0;
4343
virtual bool ShouldFinishConcurrentCollectOnIdleCallback() = 0;
44+
virtual void AddRefThreadService() { /* do nothing */ };
45+
virtual void ReleaseThreadService() { /* do nothing */ };
4446

4547
ThreadContext *GetThreadContext() { return threadContext; }
4648

4749
private:
50+
class AutoAddRefReleaseThreadService
51+
{
52+
public:
53+
AutoAddRefReleaseThreadService(ThreadServiceWrapperBase * threadService)
54+
{
55+
this->threadService = threadService;
56+
threadService->AddRefThreadService();
57+
}
58+
59+
~AutoAddRefReleaseThreadService()
60+
{
61+
threadService->ReleaseThreadService();
62+
}
63+
64+
ThreadServiceWrapperBase * threadService;
65+
};
66+
4867
static const unsigned int IdleTicks = 1000; // 1 second
4968
static const unsigned int IdleFinishTicks = 100; // 100 ms;
5069

0 commit comments

Comments
 (0)