• Takashi Iwai's avatar
    ALSA: timer: Make snd_timer_close() really kill pending actions · fe1b26c9
    Takashi Iwai authored
    snd_timer_close() is supposed to close the timer instance and sync
    with the deactivation of pending actions.  However, there are still
    some overlooked cases:
    
    - It calls snd_timer_stop() at the beginning, but some other might
      re-trigger the timer right after that.
    
    - snd_timer_stop() calls del_timer_sync() only when all belonging
      instances are closed.  If multiple instances were assigned to a
      timer object and one is closed, the timer is still running.  Then
      the pending action assigned to this timer might be left.
    
    Actually either of the above is the likely cause of the reported
    syzkaller UAF.
    
    This patch plug these holes by introducing SNDRV_TIMER_IFLG_DEAD
    flag.  This is set at the beginning of snd_timer_close(), and the flag
    is checked at snd_timer_start*() and else, so that no longer new
    action is left after snd_timer_close().
    
    Reported-by: syzbot+d5136d4d3240cbe45a2a@syzkaller.appspotmail.com
    Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
    fe1b26c9
timer.c 55.2 KB