Skip to content

Commit

Permalink
ALSA: seq: Fix race during FIFO resize
Browse files Browse the repository at this point in the history
When a new event is queued while processing to resize the FIFO in
snd_seq_fifo_clear(), it may lead to a use-after-free, as the old pool
that is being queued gets removed.  For avoiding this race, we need to
close the pool to be deleted and sync its usage before actually
deleting it.

The issue was spotted by syzkaller.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
tiwai committed Mar 24, 2017
1 parent 3f30783 commit 2d7d540
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sound/core/seq/seq_fifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize)
/* NOTE: overflow flag is not cleared */
spin_unlock_irqrestore(&f->lock, flags);

/* close the old pool and wait until all users are gone */
snd_seq_pool_mark_closing(oldpool);
snd_use_lock_sync(&f->use_lock);

/* release cells in old pool */
for (cell = oldhead; cell; cell = next) {
next = cell->next;
Expand Down

0 comments on commit 2d7d540

Please sign in to comment.