mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
To: perex@perex.cz, tiwai@suse.de
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sreeraj S Kurup <sreekuttan2156239@gmail.com>
Subject: [PATCH] ALSA: hda: Validate codec address before executing verb
Date: Sat,  5 Dec 2026 10:17:35 +0000	[thread overview]
Message-ID: <20261205101735.2605-1-sreekuttan2156239@gmail.com> (raw)

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


             reply	other threads:[~2026-12-05 10:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 10:17 Sreeraj S Kurup [this message]
2026-12-06 11:10 ` Takashi Iwai
2026-12-06 13:08   ` Sreeraj S Kurup

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261205101735.2605-1-sreekuttan2156239@gmail.com \
    --to=sreekuttan2156239@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®