Bug 226595

Summary: [Hardening] Stop storing raw pointers inside WebIDBServer::m_connections
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebKit2Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, kkinnunen, rniwa, sihui_liu, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch ews-feeder: commit-queue-

Description Chris Dumez 2021-06-03 13:25:00 PDT
Stop storing raw pointers inside WebIDBServer::m_connections and use a WeakHashSet instead.
Comment 1 Chris Dumez 2021-06-03 13:29:00 PDT
Created attachment 430495 [details]
Patch
Comment 2 Ryosuke Niwa 2021-06-03 13:42:38 PDT
Comment on attachment 430495 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=430495&action=review

> Source/WebKit/NetworkProcess/IndexedDB/WebIDBServer.h:106
> +    WeakHashSet<IPC::Connection> m_connections; // Only used on the main thread.

It's unfortunate that we can't assert this.
Comment 3 Chris Dumez 2021-06-03 13:44:34 PDT
(In reply to Ryosuke Niwa from comment #2)
> Comment on attachment 430495 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=430495&action=review
> 
> > Source/WebKit/NetworkProcess/IndexedDB/WebIDBServer.h:106
> > +    WeakHashSet<IPC::Connection> m_connections; // Only used on the main thread.
> 
> It's unfortunate that we can't assert this.

Well, we do have assertions in the places where it is used. But I agree I wish there was a way to enforce that a particular data member can only be used on the main thread. I guess we could come up with a MainThreadOnly<T> type that has the assertions embedded :P
Comment 4 Ryosuke Niwa 2021-06-03 13:52:54 PDT
(In reply to Chris Dumez from comment #3)
> (In reply to Ryosuke Niwa from comment #2)
> > Comment on attachment 430495 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=430495&action=review
> > 
> > > Source/WebKit/NetworkProcess/IndexedDB/WebIDBServer.h:106
> > > +    WeakHashSet<IPC::Connection> m_connections; // Only used on the main thread.
> > 
> > It's unfortunate that we can't assert this.
> 
> Well, we do have assertions in the places where it is used. But I agree I
> wish there was a way to enforce that a particular data member can only be
> used on the main thread. I guess we could come up with a MainThreadOnly<T>
> type that has the assertions embedded :P

Yeah, that might make sense.
Comment 5 EWS 2021-06-03 14:47:28 PDT
Committed r278422 (238446@main): <https://commits.webkit.org/238446@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 430495 [details].
Comment 6 Radar WebKit Bug Importer 2021-06-03 14:48:22 PDT
<rdar://problem/78837612>