HIGH
alsa Caiaq OOB
CVE-2026-31778
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:H
KernelScan AI2.3LOW
01Description
In the Linux kernel, the following vulnerability has been resolved: ALSA: caiaq: fix stack out-of-bounds read in init_card 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 bafeee5b1f8d ("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.
02KernelScan AI Analysis
Risk summary
Physical attackers with USB device access can trigger a stack out-of-bounds read in the ALSA Caiaq driver by connecting a malicious USB audio device with a specially crafted product name. This can leak kernel stack contents but does not allow code execution or system compromise.
Vulnerability analysis
The vulnerability is an off-by-one error in the init_card() function where a loop copies non-space characters from a USB device's product name to a 16-byte stack buffer. The bounds check uses `len < sizeof(card->id)` (16) instead of `sizeof(card->id) - 1` (15), allowing 16 characters to fill the entire buffer and overwrite the null terminator. When this non-null-terminated string is passed to snd_card_set_id(), the copy_valid_id_string() function reads past the buffer end using `while (*nid && ...)`, causing a stack out-of-bounds read that can leak kernel memory contents. The fix changes the loop bound to `sizeof(card->id) - 1` to preserve space for the null terminator. This requires physical USB access to trigger.
03Fix Versions
| Branch | Fixed in | Patch commit |
|---|---|---|
| 5.10 | 5.10.253 | 02d9c5b0b555 |
| 5.15 | 5.15.203 | 3f7f8bae0d52 |
| 6.1 | 6.1.168 | 66194c2575a4 |
| 6.12 | 6.12.81 | 3178b62e2e31 |
| 6.18 | 6.18.22 | 3afa2e67f352 |
| 6.19 | 6.19.12 | 7594a6464873 |
| 6.6 | 6.6.134 | a82c1bce2d12 |
| mainline | 7.0 | 45424e871abf |