From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EEA2C54EBE for ; Mon, 16 Jan 2023 17:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234328AbjAPROf (ORCPT ); Mon, 16 Jan 2023 12:14:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234392AbjAPRNH (ORCPT ); Mon, 16 Jan 2023 12:13:07 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A01CA4B750 for ; Mon, 16 Jan 2023 08:53:38 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 52C6EB8109B for ; Mon, 16 Jan 2023 16:53:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA8ACC433D2; Mon, 16 Jan 2023 16:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673888016; bh=R5vC2z2D3RtDn7rkXPKL1h1NguocK1kbknCA9omBTY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Czj2/1Cey9J/IHaqHXjdLsJkXNcdswufzhra4fPJwW2/kQWmtNU9FNH/T6Z1MCNas kHz6OdHZquKM4xAtotqJ3luCHXaSVe0sSQfGlcpSWirCWmo9zJZwH+5OutM61G2U76 PI8V87BK1eslFXqoLTLSlc5qUtILuRO2LvqL5aLM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Artem Egorkine , Takashi Iwai Subject: [PATCH 4.19 369/521] ALSA: line6: fix stack overflow in line6_midi_transmit Date: Mon, 16 Jan 2023 16:50:31 +0100 Message-Id: <20230116154903.593340348@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154847.246743274@linuxfoundation.org> References: <20230116154847.246743274@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Artem Egorkine commit b8800d324abb50160560c636bfafe2c81001b66c upstream. Correctly calculate available space including the size of the chunk buffer. This fixes a buffer overflow when multiple MIDI sysex messages are sent to a PODxt device. Signed-off-by: Artem Egorkine Cc: Link: https://lore.kernel.org/r/20221225105728.1153989-2-arteme@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/line6/midi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/sound/usb/line6/midi.c +++ b/sound/usb/line6/midi.c @@ -48,7 +48,8 @@ static void line6_midi_transmit(struct s int req, done; for (;;) { - req = min(line6_midibuf_bytes_free(mb), line6->max_packet_size); + req = min3(line6_midibuf_bytes_free(mb), line6->max_packet_size, + LINE6_FALLBACK_MAXPACKETSIZE); done = snd_rawmidi_transmit_peek(substream, chunk, req); if (done == 0)