From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C6D9428EE for ; Mon, 2 Jan 2023 11:25:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A28FC433EF; Mon, 2 Jan 2023 11:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672658750; bh=V8JDEOHxZYVaGl2463GBfoBZjYbsHwH465h8fIzUM6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vbWyQ9nUhWtS9evP1502lsGsVq/ik3zNaKIZtmrKtEtyF5F5gGDCNc8n3Ef5U0YDQ 8qGjqow3ep9dwSl59zi2FyamWc2Ne9Kr7HhTzRwJPzGUXnDdLZH1uZSXc0FJiH02LR AxhDiVpBs36N1dFUHzH08nZi8oO4aJYjAtOqQG2w= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Artem Egorkine , Takashi Iwai Subject: [PATCH 6.1 57/71] ALSA: line6: fix stack overflow in line6_midi_transmit Date: Mon, 2 Jan 2023 12:22:22 +0100 Message-Id: <20230102110553.896886945@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230102110551.509937186@linuxfoundation.org> References: <20230102110551.509937186@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 @@ -44,7 +44,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)