From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE1E81C84D0; Fri, 7 Aug 2026 15:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116219; cv=none; b=VXdMTM3EN8CUNa/pGHVTBdkIZLsbRDfW86ZOe8njTOtvesWp1pE1oI71qBO/+hf6FKiqgprcvn7KJqjmv9HdHZQR1YotPvvvdFyrTr4WrpXvMhRdywgnseTXHdJy0/yPhUf6m6etM0ihIoD8urUwv/Ry2g3y+H85CoAX30pVK4A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116219; c=relaxed/simple; bh=RCwHlpelBd0/xO9kFaC7d9a3ehVjQHUy8cz05boqf2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JWHu6x51BK9SUgHU9+tl9osb+JIqKsVjvW9+xSiVsVnKoXTPXmHbevU/LK9/8ZH2BCKliHC3JrlrxGTlr3vTPPgfaKJ5+XwEXz9XrCuplD+ZvqbSCytK+3vA8pHf7oJguKzJx43xcTFKFvE4npo2NDp7wbKGxF+KmE+ElZr9aos= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AZpEOzOU; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="AZpEOzOU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 369CA1F000E9; Fri, 7 Aug 2026 15:23:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786116217; bh=4/v3Fz9F6t2Ufw8LhCJbKRDUWlPJppDDe/7tvApiUR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AZpEOzOUZVLYWgEf9MSV/m+sNLM1fwO9VFPuo3i1JeAXwz8QGeJCBfNH/743bH8Cc l53ejikcK5TiKp53aPnM8tmdkGSdgOOfroaJk1e3TRdj2diM/6S/H7odyzXLZn8WY+ rJxR/uzBpgu+Kudf+AwItvEksAyxXKutTtzikJpA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Takashi Iwai , Federico Kirschbaum , Baul Lee Subject: [PATCH 6.6 117/261] ALSA: usb-audio: fix OOB write in snd_usbmidi_akai_output() Date: Fri, 7 Aug 2026 16:37:54 +0200 Message-ID: <20260807143417.896702204@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807143415.358597922@linuxfoundation.org> References: <20260807143415.358597922@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Baul Lee commit 0970274613fb463d376211450cab066d34ebfe6a upstream. snd_usbmidi_akai_output() computes its fill-loop bound buf_end = ep->max_transfer - MAX_AKAI_SYSEX_LEN - 1; as a signed int, so a small device-advertised bulk-OUT max_transfer makes buf_end negative. The loop guard then compares the u32 urb->transfer_buffer_length against that negative int: the usual arithmetic conversion turns buf_end into a large unsigned value, so the guard stays true and each iteration keeps appending SysEx framing and payload bytes past the end of the URB transfer buffer, which is only max_transfer bytes long. A USB device that advertises a tiny bulk-OUT endpoint can therefore trigger an attacker-length- and content-controlled heap out-of-bounds write when a process writes to the created /dev/snd/midiC*D* node. Return early when there is no room for even one SysEx, so the loop is never entered with a bound that would wrap. The loop is the last statement of the function, so bailing out is equivalent to it not running. Discovered by XBOW, triaged by Baul Lee Fixes: 4434ade8c933 ("ALSA: usb-audio: add support for Akai MPD16") Suggested-by: Takashi Iwai Reported-by: Federico Kirschbaum Reported-by: Baul Lee Cc: stable@vger.kernel.org Signed-off-by: Baul Lee Link: https://patch.msgid.link/20260726074500.50145-1-baul.lee@xbow.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/midi.c | 2 ++ 1 file changed, 2 insertions(+) --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -800,6 +800,8 @@ static void snd_usbmidi_akai_output(stru msg = urb->transfer_buffer + urb->transfer_buffer_length; buf_end = ep->max_transfer - MAX_AKAI_SYSEX_LEN - 1; + if (buf_end <= 0) + return; /* only try adding more data when there's space for at least 1 SysEx */ while (urb->transfer_buffer_length < buf_end) {