• Takashi Iwai's avatar
    ALSA: seq: Don't break snd_use_lock_sync() loop by timeout · 7bee1c58
    Takashi Iwai authored
    [ Upstream commit 4e7655fd ]
    
    The snd_use_lock_sync() (thus its implementation
    snd_use_lock_sync_helper()) has the 5 seconds timeout to break out of
    the sync loop.  It was introduced from the beginning, just to be
    "safer", in terms of avoiding the stupid bugs.
    
    However, as Ben Hutchings suggested, this timeout rather introduces a
    potential leak or use-after-free that was apparently fixed by the
    commit 2d7d5400 ("ALSA: seq: Fix race during FIFO resize"):
    for example, snd_seq_fifo_event_in() -> snd_seq_event_dup() ->
    copy_from_user() could block for a long time, and snd_use_lock_sync()
    goes timeout and still leaves the cell at releasing the pool.
    
    For fixing such a problem, we remove the break by the timeout while
    still keeping the warning.
    Suggested-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
    Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
    7bee1c58
seq_lock.c 1.47 KB