Skip to content

Commit 60adcfd

Browse files
committed
ALSA: seq: Fix racy access for queue timer in proc read
snd_seq_info_timer_read() reads the information of the timer assigned for each queue, but it's done in a racy way which may lead to UAF as spotted by syzkaller. This patch applies the missing q->timer_mutex lock while accessing the timer object as well as a slight code change to adapt the standard coding style. Reported-by: [email protected] Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 5d1b712 commit 60adcfd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

sound/core/seq/seq_timer.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,15 +471,19 @@ void snd_seq_info_timer_read(struct snd_info_entry *entry,
471471
q = queueptr(idx);
472472
if (q == NULL)
473473
continue;
474-
if ((tmr = q->timer) == NULL ||
475-
(ti = tmr->timeri) == NULL) {
476-
queuefree(q);
477-
continue;
478-
}
474+
mutex_lock(&q->timer_mutex);
475+
tmr = q->timer;
476+
if (!tmr)
477+
goto unlock;
478+
ti = tmr->timeri;
479+
if (!ti)
480+
goto unlock;
479481
snd_iprintf(buffer, "Timer for queue %i : %s\n", q->queue, ti->timer->name);
480482
resolution = snd_timer_resolution(ti) * tmr->ticks;
481483
snd_iprintf(buffer, " Period time : %lu.%09lu\n", resolution / 1000000000, resolution % 1000000000);
482484
snd_iprintf(buffer, " Skew : %u / %u\n", tmr->skew, tmr->skew_base);
485+
unlock:
486+
mutex_unlock(&q->timer_mutex);
483487
queuefree(q);
484488
}
485489
}

0 commit comments

Comments
 (0)