From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796034817; b=TRCCDe4cN3QRDjNNOpYfPLF5sWg6p36ca0+6T+zaiwnV3OI5kdDd0ajeJYt2ZT7A5v/M NcBHCDRQsP/S7vhibuPv9PaRN8W0M+2VfG6nFzT7aMqo0VeVBHhf4zFTVdk40OeHsCgOP xdRwEyo/i1QLkUkly/szmTOMy7dssnOCtLqh772YMA1PPEWVX/paa6w/5ohsI3opHlaZB akwLOh3RLfqaU8WLHHxkQk1e2nn1pp/2X5/ann7uLB0vhibRH2SCn20NdLybajAma0goZ TmTLFSpQ40RekWbyPVz3xU8s0fD92/BGE0Gjo3ZE8pNAXvI1aoxyEEJhj/G9mlDzCBg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796034817; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-CM-TRANSID:X-Coremail-Antispam:X-CM-SenderInfo; bh=0pcXuGzpbwNnxmgT0N92tsw8HCXFIBce1K00+QTuyxY=; b=NS5nqLRl39VoB2ASne3XN2+cKJLxED0AqwzEjb1yvOnJD78cjW+3LlyjY2stZ7U+yUVX IHIBEjGnmHCa+rN/9z1AwstUL7OgoR/yh8ljIQEWds7FEj4M/fUe+e7vFkMnjJTWympW7 hFu0JiDUTT3uXXHBuGxxJL0tGN20cue0zugKrjEbMdEiGQEgkTsfYoLK2+X+ShTlph4Vv 4lXt1xKWokKcxfCU7D0Tz702HjSHC5rYW2uwZ4jaUJbSZBzcqzHnK2FfCuYxY4Y4l9z0R aLY/paHCvhpFh/7kbWO6XVZCF6XC5467lcKmuckruo6HSS4LWMVvSP/ObzLxOE2MC+A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=kyDPGjvR; arc=none smtp.remote-ip=117.135.210.4 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 647FA606A31C; Mon, 30 Nov 2026 10:33:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 647FA606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=kyDPGjvR DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=0p cXuGzpbwNnxmgT0N92tsw8HCXFIBce1K00+QTuyxY=; b=kyDPGjvRfc4pb2k4uX P5h93SJgStUCgO9DCqZpflGGhcsys7LyhMfd/ne5VcIwHKui7aTUv05Uj3OsOa4r +ESpxyydD7xCN3FwLa8lrD6stsauSb4PT3EMH6e/oNdcD/slKoNe79Ip/npiMk7i Sa26OUc5Ab51R8UKuuxssUvjw= Received: from user-VMware-Virtual-Platform.localdomain (unknown []) by gzga-smtp-mtada-g1-3 (Coremail) with SMTP id _____wD336TdUA1rybw0LA--.30968S2; Mon, 30 Nov 2026 18:33:02 +0800 (CST) From: Ziheng Wei To: "Geoffrey D . Bennett" , Jaroslav Kysela , Takashi Iwai 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 Message-ID: <20261130103301.1383807-1-zihengw03@163.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD336TdUA1rybw0LA--.30968S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7CF4fuF48tw1fKw4UGFWktFb_yoW8XFyUpr WkC3yUtr1xtrs8ZrW8Crs7Kw4ru3WxAF4UCFW7Xwnru34DCr1vvryqkFySqF47KF97Kr1S yFyDC3Wfu3W5Aw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jZF4iUUUUU= X-CM-SenderInfo: p2lkv0ljzqjqqrwthudrp/xtbC7R5puWsNUN59uAAA3O 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 --- 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