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=1796367628; b=qvw1qiYENNOGobaPAnhZJ0BV8N5rZj31d43j+VHj9q34PnQCpnMhnN7FLbRHIsJAC4WN turPcn5gJlzlpZE63+t6AeNpbWed8YVjohLKT/c9xkYsPtsdeIMXP7j+y6bmGLFFwbdRQ 2xtfKdnBiOuK1PrX0dHvyS7B6muLmSNffyz84T8KwL4NQdgeuF91WX+QisdLsIcKkGAkN hDsBZMc37b4z8JIOIOxTA1TCpB53w7wgVjOY/HZkqd3IWe+Ag3cGZrCoE+kzPFBMOWTrA o2FcdfrSrQ+tipMLspMwXSTaS83TY49+wC6SAexpUQmsxcUUplZS9n6P8lbTSQci0Sw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796367628; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=vUBfHBsE11ocDDve1UEfyKVy1xk6PQTCNNzYug2lLxs=; b=CmLkP+/mNxtC+miJIWPBECQ+X0M0fVf4ZKEolLVAHFib1i1WC6yALR6BFtjZJzkl3IBP 5RcqHIgwUtq+XUuXmufUhwZvVeA/MMhd9wZ8XmMx2/ZrM4JMRgQHeULevS1np975gO6aE cl9wAaRPUbnCns8dBo9Qm0x4rzuZRNRcSlDlZCUXU384qK3COx0WZk9jWMXPZ/14hfcgj VUorc+kkKncZqS+fqdBiXZ5VQ0kAbhPuEzTB+2vp9JxVVuLLu1yQ246CelCyG3zMSzQcA IPqdGNmwlBxbABCrRLUW+pmQlKk0N13MUy3OkBtlaLhFYiPe6PiJluLcldYZnb2Ecmw== 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=DLnZHPKN; 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 E27EF606A32C for ; Fri, 4 Dec 2026 07:00: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=DLnZHPKN Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC2A31F000C2; Fri, 4 Dec 2026 07:00:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796367627; bh=vUBfHBsE11ocDDve1UEfyKVy1xk6PQTCNNzYug2lLxs=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=DLnZHPKNe32+LqUYe0HHPJAQx9kkE9RKueFopsSBRlcNzpkpCpfaeig2OtDe2yjv/ +u2OAw7I1kEDjS50K0yEex0gsLL56K+o0wXZoJ1MCk+7eNnkgqrjgVHATtvVR1se3r Pnw80Kg+PuZj5Qo01MOkV28efWR3grCZpykkmtoM4AKBDCvATUqOlhhFthH95vho8X a/LjAtnjqotXfWc6H1GXWfW22pcvfClRjTT7djololcpZuTkmL1XFLeNsKjvVaEP/Z ZVKCBTqwYt8aXolnL1y+j+5ZOlVz9Oy6AI1aBmxtFe9rffGWyfIJ9yI62Nx+mN3jA7 dZRtwbyxN5eLQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] scsi: leapraid: bound the phy index used to update card links Reply-To: sashiko-reviews@lists.linux.dev To: "Hongyu Guo" , linux-scsi@vger.kernel.org In-Reply-To: <20261204062938.344219-1-guohongyu@cmss.chinamobile.com> References: <20261204062938.344219-1-guohongyu@cmss.chinamobile.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 07:00:27 +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 1 potential issue to consider: - [Medium] scsi: leapraid: leapraid_transport_update_links() reads topo_node after unlock -- commit 29d15e789a79f9b363f1bebb028e93bbca890708 Author: Hongyu Guo scsi: leapraid: bound the phy index used to update card links This commit adds a bounds check on phy_index against topo_node->phys_num in leapraid_transport_update_links() before indexing into topo_node->card_phy[], logging a warning and returning early if it is out of range. > diff --git a/drivers/scsi/leapraid/leapraid_transport.c b/drivers/scsi/le= apraid/leapraid_transport.c > index 77ffbd6ddce4c..7468276b4a102 100644 > --- a/drivers/scsi/leapraid/leapraid_transport.c > +++ b/drivers/scsi/leapraid/leapraid_transport.c > @@ -1146,6 +1146,15 @@ void leapraid_transport_update_links( > return; > } > =20 > + if (phy_index >=3D topo_node->phys_num) { > + spin_unlock_irqrestore(&adapter->dev_topo.topo_node_lock, > + flags); > + dev_warn(&adapter->pdev->dev, > + "%s: phy index %u out of range, max %u\n", > + __func__, phy_index, topo_node->phys_num); > + return; > + } [Severity: Medium] Can reading topo_node->phys_num in dev_warn() trigger a use-after-free? struct leapraid_topo_node has no reference count or RCU protection, and leapraid_exp_node_rm() frees expander nodes right after unlinking them under topo_node_lock. Once LEAPRAID_EVT_SCAN_DEV_DONE clears scan_start, fw_evt_thread can run leapraid_transport_update_links() while the SCSI scan thread removes an expander via leapraid_probe_sas() -> ... -> leapraid_exp_node_rm(): CPU0 (fw_evt_thread) CPU1 (SCSI scan) leapraid_transport_update_links() spin_lock_irqsave(...) topo_node =3D ... if (phy_index >=3D topo_node->phys_num) spin_unlock_irqrestore(...) leapraid_probe_sas() ... leapraid_exp_node_rm() spin_lock_irqsave(...) list_del(&topo_node_exp->list) spin_unlock_irqrestore(...) kfree(topo_node_exp) dev_warn(..., topo_node->phys_num) <-- use-after-free Saving topo_node->phys_num into a local variable before releasing topo_node_lock avoids dereferencing topo_node after the unlock. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204062938.3442= 19-1-guohongyu@cmss.chinamobile.com?part=3D1