* [PATCH 1/7] ALSA: asihpi: bound control name formatting
@ 2026-03-23 7:03 Pengpeng Hou
2026-03-27 9:42 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-03-23 7:03 UTC (permalink / raw)
To: perex; +Cc: tiwai, linux-sound, linux-kernel, pengpeng
asihpi_ctl_init() builds mixer control names in the fixed 44-byte
hpi_ctl->name buffer, but it currently does so with sprintf(). Some
source/destination node names are already long enough that combining both
endpoints, their indices, the direction prefix, and the control name can
run past the end of the buffer.
Switch the formatting to snprintf() so the driver never writes past the
ALSA control name storage.
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
sound/pci/asihpi/asihpi.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index 3a64d0562803..f8bcc05c8742 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -1384,22 +1384,25 @@ static void asihpi_ctl_init(struct snd_kcontrol_new *snd_control,
dir = "Playback "; /* PCM Playback source, or output node */
if (hpi_ctl->src_node_type && hpi_ctl->dst_node_type)
- sprintf(hpi_ctl->name, "%s %d %s %d %s%s",
+ snprintf(hpi_ctl->name, sizeof(hpi_ctl->name),
+ "%s %d %s %d %s%s",
asihpi_src_names[hpi_ctl->src_node_type],
hpi_ctl->src_node_index,
asihpi_dst_names[hpi_ctl->dst_node_type],
hpi_ctl->dst_node_index,
dir, name);
else if (hpi_ctl->dst_node_type) {
- sprintf(hpi_ctl->name, "%s %d %s%s",
- asihpi_dst_names[hpi_ctl->dst_node_type],
- hpi_ctl->dst_node_index,
- dir, name);
+ snprintf(hpi_ctl->name, sizeof(hpi_ctl->name),
+ "%s %d %s%s",
+ asihpi_dst_names[hpi_ctl->dst_node_type],
+ hpi_ctl->dst_node_index,
+ dir, name);
} else {
- sprintf(hpi_ctl->name, "%s %d %s%s",
- asihpi_src_names[hpi_ctl->src_node_type],
- hpi_ctl->src_node_index,
- dir, name);
+ snprintf(hpi_ctl->name, sizeof(hpi_ctl->name),
+ "%s %d %s%s",
+ asihpi_src_names[hpi_ctl->src_node_type],
+ hpi_ctl->src_node_index,
+ dir, name);
}
}
@@ -2957,4 +2960,3 @@ static void __exit snd_asihpi_exit(void)
module_init(snd_asihpi_init)
module_exit(snd_asihpi_exit)
-
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/7] ALSA: asihpi: bound control name formatting
2026-03-23 7:03 [PATCH 1/7] ALSA: asihpi: bound control name formatting Pengpeng Hou
@ 2026-03-27 9:42 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-03-27 9:42 UTC (permalink / raw)
To: Pengpeng Hou; +Cc: perex, tiwai, linux-sound, linux-kernel
On Mon, 23 Mar 2026 08:03:10 +0100,
Pengpeng Hou wrote:
>
> asihpi_ctl_init() builds mixer control names in the fixed 44-byte
> hpi_ctl->name buffer, but it currently does so with sprintf(). Some
> source/destination node names are already long enough that combining both
> endpoints, their indices, the direction prefix, and the control name can
> run past the end of the buffer.
Does it really overflow? IOW, it's just for a defensive programming,
right? Please clarify it, otherwise we'll receive an unnecessary CVE
number judged only from the description.
> Switch the formatting to snprintf() so the driver never writes past the
> ALSA control name storage.
For that purpose, please use scnprintf() instead. snprintf() would
lead to other unnecessary warnings due to the potential overflow when
built with W=1, too.
> @@ -2957,4 +2960,3 @@ static void __exit snd_asihpi_exit(void)
>
> module_init(snd_asihpi_init)
> module_exit(snd_asihpi_exit)
> -
This is unneeded change. Please drop.
thanks,
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-27 9:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 7:03 [PATCH 1/7] ALSA: asihpi: bound control name formatting Pengpeng Hou
2026-03-27 9:42 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox