From: Ziheng Wei <zihengw03@163.com>
To: "Geoffrey D . Bennett" <g@b4.vu>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ALSA: FCP: avoid leaking uninitialized heap memory in fcp_ioctl_cmd()
Date: Mon, 30 Nov 2026 18:33:01 +0800 [thread overview]
Message-ID: <20261130103301.1383807-1-zihengw03@163.com> (raw)
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
next reply other threads:[~2026-11-30 10:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 10:33 Ziheng Wei [this message]
2026-12-01 7:48 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261130103301.1383807-1-zihengw03@163.com \
--to=zihengw03@163.com \
--cc=g@b4.vu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®