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=1796364327; b=EPmeb5jyEupilb+ug3iiucdj3/LdyFa/Rizi8yJdoqTuNfzMHEzz+iE5FcAWzHVm4+Cj +OrvgQModE+VfPbwslK/RD2I8Zz+qHcsENl5j4TnWG0dLpIwapaMGZEaPPu552V5HgYkE kru979DjoLanPGiLrpMSMFhIhW9D2Fw8fmeJeEgpu26x89cP8UpwGPlNWKLB45GOiuwVf c0vjO+UhbWlUMSwXn1M3+KH45SenNoLoLDOlNtHk4bA4ACi5B1VK2RFHd8ApBncbFAvcC eTe5z8rJu/Ua/OwOI4qXDJQrl6vajB//9YcwzMdptmYXhgm8yqhZ5ZHI8C5W48yG7cw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796364327; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=L16Iku3jTSMrTQ/BO4PooA/O9l5c0RH4J9OFoBPOCJM=; b=t+Mp6bvdLghA9FG0OJVMSYFsLd/TvXZlat6zca1dQvoTB+oTZjByfvY3BEtKWCAMCqgI kCphhswi+37HhnoS2VDFuWInuRi8nuXzJuwd5UqASdlXh9FsFWbacIIZCsBB0kc8w7+vG 1VZZgQnCVhzZrWNp20vMzK0+DbtS+tYO6cL0J8iZNXsZLohnlnw/vw5qLxMMNKZIHATWH YMhUOpzUjndlHyFnbZIkHkAUFQuzhV4CMT7SQwXBmlC4okEnQdliz8fyXF69qvSzZKQ79 idc6yPcY9bGAnUx4FjPxZJQ2kazOeMwSO/Xu1TwzDPSiYrwpj27wBGcr2qVyqMPSjbA== 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=RUfYATsE; 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 ABFEC606A322 for ; Fri, 4 Dec 2026 06:05:27 +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=RUfYATsE Received: by smtp.kernel.org (Postfix) with ESMTPSA id 456721F000C2; Fri, 4 Dec 2026 06:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796364327; bh=L16Iku3jTSMrTQ/BO4PooA/O9l5c0RH4J9OFoBPOCJM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=RUfYATsE5zMQm63DIywVP8QBDyGmlL0GLQyPK5IIvH0wJ1jv4INydwi0eRdRV6WMe Ih+1ynEwtfWpTpi8J22qojz7LA27rAttT4WPvGFIzPM3CIwvEvjItIf5ogN7oA1T8n b+ex/YQb9xrH3Ewj/VoY8EJoHTMDHEcFZGskc0QXAPOHRXT0uTUbWRXKx2mSu83QAD 4z2V3orqw7lbqrcp7h2ZP27PqS5g19dlD5CDJavK93gS6YqInoNVsSVNJjhxUpWbqw 37mYSg6qJCBdDKCcqXySdPuc97sMt/9faUFfhLqMJGdR6XSVPNrJyvtB6JK65+YFv1 I/Bq+qk0CM4WA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH RESEND v2] usb: gadget: f_fs: fix use-after-free of ffs_dev in ffs_free_inst() Reply-To: sashiko-reviews@lists.linux.dev To: "Palla Raghunath" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261204055346.42890-1-raghunathpalla.0209@gmail.com> References: <20261204055346.42890-1-raghunathpalla.0209@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 06:05:26 +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 1 potential issue to consider: - [Low] usb: gadget: f_fs: __must_hold() fails without ffs_dev_lock() annotations -- commit 6c427f29e02317dd1e9434249fd97f907aa55e3c Author: Palla Raghunath usb: gadget: f_fs: fix use-after-free of ffs_dev in ffs_free_inst() This commit splits ffs_release_dev() into a lockless _ffs_release_dev() helper annotated with __must_hold(&ffs_lock) so ffs_free_inst() can release and free opts->dev under a single ffs_dev_lock() critical section. > diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/func= tion/f_fs.c > index 59afa7f2bce45..87befbca7af51 100644 > --- a/drivers/usb/gadget/function/f_fs.c > +++ b/drivers/usb/gadget/function/f_fs.c [ ... ] > @@ -4372,10 +4374,12 @@ static int ffs_acquire_dev(const char *dev_name, = struct ffs_data *ffs_data) > return ret; > } > =20 > -static void ffs_release_dev(struct ffs_dev *ffs_dev) > +/* > + * Same as ffs_release_dev(), for callers that already hold ffs_lock. > + */ > +static void _ffs_release_dev(struct ffs_dev *ffs_dev) > + __must_hold(&ffs_lock) > { > - ffs_dev_lock(); > - > if (ffs_dev && ffs_dev->mounted) { > ffs_dev->mounted =3D false; > if (ffs_dev->ffs_data) { > @@ -4386,7 +4390,12 @@ static void ffs_release_dev(struct ffs_dev *ffs_de= v) > if (ffs_dev->ffs_release_dev_callback) > ffs_dev->ffs_release_dev_callback(ffs_dev); > } > +} > =20 > +static void ffs_release_dev(struct ffs_dev *ffs_dev) > +{ > + ffs_dev_lock(); > + _ffs_release_dev(ffs_dev); > ffs_dev_unlock(); > } [Severity: Low] As reported by Greg Kroah-Hartman on v1 [1], does __must_hold(&ffs_lock) on _ffs_release_dev() work with the unannotated ffs_dev_lock() wrapper? Both ffs_free_inst() and ffs_release_dev() acquire ffs_lock via ffs_dev_lock() and ffs_dev_unlock() in drivers/usb/gadget/function/u_fs.h, which lack __acquires(&ffs_lock) and __releases(&ffs_lock). Clang context analysis does not infer locks across inline functions, so CONFIG_WARN_CONTEXT_ANALYSIS_ALL=3Dy triggers -Wthread-safety-analysis warnings (or errors under CONFIG_WERROR=3Dy) at both call sites and in the wrappers. Annotating ffs_dev_lock() and ffs_dev_unlock() would fix this. [1] https://lore.kernel.org/r/2026112029-depletion-small-f290@gregkh --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204055346.4289= 0-1-raghunathpalla.0209@gmail.com?part=3D1