Skip to contentSkip to conversation

ALSA: pcm: disallow linking stream to itself

PATCH In review Takashi Iwai 2 participants 2 messages Jun 15, 2020 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: pcm: disallow linking stream to itself

From: Michał Mirosław <[email protected]>

commit 951e2736f4b11b58dc44d41964fa17c3527d882a upstream.

Prevent SNDRV_PCM_IOCTL_LINK linking stream to itself - the code can't handle it. Fixed commit is not where bug was introduced, but changes the context significantly.

---

Backported to 4.19.y. It can be used for older branches, too.

 sound/core/pcm_native.c | 5 +++++
 1 file changed, 5 insertions(+)
sound/core/pcm_native.c +5 -0
index 14b1ee29509d..071e09c3d855 100644
@@ -1950,6 +1950,11 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
 	}
 	pcm_file = f.file->private_data;
 	substream1 = pcm_file->substream;
+	if (substream == substream1) {
+		res = -EINVAL;
+		goto _badf;
+	}
+
 	group = kmalloc(sizeof(*group), GFP_KERNEL);
 	if (!group) {
 		res = -ENOMEM;
Signature · 1 line
2.16.4
#1 lore raw
Quoted 14 lines · Takashi Iwai

From: Michał Mirosław <[email protected]>

commit 951e2736f4b11b58dc44d41964fa17c3527d882a upstream.

Prevent SNDRV_PCM_IOCTL_LINK linking stream to itself - the code can't handle it. Fixed commit is not where bug was introduced, but changes the context significantly.

Quoted 3 lines

---

Backported to 4.19.y. It can be used for older branches, too.

Thanks, that worked.

greg k-h