All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda/via: Avoid potential array out-of-bound in add_secret_dac_path()
@ 2023-01-19  8:22 ` Artemii Karasev
  0 siblings, 0 replies; 4+ messages in thread
From: Artemii Karasev @ 2023-01-19  8:22 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai
  Cc: lvc-project, alsa-devel, Xiang wangx, Artemii Karasev,
	linux-kernel

snd_hda_get_connections() can return a negative error code.
It may lead to accessing 'conn' array at a negative index.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Artemii Karasev <karasev@ispras.ru>
Fixes: 30b4503378c9 ("ALSA: hda - Expose secret DAC-AA connection of some VIA codecs")
---
 sound/pci/hda/patch_via.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index aea7fae2ca4b..2994f85bc1b9 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -819,6 +819,9 @@ static int add_secret_dac_path(struct hda_codec *codec)
 		return 0;
 	nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn,
 				       ARRAY_SIZE(conn) - 1);
+	if (nums < 0)
+		return nums;
+
 	for (i = 0; i < nums; i++) {
 		if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT)
 			return 0;
-- 
2.25.1


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

* [PATCH] ALSA: hda/via: Avoid potential array out-of-bound in add_secret_dac_path()
@ 2023-01-19  8:22 ` Artemii Karasev
  0 siblings, 0 replies; 4+ messages in thread
From: Artemii Karasev @ 2023-01-19  8:22 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai
  Cc: Artemii Karasev, Xiang wangx, alsa-devel, linux-kernel,
	lvc-project

snd_hda_get_connections() can return a negative error code.
It may lead to accessing 'conn' array at a negative index.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Artemii Karasev <karasev@ispras.ru>
Fixes: 30b4503378c9 ("ALSA: hda - Expose secret DAC-AA connection of some VIA codecs")
---
 sound/pci/hda/patch_via.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index aea7fae2ca4b..2994f85bc1b9 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -819,6 +819,9 @@ static int add_secret_dac_path(struct hda_codec *codec)
 		return 0;
 	nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn,
 				       ARRAY_SIZE(conn) - 1);
+	if (nums < 0)
+		return nums;
+
 	for (i = 0; i < nums; i++) {
 		if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT)
 			return 0;
-- 
2.25.1


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

* Re: [PATCH] ALSA: hda/via: Avoid potential array out-of-bound in add_secret_dac_path()
  2023-01-19  8:22 ` Artemii Karasev
@ 2023-01-19 10:29   ` Takashi Iwai
  -1 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2023-01-19 10:29 UTC (permalink / raw)
  To: Artemii Karasev
  Cc: alsa-devel, Xiang wangx, lvc-project, linux-kernel, Takashi Iwai

On Thu, 19 Jan 2023 09:22:59 +0100,
Artemii Karasev wrote:
> 
> snd_hda_get_connections() can return a negative error code.
> It may lead to accessing 'conn' array at a negative index.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Artemii Karasev <karasev@ispras.ru>
> Fixes: 30b4503378c9 ("ALSA: hda - Expose secret DAC-AA connection of some VIA codecs")

Thanks, applied.


Takashi

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

* Re: [PATCH] ALSA: hda/via: Avoid potential array out-of-bound in add_secret_dac_path()
@ 2023-01-19 10:29   ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2023-01-19 10:29 UTC (permalink / raw)
  To: Artemii Karasev
  Cc: Jaroslav Kysela, Takashi Iwai, Xiang wangx, alsa-devel,
	linux-kernel, lvc-project

On Thu, 19 Jan 2023 09:22:59 +0100,
Artemii Karasev wrote:
> 
> snd_hda_get_connections() can return a negative error code.
> It may lead to accessing 'conn' array at a negative index.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Artemii Karasev <karasev@ispras.ru>
> Fixes: 30b4503378c9 ("ALSA: hda - Expose secret DAC-AA connection of some VIA codecs")

Thanks, applied.


Takashi

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

end of thread, other threads:[~2023-01-19 10:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-19  8:22 [PATCH] ALSA: hda/via: Avoid potential array out-of-bound in add_secret_dac_path() Artemii Karasev
2023-01-19  8:22 ` Artemii Karasev
2023-01-19 10:29 ` Takashi Iwai
2023-01-19 10:29   ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.