Skip to contentSkip to conversation

ALSA: pcm: Fix endless loop for XRUN recovery in OSS emulation

PATCH New Takashi Iwai 1 participant 1 message Apr 7, 2018 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: pcm: Fix endless loop for XRUN recovery in OSS emulation

The commit 02a5d6925cd3 ("ALSA: pcm: Avoid potential races between OSS ioctls and read/write") split the PCM preparation code to a locked version, and it added a sanity check of runtime->oss.prepare flag along with the change. This leaded to an endless loop when the stream gets XRUN: namely, snd_pcm_oss_write3() and co call snd_pcm_oss_prepare() without setting runtime->oss.prepare flag and the loop continues until the PCM state reaches to another one.

As the function is supposed to execute the preparation unconditionally, drop the invalid state check there.

The bug was triggered by syzkaller.

Fixes 02a5d6925cd3 ("ALSA: pcm: Avoid potential races between OSS ioctls and read/write")
Reported-by [email protected]
Reported-by [email protected]
---
 sound/core/oss/pcm_oss.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/core/oss/pcm_oss.c +1 -2
index 481ab0e94ffa..727647755aab 100644
@@ -1128,13 +1128,12 @@ static int snd_pcm_oss_get_active_substream(struct snd_pcm_oss_file *pcm_oss_fil
 }
 
 /* call with params_lock held */
+/* NOTE: this doesn't care whether runtime->oss.prepare is set or not */
 static int snd_pcm_oss_prepare(struct snd_pcm_substream *substream)
 {
 	int err;
 	struct snd_pcm_runtime *runtime = substream->runtime;
 
-	if (!runtime->oss.prepare)
-		return 0;
 	err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_PREPARE, NULL);
 	if (err < 0) {
 		pcm_dbg(substream->pcm,
Signature · 1 line
2.16.3