Skip to content

Commit b980ce4

Browse files
Wang Wenshenggregkh
authored andcommitted
ALSA: timer: Fix use-after-free problem
commit c0317c0 upstream. When the timer instance was add into ack_list but was not currently in process, the user could stop it via snd_timer_stop1() without delete it from the ack_list. Then the user could free the timer instance and when it was actually processed UAF occurred. This issue could be reproduced via testcase snd_timer01 in ltp - running several instances of that testcase at the same time. What I actually met was that the ack_list of the timer broken and the kernel went into deadloop with irqoff. That could be detected by hardlockup detector on board or when we run it on qemu, we could use gdb to dump the ack_list when the console has no response. To fix this issue, we delete the timer instance from ack_list and active_list unconditionally in snd_timer_stop1(). Signed-off-by: Wang Wensheng <wangwensheng4@huawei.com> Suggested-by: Takashi Iwai <tiwai@suse.de> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20211103033517.80531-1-wangwensheng4@huawei.com Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7c6fd52 commit b980ce4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎sound/core/timer.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,13 +624,13 @@ static int snd_timer_stop1(struct snd_timer_instance *timeri, bool stop)
624624
if (!timer)
625625
return -EINVAL;
626626
spin_lock_irqsave(&timer->lock, flags);
627+
list_del_init(&timeri->ack_list);
628+
list_del_init(&timeri->active_list);
627629
if (!(timeri->flags & (SNDRV_TIMER_IFLG_RUNNING |
628630
SNDRV_TIMER_IFLG_START))) {
629631
result = -EBUSY;
630632
goto unlock;
631633
}
632-
list_del_init(&timeri->ack_list);
633-
list_del_init(&timeri->active_list);
634634
if (timer->card && timer->card->shutdown)
635635
goto unlock;
636636
if (stop) {

0 commit comments

Comments
 (0)