Skip to content

Commit 2d7d540

Browse files
committed
ALSA: seq: Fix race during FIFO resize
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 <[email protected]> Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 3f30783 commit 2d7d540

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sound/core/seq/seq_fifo.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize)
267267
/* NOTE: overflow flag is not cleared */
268268
spin_unlock_irqrestore(&f->lock, flags);
269269

270+
/* close the old pool and wait until all users are gone */
271+
snd_seq_pool_mark_closing(oldpool);
272+
snd_use_lock_sync(&f->use_lock);
273+
270274
/* release cells in old pool */
271275
for (cell = oldhead; cell; cell = next) {
272276
next = cell->next;

0 commit comments

Comments
 (0)