Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UPSTREAM: ALSA: timer: Harden slave timer list handling
A slave timer instance might be still accessible in a racy way while operating the master instance as it lacks of locking. Since the master operation is mostly protected with timer->lock, we should cope with it while changing the slave instance, too. Also, some linked lists (active_list and ack_list) of slave instances aren't unlinked immediately at stopping or closing, and this may lead to unexpected accesses. This patch tries to address these issues. It adds spin lock of timer->lock (either from master or slave, which is equivalent) in a few places. For avoiding a deadlock, we ensure that the global slave_active_lock is always locked at first before each timer lock. Also, ack and active_list of slave instances are properly unlinked at snd_timer_stop() and snd_timer_close(). Last but not least, remove the superfluous call of _snd_timer_stop() at removing slave links. This is a noop, and calling it may confuse readers wrt locking. Further cleanup will follow in a later patch. Actually we've got reports of use-after-free by syzkaller fuzzer, and this hopefully fixes these issues. Reported-by: Dmitry Vyukov <dvyukov@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> (cherry picked from commit b5a663a) Signed-off-by: Ben Zhang <benzh@chromium.org> BUG=b:26636060 TEST=Build and boot Ryu Change-Id: I02ec39c7a51d8b2b7948af899811d1bcd4ba8c02 Reviewed-on: https://chromium-review.googlesource.com/329044 Commit-Ready: Ben Zhang <benzh@chromium.org> Tested-by: Ben Zhang <benzh@chromium.org> Reviewed-by: Andrew Bresticker <abrestic@chromium.org> (cherry picked from commit a4fc8d290af4448eb0ca5b6c9b45cefe8638d2ef) Reviewed-on: https://chromium-review.googlesource.com/329138 Commit-Queue: Andrew Bresticker <abrestic@chromium.org> Tested-by: Andrew Bresticker <abrestic@chromium.org>
- Loading branch information