Skip to content

Commit 4a63bd1

Browse files
committed
ALSA: timer: Set lower bound of start tick time
Currently ALSA timer doesn't have the lower limit of the start tick time, and it allows a very small size, e.g. 1 tick with 1ns resolution for hrtimer. Such a situation may lead to an unexpected RCU stall, where the callback repeatedly queuing the expire update, as reported by fuzzer. This patch introduces a sanity check of the timer start tick time, so that the system returns an error when a too small start size is set. As of this patch, the lower limit is hard-coded to 100us, which is small enough but can still work somehow. Reported-by: [email protected] Closes: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent d731b1e commit 4a63bd1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sound/core/timer.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,14 @@ static int snd_timer_start1(struct snd_timer_instance *timeri,
544544
SNDRV_TIMER_IFLG_START))
545545
return -EBUSY;
546546

547+
/* check the actual time for the start tick;
548+
* bail out as error if it's way too low (< 100us)
549+
*/
550+
if (start) {
551+
if ((u64)snd_timer_hw_resolution(timer) * ticks < 100000)
552+
return -EINVAL;
553+
}
554+
547555
if (start)
548556
timeri->ticks = timeri->cticks = ticks;
549557
else if (!timeri->cticks)

0 commit comments

Comments
 (0)