Commit 2dbfb5cb authored by Takashi Iwai's avatar Takashi Iwai Committed by Willy Tarreau

ALSA: seq: Fix link corruption by event error handling

commit f3ac9f73 upstream.

The sequencer FIFO management has a bug that may lead to a corruption
(shortage) of the cell linked list.  When a sequencer client faces an
error at the event delivery, it tries to put back the dequeued cell.
When the first queue was put back, this forgot the tail pointer
tracking, and the link will be screwed up.

Although there is no memory corruption, the sequencer client may stall
forever at exit while flushing the pending FIFO cells in
snd_seq_pool_done(), as spotted by syzkaller.

This patch addresses the missing tail pointer tracking at
snd_seq_fifo_cell_putback().  Also the patch makes sure to clear the
cell->enxt pointer at snd_seq_fifo_event_in() for avoiding a similar
mess-up of the FIFO linked list.
Reported-by: default avatarDmitry Vyukov <dvyukov@google.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
parent 7a3085a3
...@@ -137,6 +137,7 @@ int snd_seq_fifo_event_in(struct snd_seq_fifo *f, ...@@ -137,6 +137,7 @@ int snd_seq_fifo_event_in(struct snd_seq_fifo *f,
f->tail = cell; f->tail = cell;
if (f->head == NULL) if (f->head == NULL)
f->head = cell; f->head = cell;
cell->next = NULL;
f->cells++; f->cells++;
spin_unlock_irqrestore(&f->lock, flags); spin_unlock_irqrestore(&f->lock, flags);
...@@ -216,6 +217,8 @@ void snd_seq_fifo_cell_putback(struct snd_seq_fifo *f, ...@@ -216,6 +217,8 @@ void snd_seq_fifo_cell_putback(struct snd_seq_fifo *f,
spin_lock_irqsave(&f->lock, flags); spin_lock_irqsave(&f->lock, flags);
cell->next = f->head; cell->next = f->head;
f->head = cell; f->head = cell;
if (!f->tail)
f->tail = cell;
f->cells++; f->cells++;
spin_unlock_irqrestore(&f->lock, flags); spin_unlock_irqrestore(&f->lock, flags);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment