ALSA: timer: Set lower bound of start tick time
Subsystems (2)
PATCH 1/1 ALSA: timer: Set lower bound of start tick time
commit 4a63bd179fa8d3fcc44a0d9d71d941ddd62f0c4e upstream.
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.
[ backport note: the error handling is changed, as the original commit
is based on the recent cleanup with guard() in commit beb45974dd49 -- tiwai ]
---
Greg, this is an alternative fix to the original cherry-pick; apply to 6.8.y and older stable kernels. Thanks!
sound/core/timer.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/core/timer.c +10 -0
@@ -553,6 +553,16 @@ static int snd_timer_start1(struct snd_timer_instance *timeri, goto unlock; } +/* check the actual time for the start tick; +* bail out as error if it's way too low (< 100us) +*/ +if (start) { +if ((u64 )snd_timer_hw_resolution (timer) * ticks <100000 ) { + result = -EINVAL ; + goto unlock; + } + } +if (start) timeri->ticks = timeri->cticks = ticks;else if (!timeri->cticks)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerQuoted 22 lines · Takashi Iwai
commit
4a63bd179fa8d3fcc44a0d9d71d941ddd62f0c4eupstream.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.
[ backport note: the error handling is changed, as the original commit
is based on the recent cleanup withguard()in commitbeb45974dd49-- tiwai ]
Quoted 4 lines
---
Greg, this is an alternative fix to the original cherry-pick; apply to 6.8.y and older stable kernels. Thanks!
Now queued up, thanks!
greg k-h