Make sure that all extension functions do null check for render frame host in callbacks. |
|||||||||
Issue descriptionWhen posting a task, render frame host may be gone. It's not easy to reproduce, but it can happen. We fix these issues on case by case basis, but this keeps happening, as it's very easy to miss this. Maybe we should rename ExtensionFunction::render_frame_host() to ExtensionFunction::GetRenderFrameHostAsWeakPtr. Then it would be obvious that this weak pointer has to be null checked.
,
Jul 5 2017
We hit this issue again in crbug.com/673459. It's like 4th time, and each time it's hard to debug. I'm pretty sure we have plenty of other instances of this very same issue. I'd strongly suggest to use a weak pointer here. It will unlikely cause any performance regression but it would guarantee that these bugs will never happen again.
,
Jul 5 2017
How would a weak ptr have helped in crbug.com/673459? The code in question never checked the return result of render_frame_host(), and calling the operator -> on an invalidated weak ptr still crashes. It's true that there would be benefit in having a null access rather than a UAF, but from a "do we crash or don't we", it doesn't seem like this would help. Am I missing something?
,
Jul 6 2017
I wanted to change the getter ExtensionFunction::render_frame_host() into ExtensionFunction::GetRenderFrameHostAsWeakPtr(). Though when I think about it again, it looks like an overkill. I still do believe that we can do something here to avoid this bug happening again. How about renaming the getter into a method like: GetRenderFrameHostOrNull(). It's verbose, but I believe everyone will do a null check after calling such method. Alternatively maybe we could remove refcounting from ExtensionFunction and make it WeakPtrFactory, then make the object gone with render frame host. I don't see much point in continuing executing an extension function after the host is gone, as we can't even post the response.
,
Nov 16 2017
,
Dec 8 2017
,
Dec 8 2017
,
Jan 31 2018
,
Feb 1 2018
,
Feb 23 2018
,
Feb 28 2018
,
Oct 31
|
|||||||||
►
Sign in to add a comment |
|||||||||
Comment 1 by rdevlin....@chromium.org
, May 26 2017