* [PATCH] ALSA: usb-audio: fix OOB write in snd_usbmidi_us122l_output()
@ 2026-09-01 9:04 HyeongJun An
2026-09-01 10:37 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: HyeongJun An @ 2026-09-01 9:04 UTC (permalink / raw)
To: clemens, tiwai, perex; +Cc: linux-sound, linux-kernel, stable, HyeongJun An
The snd_usbmidi_us122l_output() picks a count of 2 on anything slower
than high speed and never relates it to ep->max_transfer. The URB
buffer holds exactly max_transfer bytes, so a device declaring a one
byte bulk endpoint takes two bytes from snd_rawmidi_transmit(), and the
memset that pads the rest computes 1 - 2 in int and wraps to SIZE_MAX.
Only 0x800e and 0x800f are pinned to nine bytes. The US-122MKII at
0x0644:0x8021 falls to the default and takes usb_maxpacket(), which the
USB core only clamps downward.
The akai and novation output ops in this file were given the same guard
recently. Do the same here.
Fixes: 030a07e44129 ("ALSA: Add USB US122L driver")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-5
Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
---
sound/usb/midi.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index f8996416c3be..1a5210556981 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -969,6 +969,8 @@ static void snd_usbmidi_us122l_output(struct snd_usb_midi_out_endpoint *ep,
default:
count = 2;
}
+ if (ep->max_transfer < count)
+ return;
count = snd_rawmidi_transmit(ep->ports[0].substream,
urb->transfer_buffer,
count);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ALSA: usb-audio: fix OOB write in snd_usbmidi_us122l_output()
2026-09-01 9:04 [PATCH] ALSA: usb-audio: fix OOB write in snd_usbmidi_us122l_output() HyeongJun An
@ 2026-09-01 10:37 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-09-01 10:37 UTC (permalink / raw)
To: HyeongJun An; +Cc: clemens, tiwai, perex, linux-sound, linux-kernel, stable
On Tue, 01 Sep 2026 11:04:09 +0200,
HyeongJun An wrote:
>
> The snd_usbmidi_us122l_output() picks a count of 2 on anything slower
> than high speed and never relates it to ep->max_transfer. The URB
> buffer holds exactly max_transfer bytes, so a device declaring a one
> byte bulk endpoint takes two bytes from snd_rawmidi_transmit(), and the
> memset that pads the rest computes 1 - 2 in int and wraps to SIZE_MAX.
>
> Only 0x800e and 0x800f are pinned to nine bytes. The US-122MKII at
> 0x0644:0x8021 falls to the default and takes usb_maxpacket(), which the
> USB core only clamps downward.
>
> The akai and novation output ops in this file were given the same guard
> recently. Do the same here.
>
> Fixes: 030a07e44129 ("ALSA: Add USB US122L driver")
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-5
> Signed-off-by: HyeongJun An <sammiee5311@gmail.com>
Applied now. Thanks.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-01 10:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-01 9:04 [PATCH] ALSA: usb-audio: fix OOB write in snd_usbmidi_us122l_output() HyeongJun An
2026-09-01 10:37 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox