OSDN Git Service

audiohal: Fix UAF of HAL devices in Stream objects
authorMikhail Naganov <mnaganov@google.com>
Wed, 29 Mar 2017 16:31:18 +0000 (09:31 -0700)
committerMikhail Naganov <mnaganov@google.com>
Thu, 30 Mar 2017 15:52:30 +0000 (15:52 +0000)
commit936279e1ffe6bf7e842c46f9a94d98a48dce6754
tree39eadf542d861befe9ca3eed3cf21ba439e52353
parent63e15f079062579a1b1866026eee0fca5d677fb7
audiohal: Fix UAF of HAL devices in Stream objects

Stream objects used to hold a pointer to underlying HAL device
object which they didn't own. Since destruction of server side
objects is asynchronous, it was possible that a Device object
gets destroyed before Stream objects, making all the HAL device
object pointer to become stale.

Fixed by adding a strong reference to Device objects into Stream
objects.

Bug: 36702804
Change-Id: I3da3611afbb91d6fd6410ac5b8af2a2eebfa6dac
Test: ran Loopback app and HAL VTS tests
(cherry picked from commit 96d3573cda6f76bcbfc277e69d94914a565218d8)
audio/2.0/default/Device.cpp
audio/2.0/default/Device.h
audio/2.0/default/StreamIn.cpp
audio/2.0/default/StreamIn.h
audio/2.0/default/StreamOut.cpp
audio/2.0/default/StreamOut.h