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=1796185183; b=5fFr5EDWUVkwBg2q3vyRzzlujaB8/H6KMoWuRtwj458xeouh2OVSB2qk+bCSEbUuZest HklzkxvSYg2kAuXMaa0yaLz+28cjMaCbVWHFiQbz9WMpxQFGujX1cLSQe7MHQZYKsHUOo E4QkiDcrhodDZmATMOarakBuQg6kdhJ1be6vHKHIHsM30zf+hIJ115BSFucvYB13ffllY dlh2ukLt+uxjV6mMNlolemmcpv/GBtojki2ZVYZtrvkIutNVFihSp3jJxKBQJ3hzDqt0/ joIN7QLeiVrx7w3ySpTdUCu6QKee/bYW7CDeleAtLW6G572RyZT6rlA2xEWGvEGUHtg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796185183; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=NaOSSgtUs4/R+srk6tdckdxaXG5KarV8LhOUnxDTtr8=; b=uqEmAlVTqutH/Hm0FrhERUAavhkd6C82gHxzEwiA0Ha4RzDMvlRoC8CPDSwKfiwnombd YvdDYnRyI1A+aXegEEJoEcdlIMrTSG0RqJGxWv14PjduUgHtz81OYLYm4ZZsK0O9lXv5b SN+OZNYlKy69y8uDpssevSmysJshxTsY1+mh+rSh3pvc/ETax13GpHZZIezNOr30fKwlT fVd75L5ygERd0JjJiYHaU4VQbTQW1HvTFEoROditsNvsG/13NV/I3jbPX9ipTK7BZ4YLC JrGE2t7jPsCZ40waHvPdY7xffDCtzbJU2dl1sJj6ITWEk7A9Syf/YqxzfGphLXehkyA== 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="MvRf/AD/"; 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 27067606A31A for ; Wed, 2 Dec 2026 04:19:42 +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=MvRf/AD/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD84F1F000C1; Wed, 2 Dec 2026 04:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796185182; bh=NaOSSgtUs4/R+srk6tdckdxaXG5KarV8LhOUnxDTtr8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=MvRf/AD/h6hmUhekRhH1xSAErhRghOXQkWNcWfkspRNCJKh6IgYS3/XWMBQDFhZCQ H3PJpyBZoeyMOgDF2cDxqduOxJss9BLz84QVD9t+xzUFulFGEjDzyRzIoOEqLMyhmP eX5Kw5khosO5A0TN/ExFTPM5mFDoqBB1Ef6g8SHilj00JUBiEfcfOcAFF5SjdWh+0D EbSrJxc3wt60OevK5dBfNA82t+6yqOB+05xccR+idZc/QXtyJyXUeNlRTPoqjIUG2S /6ioj7RZTPQFexFbLenOMYB+z5Fo5d01/ITT58q9Ky8xpMumVidQaMqChoEqka/m3I LydDxjtoMvpmw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] scsi: st: Free the reserved page array on probe failure Reply-To: sashiko-reviews@lists.linux.dev To: "Haoxiang Li" Cc: linux-scsi@vger.kernel.org In-Reply-To: <20261202041412.4009678-1-haoxiang_li2024@163.com> References: <20261202041412.4009678-1-haoxiang_li2024@163.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 04:19:41 +0000 X-Mailing-List: linux-scsi@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] scsi: st: use-after-free in st_probe() [1] -- commit bf382c81186020068666c0ef5a2d0f660a45bfd1 Author: Haoxiang Li scsi: st: Free the reserved page array on probe failure This commit frees buffer->reserved_pages on the st_probe() error path before freeing the tape buffer itself. > diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c > index e9d41e3cc2dd3..77f4a66af2ec3 100644 > --- a/drivers/scsi/st.c > +++ b/drivers/scsi/st.c > @@ -4593,6 +4593,7 @@ static int st_probe(struct scsi_device *SDp) > out_free_tape: > kfree(tpnt); > out_buffer_free: > + kfree(buffer->reserved_pages); > kfree(buffer); > out: > scsi_autopm_put_device(SDp); [Severity: Critical] This problem wasn't introduced by this patch, but can kfree(tpnt) at out_free_tape cause a use-after-free [1] if a concurrent st_open() acquires a reference to tpnt before probe failure cleanup completes? st_probe() publishes tpnt in st_index_idr via idr_alloc() before allocating tpnt->stats and calling create_cdevs(). If either step fails, a concurrent opener can look up tpnt in st_index_idr and increment tpnt->kref before out_idr_remove removes the entry, while out_free_tape frees tpnt unconditionally instead of dropping its reference: CPU0 CPU1 st_probe() kref_init(&tpnt->kref) idr_alloc(&st_index_idr, tpnt, ...) create_cdevs(tpnt) // fails st_open() scsi_tape_get() STp =3D idr_find(&st_index_idr, ...) kref_get(&STp->kref) remove_cdevs(tpnt) idr_remove(&st_index_idr, ...) kfree(tpnt) filp->private_data =3D STp; ... <-- use-after-free [1] https://sashiko.dev/#/bug/linux-9c29c2d3-7e87-4362-b5ae-ae4459b36d9f --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202041412.4009= 678-1-haoxiang_li2024@163.com?part=3D1