[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git-commits-head
Subject:    ALSA: line6: fix stack overflow in line6_midi_transmit
From:       Linux Kernel Mailing List <linux-kernel () vger ! kernel ! org>
Date:       2022-12-30 18:51:02
Message-ID: git-mailbomb-linux-master-b8800d324abb50160560c636bfafe2c81001b66c () kernel ! org
[Download RAW message or body]

Commit:     b8800d324abb50160560c636bfafe2c81001b66c
Parent:     8508fa2e7472f673edbeedf1b1d2b7a6bb898ecc
Refname:    refs/heads/master
Web:        https://git.kernel.org/torvalds/c/b8800d324abb50160560c636bfafe2c81001b66c
Author:     Artem Egorkine <arteme@gmail.com>
AuthorDate: Sun Dec 25 12:57:28 2022 +0200
Committer:  Takashi Iwai <tiwai@suse.de>
CommitDate: Mon Dec 26 09:07:49 2022 +0100

    ALSA: line6: fix stack overflow in line6_midi_transmit
    
    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 <arteme@gmail.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20221225105728.1153989-2-arteme@gmail.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/usb/line6/midi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/usb/line6/midi.c b/sound/usb/line6/midi.c
index d52355de2bbc0..0838632c788e4 100644
--- a/sound/usb/line6/midi.c
+++ b/sound/usb/line6/midi.c
@@ -44,7 +44,8 @@ static void line6_midi_transmit(struct snd_rawmidi_substream *substream)
 	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)
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic