linux/sound/usb
Berk Cem Goksel 3f7f8bae0d ALSA: caiaq: fix stack out-of-bounds read in init_card
commit 45424e871a upstream.

The loop creates a whitespace-stripped copy of the card shortname
where `len < sizeof(card->id)` is used for the bounds check. Since
sizeof(card->id) is 16 and the local id buffer is also 16 bytes,
writing 16 non-space characters fills the entire buffer,
overwriting the terminating nullbyte.

When this non-null-terminated string is later passed to
snd_card_set_id() -> copy_valid_id_string(), the function scans
forward with `while (*nid && ...)` and reads past the end of the
stack buffer, reading the contents of the stack.

A USB device with a product name containing many non-ASCII, non-space
characters (e.g. multibyte UTF-8) will reliably trigger this as follows:

  BUG: KASAN: stack-out-of-bounds in copy_valid_id_string
       sound/core/init.c:696 [inline]
  BUG: KASAN: stack-out-of-bounds in snd_card_set_id_no_lock+0x698/0x74c
       sound/core/init.c:718

The off-by-one has been present since commit bafeee5b1f ("ALSA:
snd_usb_caiaq: give better shortname") from June 2009 (v2.6.31-rc1),
which first introduced this whitespace-stripping loop. The original
code never accounted for the null terminator when bounding the copy.

Fix this by changing the loop bound to `sizeof(card->id) - 1`,
ensuring at least one byte remains as the null terminator.

Fixes: bafeee5b1f ("ALSA: snd_usb_caiaq: give better shortname")
Cc: stable@vger.kernel.org
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Reported-by: Berk Cem Goksel <berkcgoksel@gmail.com>
Signed-off-by: Berk Cem Goksel <berkcgoksel@gmail.com>
Link: https://patch.msgid.link/20260329133825.581585-1-berkcgoksel@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-04-18 10:33:32 +02:00
..
6fire ALSA: 6fire: Release resources at card release 2024-12-14 19:50:59 +01:00
bcd2000 ALSA: bcd2000: Fix a UAF bug on the error path of probing 2022-08-17 14:22:46 +02:00
caiaq ALSA: caiaq: fix stack out-of-bounds read in init_card 2026-04-18 10:33:32 +02:00
hiface module: remove never implemented MODULE_SUPPORTED_DEVICE 2021-03-17 13:16:18 -07:00
line6 ALSA: line6: add hw monitor volume control to POD HD500X 2024-10-17 15:11:36 +02:00
misc ALSA: ua101: fix division by zero at probe 2021-11-18 19:15:54 +01:00
usx2y ALSA: usx2y: validate nrpacks module parameter on probe 2025-03-13 12:51:05 +01:00
card.c ALSA: usb-audio: Fix NULL pointer deference in try_to_register_card 2025-10-29 14:03:09 +01:00
card.h ALSA: usb-audio: Add new quirk FIXED_RATE for JBL Quantum810 Wireless 2024-03-15 10:48:19 -04:00
clock.c ALSA: usb-audio: Fix out of bounds reads when finding clock sources 2024-12-14 19:51:11 +01:00
clock.h ALSA: usb-audio: Constify audioformat pointer references 2020-11-23 15:15:36 +01:00
endpoint.c ALSA: usb-audio: Check max frame size for implicit feedback mode, too 2026-04-18 10:33:11 +02:00
endpoint.h ALSA: usb-audio: Add new quirk FIXED_RATE for JBL Quantum810 Wireless 2024-03-15 10:48:19 -04:00
format.c ALSA: usb-audio: Add second USB ID for Jabra Evolve 65 headset 2025-05-09 09:39:35 +02:00
format.h ALSA: usb: initial USB Audio Device Class 3.0 support 2018-03-21 11:46:33 +01:00
helper.c ALSA: usb-audio: Add snd_usb_get_host_interface() helper 2020-11-23 15:13:47 +01:00
helper.h ALSA: usb-audio: Add snd_usb_get_host_interface() helper 2020-11-23 15:13:47 +01:00
implicit.c ALSA: usb-audio: Add implicit feedback quirk for RODE AI-1 2025-06-27 11:05:21 +01:00
implicit.h ALSA: usb-audio: Add new quirk FIXED_RATE for JBL Quantum810 Wireless 2024-03-15 10:48:19 -04:00
Kconfig sound: Fix Kconfig indentation 2019-10-07 03:53:03 +02:00
Makefile ALSA: usb-audio: Factor out the implicit feedback quirk code 2020-11-23 15:17:00 +01:00
media.c ALSA: usb-audio: fix spelling mistakes 2021-07-05 19:33:54 +02:00
media.h media: sound/usb: Use Media Controller API to share media resources 2019-04-22 11:21:06 -04:00
midi.c ALSA: usb-audio: Fix CME quirk for UF series keyboards 2025-05-02 07:43:54 +02:00
midi.h ALSA: usb-audio: generate midi streaming substream names from jack names 2021-03-01 09:21:54 +01:00
mixer.c ALSA: usb-audio: Fix use-after-free in snd_usb_mixer_free() 2026-02-06 16:41:56 +01:00
mixer.h ALSA: usb-audio: Add input value sanity checks for standard types 2024-10-17 15:11:27 +02:00
mixer_maps.c ALSA: usb-audio: Rename ALSA kcontrol PCM and PCM1 for the KTMicro sound card 2025-06-27 11:05:34 +01:00
mixer_quirks.c ALSA: usb-audio: Fix build with CONFIG_INPUT=n 2025-10-02 13:39:10 +02:00
mixer_quirks.h ALSA: usb-audio: Initialize Dell Dock playback volumes 2018-05-02 16:02:32 +02:00
mixer_s1810c.c ALSA: usb-audio: add mono main switch to Presonus S1824c 2025-12-07 06:09:24 +09:00
mixer_s1810c.h ALSA: usb-audio: Add support for Presonus Studio 1810c 2020-02-15 09:46:16 +01:00
mixer_scarlett.c ALSA: usb-audio: fix spelling mistakes 2021-07-05 19:33:54 +02:00
mixer_scarlett.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mixer_scarlett_gen2.c ALSA: scarlett2: Fix buffer overflow in config retrieval 2026-02-06 16:42:03 +01:00
mixer_scarlett_gen2.h ALSA: usb-audio: scarlett2: Improve driver startup messages 2021-05-21 16:22:52 +02:00
mixer_us16x08.c ALSA: usb-mixer: us16x08: validate meter packet indices 2026-01-19 13:09:46 +01:00
mixer_us16x08.h ALSA: usb: Constify snd_kcontrol_new items 2020-01-03 09:24:34 +01:00
pcm.c ALSA: usb-audio: Fix possible NULL pointer dereference in snd_usb_pcm_has_fixed_rate() 2024-10-17 15:11:48 +02:00
pcm.h ALSA: usb-audio: Add new quirk FIXED_RATE for JBL Quantum810 Wireless 2024-03-15 10:48:19 -04:00
power.c ALSA: usb-audio: More validations of descriptor units 2019-08-22 10:35:59 +02:00
power.h ALSA: usb-audio: Initial Power Domain support 2018-07-31 15:01:22 +02:00
proc.c ALSA: usb-audio: Show sync endpoint information in proc outputs 2020-11-23 15:16:45 +01:00
proc.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
quirks-table.h ALSA: usb-audio: Fix Yamaha P-125 Quirk Entry 2024-12-14 19:50:41 +01:00
quirks.c ALSA: usb-audio: Avoid implicit feedback mode on DIYINHK USB Audio 2.0 2026-04-18 10:33:11 +02:00
quirks.h ALSA: usb-audio: Register card at the last interface 2022-10-26 12:35:39 +02:00
stream.c ALSA: usb-audio: Fix size validation in convert_chmap_v3() 2025-08-28 16:24:38 +02:00
stream.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
usbaudio.h ALSA: usb-audio: Add new quirk FIXED_RATE for JBL Quantum810 Wireless 2024-03-15 10:48:19 -04:00
validate.c ALSA: usb-audio: Use correct version for UAC3 header validation 2026-04-18 10:33:09 +02:00