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=1796371104; b=BG4ER8V/7VIppFe9aoxewuGve49YNeg4AqXsDMY/L3UdRSDNIhDYi05nf/bt4z3PSHA2 zi+IeiH2I2qZpjLEdpQ9ZwqdV0doTyC3QlAJzcH03nTqSqfo9VpipgEsGc25IYpo0RX76 iIfGNbKm6zKkAVV1yoy1g2gjL6Ufr6rQrgaIWwzUb43/dqpLeqstKRdW7RWGQsLsSia8j EpN2RaSWKcxEpGUjcTGdnNsJZt3s1ON7JIvfOEsEjdDCCG5J58p9ox8Id+JxsfV3gk/2O jWgUVK3WLezUEuvH3q+MGHB4tY3aAsvCRMscJ/gbqIje2qhDf+7GozAmm2VmoIDc/PA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796371104; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=NLADZI00Vck6kGCc/tb4F7y464vzuMrZfOkO/F+tEs0=; b=J4OdTnDFRIObFaYS8BpDjGCLZ8SUBKE3yehS82G9t943zV6hSJlIBuYsRc4d92BpIX5c Rt8E3VbB3BlrKt1ZSqeLTCPvUGz/oqKx9gs1FbnzET1gKxwlOluDGBTFmt3Ywc6b36hd5 5mqmRf2yblZe8tm1W2kRztQNubgkJq0K8iY3ECRIqVbKIiYvPdXY45fziTN2d2z3anfV6 QxtzvmnGghCpx9yg6wkr/tBugB88ltxWc5VGM/F1aIYTHukq1FZr1rbjHuJ7NzXLyfB3O b4+kJVTbdKqQ4no+8OwndtZaIWpzrnG5O5n27LlP9PWkeJKY+MtIn2We+qApTyn7FtA== 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=aeB8u5eM; 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 6F354606A32C for ; Fri, 4 Dec 2026 07:58:24 +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=aeB8u5eM Received: by smtp.kernel.org (Postfix) with ESMTPSA id F38681F000CE; Fri, 4 Dec 2026 07:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796371104; bh=NLADZI00Vck6kGCc/tb4F7y464vzuMrZfOkO/F+tEs0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=aeB8u5eMhXXrEC5x7BZ8f+wKXkJ0GIvEBL+bQ+0oEhNo+RfArXWoPeimAH2dXS80d eWxRAq5UlSh/YO3w9CXmJOZoaMJi1mDilWC4KL1IbXHfyANDtGH9wK8+67Y0jmC7rm PhGy+u3OHAlDw3N7FhuFR3oeAbHBxFsv5a8G40bnUvq0iQPo7PPKVWhBTR415xDG+E dy/cmFJs6VsFnGi8W2QN9vG6muvliqedopsA7O1fVSn0oc5iQss1xVMyFu6vqUd5lj Q26hn6ZD2YIqrXPlzX7YVwAYllo+dt7J9+zdKdQJUomSdzT29YylqZGeIvzAsWAl+5 js0An2+6rM+uQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3] usb: gadget: f_tcm: take the TPG in tcm_bind() instead of tcm_alloc() Reply-To: sashiko-reviews@lists.linux.dev To: "Slawomir Stepien" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261204073332.1657586-1-sst@poczta.fm> References: <20261204073332.1657586-1-sst@poczta.fm> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 07:58:23 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list > tcm_alloc() runs when a TCM function is symlinked into a gadget > configuration. It searches tpg_instances[] for the function instance > and copies the TPG pointer into fu->tpg at that point, under > tpg_instances_lock, and fu->tpg is never updated afterwards. >=20 > The function and the TPG can be set up in either order. If the > function is linked into a configuration before the TPG directory is > created, fu->tpg stays NULL. Creating and enabling the TPG afterwards > lets tcm_bind() succeed, and the first USB request that reaches the > target code dereferences the NULL fu->tpg. Likewise, if the TPG is > removed (usbg_drop_tpg() detaches the gadget first) and a new one > is created and enabled, the next bind keeps using the freed TPG. >=20 > Store the TPG in struct f_tcm_opts instead: set it in usbg_make_tpg(), > clear it in usbg_drop_tpg() and copy it into fu->tpg in tcm_bind(). > [ ... ] > Cc: stable@vger.kernel.org > Reported-by: syzbot+2799146a53c356f8017d@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=3D2799146a53c356f8017d > Link: https://syzkaller.appspot.com/ai_job?id=3D51e1f189-6d91-4321-a6ba-0= 7d4eb3cd8cd > Signed-off-by: Slawomir Stepien Sashiko has reviewed this patch and found no issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204073332.1657= 586-1-sst@poczta.fm?part=3D1