From: Takashi Iwai <tiwai@suse.de>
To: Edward Adam Davis <eadavis@sina.com>
Cc: syzbot+c35f34092a4bc9855be6@syzkaller.appspotmail.com,
gregkh@linuxfoundation.org, kees@kernel.org, tiwai@suse.de,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] usb: gadget: midi2: prevent in/out jack from oob
Date: Fri, 28 Aug 2026 14:07:43 +0200 [thread overview]
Message-ID: <87cxv2v46o.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260826134606.127250-1-eadavis@sina.com>
On Wed, 26 Aug 2026 15:46:06 +0200,
Edward Adam Davis wrote:
>
> The increment of config->jack_out in append_midi1_out_jack() lacked
> bounds checking, triggering issue [1] when the value approached the
> limit MAX_CABLES.
>
> A similar out-of-bounds issue exists in append_midi1_in_jack(), so it
> is being fixed as well.
>
> Before incrementing jack_out/in, the code now checks if the value has
> reached the upper limit MAX_CABLES; if so, it exits and returns -EINVAL.
>
> Additionally, the jack_id assignment is moved to occur after the jack_out
> bounds check to prevent wasting IDs on invalid increments.
I think the bug is rather the arrays are too small; they should have
been twice as the jacks can be added from both input and output.
Both append_midi1_out_jack() and append_midi1_in_jack() are called
from the loops of midi2->num_midi1_out and midi2->num_midi1_in
counts, and they are properly upper-bound to MAX_CABLES.
Could you check whether the fix below works instead?
thanks,
Takashi
--- a/drivers/usb/gadget/function/f_midi2.c
+++ b/drivers/usb/gadget/function/f_midi2.c
@@ -1634,8 +1634,8 @@ struct f_midi2_usb_config {
/* MIDI 1.0 jacks */
unsigned char jack_in, jack_out, jack_id;
- struct usb_midi_in_jack_descriptor jack_ins[MAX_CABLES];
- struct usb_midi_out_jack_descriptor_1 jack_outs[MAX_CABLES];
+ struct usb_midi_in_jack_descriptor jack_ins[MAX_CABLES * 2];
+ struct usb_midi_out_jack_descriptor_1 jack_outs[MAX_CABLES * 2];
};
static int append_config(struct f_midi2_usb_config *config, void *d)
prev parent reply other threads:[~2026-08-28 12:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 11:49 [syzbot] [usb?] KASAN: stack-out-of-bounds Write in append_midi1_out_jack syzbot
2026-08-26 13:46 ` [PATCH] usb: gadget: midi2: prevent in/out jack from oob Edward Adam Davis
2026-08-28 12:07 ` Takashi Iwai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87cxv2v46o.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=eadavis@sina.com \
--cc=gregkh@linuxfoundation.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=syzbot+c35f34092a4bc9855be6@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox