* [PATCH 6.8.y-and-older] ALSA: timer: Set lower bound of start tick time
@ 2024-05-27 6:23 Takashi Iwai
2024-06-06 12:57 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Takashi Iwai @ 2024-05-27 6:23 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: stable
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 ]
Reported-by: syzbot+43120c2af6ca2938cc38@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/r/000000000000fa00a1061740ab6d@google.com
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20240514182745.4015-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
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(+)
diff --git a/sound/core/timer.c b/sound/core/timer.c
index e6e551d4a29e..a0b515981ee9 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -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)
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 6.8.y-and-older] ALSA: timer: Set lower bound of start tick time
2024-05-27 6:23 [PATCH 6.8.y-and-older] ALSA: timer: Set lower bound of start tick time Takashi Iwai
@ 2024-06-06 12:57 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2024-06-06 12:57 UTC (permalink / raw)
To: Takashi Iwai; +Cc: stable
On Mon, May 27, 2024 at 08:23:59AM +0200, Takashi Iwai wrote:
> 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 ]
>
> Reported-by: syzbot+43120c2af6ca2938cc38@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/r/000000000000fa00a1061740ab6d@google.com
> Cc: <stable@vger.kernel.org>
> Link: https://lore.kernel.org/r/20240514182745.4015-1-tiwai@suse.de
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
>
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-06 12:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-27 6:23 [PATCH 6.8.y-and-older] ALSA: timer: Set lower bound of start tick time Takashi Iwai
2024-06-06 12:57 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox