From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795961868; b=v3K4Y8iivAQV913l4fAeFKyXBYiyztT2lauWqw2j5LNREikephQ4C4T7pCd8m5Yp9v90 ozN5CNGJX6HIBKCiODant4l4p0w9bWB50QVigA+ObK22hO6FQqluwXgklfkrmCOemFF+s Zl8rEdelO60YEaU6HnqxemTXJpJrS7Hgyl+eIFKTWRvNUwqr5MJFde7fOFN43NydBdIzx uW3VnsO1iTrPakmKyOsAvqx4DA4BaRgZQiyzPLmckNNawjaZCpFKaIKmqjckZWdEJZZgG TGbfEU1MowpS+7SCOadTce63mtG1+Ch9oAQUrG1ktsP7b8YOldoZSv41IMHePnQyqag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795961868; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ajHUbW9qy3rSlms+r6YCUujSWyMYHZFoNC2Po+7bfbo=; b=P48sJWNFUtXvHUh3nOPcQZtuH5nvKeRaG9mfut+sZ1wzKXBFC3iKXZgnuMXw+NiBVLF/ C/3RRj7sorDEXE7EMHAtrZYIc28JnOj/LQe2BE7l0oYXiASEmE+V2cXUw4kVPuEuy3KIC c9AKby/ooyc6N+6bGn228PHxYhBV6NH07ucJ4C87VO8JdhvXRmkcn6Vawa49K5KdCutbd mG/Av1pUhWK8U6EMeWRAVTmYtcWLdO5p4HDFGSf3A36aScCR/3jjHU7wkm71a9GKEHodc knF/mMGlUZtaN5g9CUFOb65WnwyT0/2c3klKtKJhwSuCpzilOUCVg99/PupLCln6uXw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="NP/lfqAG"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CD35606A31C for ; Sun, 29 Nov 2026 14:17:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NP/lfqAG Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA46F1F000C1; Sun, 29 Nov 2026 14:17:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795961867; bh=ajHUbW9qy3rSlms+r6YCUujSWyMYHZFoNC2Po+7bfbo=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=NP/lfqAG4zoGH3+sgyFmxXqe6otasiIfNcx1bH12CLDe3h6nyQRQYShZZqNmbc6qS glUbG+4rgQzLbhb3ItdMImK+HxNgTI7iKRKSGAWPpQOunaE5v2fmqORT93prQt1+1e tGfNotY8TIUCLieOPbZqGGOq3qlHgRIBd78/wjc5y8tKjm9gK9Sk7/I8TWee7Ihcbg Rtabi77MwT5JE8NTUvesVyoDZNYIyU9qUQNwCggLpUUBrwxb2Jtp/0sr4pXUsUtlcZ erxLTrbzf8YEc45KHc5bCHkLgweLsIeScD1+170DgyVOEsWW1IpxkB3rswVO7htEWC jzX7k6CHOEGTg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] usb: gadget: f_midi: restart IN transfers after SET_INTERFACE Reply-To: sashiko-reviews@lists.linux.dev To: "Jaegyun Lee" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261129140555.651497-1-dreams200260@gmail.com> References: <20261129140555.651497-1-dreams200260@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 14:17:47 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Critical] usb: gadget: f_midi: use-after-free race in f_midi_complete() [1] -- commit e9b2887e99b3e3e822534d3a7636ce9d94ac700a Author: Jaegyun Lee usb: gadget: f_midi: restart IN transfers after SET_INTERFACE This commit resets req->length on aborted IN requests in f_midi_complete() and schedules midi->work at the end of f_midi_set_alt() so IN transfers resume after SET_INTERFACE. > diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/fu= nction/f_midi.c > index 28d2e9db2450d..3e71ccb173a3a 100644 > --- a/drivers/usb/gadget/function/f_midi.c > +++ b/drivers/usb/gadget/function/f_midi.c > @@ -299,6 +299,8 @@ f_midi_complete(struct usb_ep *ep, struct usb_request= *req) > /* We don't need to free IN requests because it's handled > * by the midi->in_req_fifo. */ > free_ep_req(ep, req); > + } else if (ep =3D=3D midi->in_ep) { > + req->length =3D 0; > } > return; [Severity: Critical] This problem wasn't introduced by this patch, but can f_midi_complete() hit a use-after-free on req [1] when f_midi_disable() runs concurrently? When an IN request is queued, its pointer stays in midi->in_req_fifo. On normal completion, the UDC driver drops its controller lock before calling usb_gadget_giveback_request(), and usb_ep_disable() does not wait for in-flight completion callbacks to finish: CPU0 CPU1 usb_gadget_giveback_request() f_midi_complete() f_midi_disable() usb_ep_disable(midi->in_ep) while (kfifo_get(&midi->in_req_fifo, &req)) free_ep_req(midi->in_ep, req) req->length =3D 0; <-- use-after-free queue_work(..., &midi->work); If a disconnect or configuration change calls f_midi_disable() while an IN completion is entering f_midi_complete(), f_midi_disable() drains midi->in_req_fifo and frees req before f_midi_complete() writes to req->length and queues midi->work. [1] https://sashiko.dev/#/bug/linux-22a882f3-c221-4b3e-aa74-b2c3c35d00ab --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129140555.6514= 97-1-dreams200260@gmail.com?part=3D1