* [PATCH] ALSA: FCP: avoid leaking uninitialized heap memory in fcp_ioctl_cmd()
@ 2026-11-30 10:33 Ziheng Wei
2026-12-01 7:48 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Ziheng Wei @ 2026-11-30 10:33 UTC (permalink / raw)
To: Geoffrey D . Bennett, Jaroslav Kysela, Takashi Iwai
Cc: linux-sound, linux-kernel
fcp_ioctl_cmd() allocates the request/response buffer with kmalloc(). If
userspace invokes FCP_IOCTL_CMD with opcode == FCP_USB_REBOOT,
req_size == 0, and resp_size > 0 (up to 4096 bytes), fcp_usb() returns 0
early on -ESHUTDOWN or -EPROTO without writing resp_data, and
fcp_ioctl_cmd() copies uninitialized heap memory back to userspace.
Allocate the buffer with kzalloc() and zero resp_data on the early-return
path in fcp_usb().
Found by LLM-assisted static analysis and compile-tested on x86_64.
Fixes: 46757a3e7d50 ("ALSA: FCP: Add Focusrite Control Protocol driver")
Signed-off-by: Ziheng Wei <zihengw03@163.com>
---
sound/usb/fcp.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/sound/usb/fcp.c b/sound/usb/fcp.c
index 68bb7eabf..34a363d33 100644
--- a/sound/usb/fcp.c
+++ b/sound/usb/fcp.c
@@ -248,8 +248,11 @@ retry:
* reboot request
*/
if (opcode == FCP_USB_REBOOT &&
- (err == -ESHUTDOWN || err == -EPROTO))
+ (err == -ESHUTDOWN || err == -EPROTO)) {
+ if (resp_data && resp_size > 0)
+ memset(resp_data, 0, resp_size);
return 0;
+ }
usb_audio_err(mixer->chip,
"FCP read response %08x failed: %d\n",
@@ -585,7 +588,7 @@ static int fcp_ioctl_cmd(struct usb_mixer_interface *mixer,
buf_size = max(cmd.req_size, cmd.resp_size);
if (buf_size > 0) {
- data = kmalloc(buf_size, GFP_KERNEL);
+ data = kzalloc(buf_size, GFP_KERNEL);
if (!data)
return -ENOMEM;
}
base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: FCP: avoid leaking uninitialized heap memory in fcp_ioctl_cmd()
2026-11-30 10:33 [PATCH] ALSA: FCP: avoid leaking uninitialized heap memory in fcp_ioctl_cmd() Ziheng Wei
@ 2026-12-01 7:48 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-12-01 7:48 UTC (permalink / raw)
To: Ziheng Wei
Cc: Geoffrey D . Bennett, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-kernel
On Mon, 30 Nov 2026 11:33:01 +0100,
Ziheng Wei wrote:
>
> fcp_ioctl_cmd() allocates the request/response buffer with kmalloc(). If
> userspace invokes FCP_IOCTL_CMD with opcode == FCP_USB_REBOOT,
> req_size == 0, and resp_size > 0 (up to 4096 bytes), fcp_usb() returns 0
> early on -ESHUTDOWN or -EPROTO without writing resp_data, and
> fcp_ioctl_cmd() copies uninitialized heap memory back to userspace.
>
> Allocate the buffer with kzalloc() and zero resp_data on the early-return
> path in fcp_usb().
>
> Found by LLM-assisted static analysis and compile-tested on x86_64.
>
> Fixes: 46757a3e7d50 ("ALSA: FCP: Add Focusrite Control Protocol driver")
> Signed-off-by: Ziheng Wei <zihengw03@163.com>
Applied now. Thanks.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-01 7:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 10:33 [PATCH] ALSA: FCP: avoid leaking uninitialized heap memory in fcp_ioctl_cmd() Ziheng Wei
2026-12-01 7:48 ` Takashi Iwai
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®