This is a note to let you know that I've just added the patch titled ALSA: hda: hdac_stream: fix potential locking issue in snd_hdac_stream_assign() to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: alsa-hda-hdac_stream-fix-potential-locking-issue-in-snd_hdac_stream_assign.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 1465d06a6d8580e73ae65f8590392df58c5ed2fd Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx> Date: Fri, 24 Sep 2021 14:24:14 -0500 Subject: ALSA: hda: hdac_stream: fix potential locking issue in snd_hdac_stream_assign() From: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx> commit 1465d06a6d8580e73ae65f8590392df58c5ed2fd upstream. The fields 'opened', 'running', 'assigned_key' are all protected by a spinlock, but the spinlock is not taken when looking for a stream. This can result in a possible race between assign() and release(). Fix by taking the spinlock before walking through the bus stream list. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20210924192417.169243-2-pierre-louis.bossart@xxxxxxxxxxxxxxx Signed-off-by: Takashi Iwai <tiwai@xxxxxxx> Cc: Scott Bruce <smbruce@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- sound/hda/hdac_stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/sound/hda/hdac_stream.c +++ b/sound/hda/hdac_stream.c @@ -296,6 +296,7 @@ struct hdac_stream *snd_hdac_stream_assi int key = (substream->pcm->device << 16) | (substream->number << 2) | (substream->stream + 1); + spin_lock_irq(&bus->reg_lock); list_for_each_entry(azx_dev, &bus->stream_list, list) { if (azx_dev->direction != substream->stream) continue; @@ -309,13 +310,12 @@ struct hdac_stream *snd_hdac_stream_assi res = azx_dev; } if (res) { - spin_lock_irq(&bus->reg_lock); res->opened = 1; res->running = 0; res->assigned_key = key; res->substream = substream; - spin_unlock_irq(&bus->reg_lock); } + spin_unlock_irq(&bus->reg_lock); return res; } EXPORT_SYMBOL_GPL(snd_hdac_stream_assign); Patches currently in stable-queue which might be from pierre-louis.bossart@xxxxxxxxxxxxxxx are queue-5.10/alsa-hda-hdac_ext_stream-fix-potential-locking-issues.patch queue-5.10/alsa-hda-hdac_stream-fix-potential-locking-issue-in-snd_hdac_stream_assign.patch queue-5.10/asoc-intel-sof_sdw-add-missing-quirk-for-dell-sku-0a.patch queue-5.10/alsa-intel-dsp-config-add-quirk-for-apl-glk-tgl-devi.patch queue-5.10/asoc-sof-intel-hda-dai-fix-potential-locking-issue.patch