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=1795960564; b=vQjLKpcEPnhGT0NirjKjEmUbTnnSFYnUHe6oX5s3uWZJp5cWfNtTqwJr+UTSD1a81iwF uP1gD2OwQT1gqZlZF4uQSERGVQKfovzacv3xVO8RzLfSdmZ9mjTkawJfOEMNfkjFBWTQU DeKdRC3N12RShDPFcjfibZXE/EM1DJpR1kddW/uBuxabMXgAUDODN48iKMV28ZxKZ1nHh UUn5ikO2mYHq/k3COr5aIyIaEM6S7isdxcYGJxdmxx09Gf7auoPDZETMwMXvOPuEYD6zU 8BoVdQfZ0UeP5bxIpInEhqfYrkfsNhWiiagXndAeJtDdTkMTamQgc9JUAfHlWiAwEiQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795960564; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Hosqj9efXQFlQw1iVXYz86oVfrGd+qLlAbLYXM6uGow=; b=2tVTTXs1egP09vxKYlL7XA4EJexDn/gzGdJQSBmbFXu8dlBd3wvWdyRSZFoB30bIR5b3 s/IGBPIV1Oa697o9tPo8PaoJex1RPfa30rRETXadwBAQOaG96d6lTzqHZueeJr4wEMNb6 0S+y52zWeMVzJI7AGHiSiosehTt37KNU/GQHLVQ0n6MHQxLWyHpvn1MsguJGdVhfZ7bAN vfotMCFa0c75KXyAe6CKaPzLZmrjrN3Qf3C336GF53IRWhqUMdTM1PcRlscmBQCk04FMl hn63h4GoXV1pprllYspY0eAs12MYf03lntv+ckiThMfGt1CVEySXZdfof4ZP/mbI4LA== 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=MBxxvN3R; 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 8F4E1606A33B for ; Sun, 29 Nov 2026 13:56:04 +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=MBxxvN3R Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4AE51F00927; Sun, 29 Nov 2026 13:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795960563; bh=Hosqj9efXQFlQw1iVXYz86oVfrGd+qLlAbLYXM6uGow=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=MBxxvN3RDejlrbYN2ZxSYa7jO23c8jQiVFPhOE+s8MYT16NIKKASGyR7/xAgC4XUL 39y2Hlt83VAjIjoBQ8KYlDUSMxrnerBcatOuGZRB65fSadLQ7VhgYILnVwNAvVz2uu n5zfWSdU+yCnbLyTAS0HS3Ng+HGMNLqTZ59AUHZGahgbFvs3jiPIRwiOhXDXBTDxNM 9S/Pb3TOGuW5EzIog/rgpcd5QfuLEA+sWqKdoSK2XPW+NZ1yKAqtof/MvdqBxN/HFj lzkzL+0UtBVAfhU8/2+BkxTRikiYb7D0akFEk41VlFi6nOSolzfcT6FdoZ6QhT4/dk WF7n4IlEk/fYw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/2] usb: gadget: f_tcm: complete the Bulk-Only Reset status stage Reply-To: sashiko-reviews@lists.linux.dev To: "Jaegyun Lee" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261129134752.422736-2-dreams200260@gmail.com> References: <20261129134752.422736-1-dreams200260@gmail.com> <20261129134752.422736-2-dreams200260@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 13:56:03 +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: - [High] usb: gadget: f_tcm: data race in usbg_bot_setup() and bot_cmd_complete() [1] -- commit 8c8c2b026d0d7c87ed616a18a1d98e7e4805cec5 Author: Jaegyun Lee usb: gadget: f_tcm: complete the Bulk-Only Reset status stage This commit validates the USB control request fields for US_BULK_RESET_REQUEST in usbg_bot_setup() and queues a zero-length status stage response on ep0. > diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/fun= ction/f_tcm.c > index 2d74ca7c6d126..b213f57cb8296 100644 > --- a/drivers/usb/gadget/function/f_tcm.c > +++ b/drivers/usb/gadget/function/f_tcm.c > @@ -466,6 +466,10 @@ static int usbg_bot_setup(struct usb_function *f, > return usb_ep_queue(cdev->gadget->ep0, cdev->req, GFP_ATOMIC); > =20 > case US_BULK_RESET_REQUEST: > + if (ctrl->bRequestType !=3D (USB_DIR_OUT | USB_TYPE_CLASS | > + USB_RECIP_INTERFACE) || w_value || w_length) > + return -EINVAL; > + > bot_dequeue_req(fu->ep_in, fu->bot_req_in); > bot_dequeue_req(fu->ep_out, fu->bot_req_out); > bot_dequeue_req(fu->ep_in, fu->bot_status.req); > @@ -475,7 +479,9 @@ static int usbg_bot_setup(struct usb_function *f, > } > =20 > bot_enqueue_cmd_cbw(fu); [Severity: High] This problem wasn't introduced by this patch, but can usbg_bot_setup() and bot_cmd_complete() race on fu->flags [1]? The USB gadget framework does not serialize ep0 setup callbacks against bulk endpoint completion callbacks across CPUs. Both usbg_bot_setup() (and its call to bot_enqueue_cmd_cbw()) and bot_cmd_complete() perform unlocked read-modify-write updates on fu->flags: drivers/usb/gadget/function/f_tcm.c:bot_cmd_complete() { ... fu->flags &=3D ~USBG_BOT_CMD_PEND; ... ret =3D bot_submit_command(fu, req->buf, req->actual); if (ret) { ... fu->flags |=3D USBG_BOT_WEDGED; bot_enqueue_cmd_cbw(fu); } else if (fu->flags & USBG_BOT_WEDGED) { fu->flags &=3D ~USBG_BOT_WEDGED; usb_ep_clear_halt(fu->ep_in); } } If an ep0 reset arrives while an ep_out CBW completion is running on another CPU, one update can clobber the other: CPU0 CPU1 usbg_bot_setup() bot_cmd_complete() [read fu->flags] [read fu->flags] fu->flags &=3D ~USBG_BOT_WEDGED; fu->flags &=3D ~USBG_BOT_CMD_PEND; [write fu->flags] [write fu->flags] <-- lost update Losing an update to USBG_BOT_CMD_PEND or USBG_BOT_WEDGED can either double-queue the CBW request or leave USBG_BOT_CMD_PEND stuck set so that bot_enqueue_cmd_cbw() never queues another CBW. [1] https://sashiko.dev/#/bug/linux-7f1632bf-7fa1-4d1c-9f74-d3b84235cdd5 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129134752.4227= 36-1-dreams200260@gmail.com?part=3D2