Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda: Validate codec address before executing verb
@ 2026-12-05 10:17 Sreeraj S Kurup
  2026-12-06 11:10 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Sreeraj S Kurup @ 2026-12-05 10:17 UTC (permalink / raw)
  To: perex, tiwai; +Cc: linux-sound, linux-kernel, Sreeraj S Kurup

snd_hdac_bus_exec_verb_unlocked() receives a codec address
that is later passed to the response handling operation.

An invalid codec address can lead to an out-of-bounds array
access in the response handling path.

Add a check using snd_BUG_ON() and return -EINVAL when the
address is greater than or equal to HDA_MAX_CODECS.

This protects verb execution from invalid addresses passed
by existing callers as well as future callers, including
paths that use custom get_response operations.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
 sound/hda/core/bus.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/hda/core/bus.c b/sound/hda/core/bus.c
index 02462bd035e7..e37426d551ad 100644
--- a/sound/hda/core/bus.c
+++ b/sound/hda/core/bus.c
@@ -9,6 +9,7 @@
 #include <linux/module.h>
 #include <linux/export.h>
 #include <sound/hdaudio.h>
+#include <sound/core.h>
 #include "local.h"
 #include "trace.h"
 
@@ -107,6 +108,9 @@ int snd_hdac_bus_exec_verb_unlocked(struct hdac_bus *bus, unsigned int addr,
 	unsigned int tmp;
 	int err;
 
+	if (snd_BUG_ON(addr >= HDA_MAX_CODECS))
+		return -EINVAL;
+
 	if (cmd == ~0)
 		return -EINVAL;
 
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: hda: Validate codec address before executing verb
  2026-12-05 10:17 [PATCH] ALSA: hda: Validate codec address before executing verb Sreeraj S Kurup
@ 2026-12-06 11:10 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-12-06 11:10 UTC (permalink / raw)
  To: Sreeraj S Kurup; +Cc: perex, tiwai, linux-sound, linux-kernel

On Sat, 05 Dec 2026 11:17:35 +0100,
Sreeraj S Kurup wrote:
> 
> snd_hdac_bus_exec_verb_unlocked() receives a codec address
> that is later passed to the response handling operation.
> 
> An invalid codec address can lead to an out-of-bounds array
> access in the response handling path.
> 
> Add a check using snd_BUG_ON() and return -EINVAL when the
> address is greater than or equal to HDA_MAX_CODECS.
> 
> This protects verb execution from invalid addresses passed
> by existing callers as well as future callers, including
> paths that use custom get_response operations.
> 
> Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>

Applied to for-next branch.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-06 11:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 10:17 [PATCH] ALSA: hda: Validate codec address before executing verb Sreeraj S Kurup
2026-12-06 11:10 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox