summaryrefslogtreecommitdiff
path: root/sound/core/hrtimer.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2017-11-05 10:07:43 +0100
committerTakashi Iwai <tiwai@suse.de>2017-11-06 10:41:24 +0100
commit9b7d869ee5a77ed4a462372bb89af622e705bfb8 (patch)
tree8151b57ebb526eac4c1bf711aa01bfe0972eecaa /sound/core/hrtimer.c
parentf5ce817951f38023588b2b8308beca79abe20507 (diff)
ALSA: timer: Limit max instances per timer
Currently we allow unlimited number of timer instances, and it may bring the system hogging way too much CPU when too many timer instances are opened and processed concurrently. This may end up with a soft-lockup report as triggered by syzkaller, especially when hrtimer backend is deployed. Since such insane number of instances aren't demanded by the normal use case of ALSA sequencer and it merely opens a risk only for abuse, this patch introduces the upper limit for the number of instances per timer backend. As default, it's set to 1000, but for the fine-grained timer like hrtimer, it's set to 100. Reported-by: syzbot Tested-by: Jérôme Glisse <jglisse@redhat.com> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/hrtimer.c')
-rw-r--r--sound/core/hrtimer.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/sound/core/hrtimer.c b/sound/core/hrtimer.c
index 1ac0c423903e..6e47b823bcaa 100644
--- a/sound/core/hrtimer.c
+++ b/sound/core/hrtimer.c
@@ -159,6 +159,7 @@ static int __init snd_hrtimer_init(void)
timer->hw = hrtimer_hw;
timer->hw.resolution = resolution;
timer->hw.ticks = NANO_SEC / resolution;
+ timer->max_instances = 100; /* lower the limit */
err = snd_timer_global_register(timer);
if (err < 0) {