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=1796381319; b=YcwpdscSymqokeTmixKzCKMkOL/IJe68FFmSevt2UGhXAY75UFf2YrqldGjzlfhrzhMl WrIJQtNmYQ0ZYl6yOhoGl4n6kdt0byJS5Kat28ITNkrPRlzsJLSYpXIpbPmJWnoB1TRsz Gp52iVn+5qgjFcIXuq2YxItoh0bHh+cEWcHuj2aaHMfLD3MEN15WiOXCSVlvyPCXW6Cdc Ug8vqmp0Njimjyr7MBQ3sqmZmBQqQJM/lSfWDZ4DrXfJLBXrbKl1C4G6PrEEIMCXAHzSz ujatWo0jOKF0Qx2Nn79oXmTlwYlo5S0jjONSSSso1ocpeDhQlV3JFt7LwxSMVQN6PfQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381319; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=MJVDEBSKGybhuCDDJMJMqIbS0LtZhPA74chVMGKbYg4=; b=NSVWA+DsY4AJvpgL5RiuK59nLbmwlbij4wZWFYZ6cXz1sA70wC+wLhxPJSozRUtodDvu O+LUqTYaClW3m2I7iszC/jQdyFmmkYfbhOj4R2D774ziSHuCcz1nwV9PLAR/Xq//9k5yx x5wqUDdtXUSynlKtJiPODh346U6rZ39kK/0GdNIP/0V0t8wkU6gLAKFdRV87F0aSh8VYY 17wASK5EN7Ft6qDKkPFN8LyptwxLXdJRTh+sTSw+/aFhtScQmxV4RRXe8CmJ2i7Jr5+Uu tk1Gt/nilLbKfGlVMpYTmYR2AtdB/XLV0lNQiRHvV4E3xJer85PD++ng3ON0bkYsIkA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=NZ22MGfX; 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 B8C25606A322; Fri, 4 Dec 2026 10:48:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=NZ22MGfX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3557F1F00897; Fri, 4 Dec 2026 10:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381319; bh=MJVDEBSKGybhuCDDJMJMqIbS0LtZhPA74chVMGKbYg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NZ22MGfXnd04I5Wz7dQJ4st9px/UifqHyvzJXOOuuX9lkOg5bMuEE+gKztWj4s0Fe HhCc1+uYv+YO4eGS0rS4Yp52AoAuh6mbZ0ZYYMnZl5qYSlRJP2lt3iG1BomFs2tNQO pwKZ8toS//vYJ8q9Y5KXSwQ/sIZ8HXG/Pusn3aPU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shao Mingyin , "Martin K. Petersen (Oracle)" Subject: [PATCH 7.3 651/742] scsi: target: Fix NULL pointer dereference in core_alua_do_port_transition() Date: Fri, 4 Dec 2026 19:08:35 +0900 Message-ID: <20261204100652.383095919@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shao Mingyin commit c0bb6614132c64205a3c40c32dc1494c1bfeffe1 upstream. core_alua_do_port_transition() assumes that the device has an ALUA LU group member and that the member is associated with an LU group. Neither is guaranteed: internal-use HBAs never allocate dev_alua_lu_gp_mem, and the association with an LU group is dropped when "NULL" is written to the device's alua_lu_gp attribute. The configfs path can reach the second case. After clearing the LU group association, writing the implicit ALUA access state of a target port group calls core_alua_do_port_transition(), which dereferences the NULL lu_gp in atomic_inc(&lu_gp->lu_gp_ref_cnt). Return -ENODEV when the device has no LU group association instead. Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6") Signed-off-by: Shao Mingyin Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261026195133237y2UxJLoV1FK6aD1zrFbIU@zte.com.cn Signed-off-by: Martin K. Petersen (Oracle) Signed-off-by: Greg Kroah-Hartman --- drivers/target/target_core_alua.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c @@ -1081,8 +1081,15 @@ int core_alua_do_port_transition( return -EINVAL; local_lu_gp_mem = l_dev->dev_alua_lu_gp_mem; + if (!local_lu_gp_mem) + return -ENODEV; + spin_lock(&local_lu_gp_mem->lu_gp_mem_lock); lu_gp = local_lu_gp_mem->lu_gp; + if (!lu_gp) { + spin_unlock(&local_lu_gp_mem->lu_gp_mem_lock); + return -ENODEV; + } atomic_inc(&lu_gp->lu_gp_ref_cnt); spin_unlock(&local_lu_gp_mem->lu_gp_mem_lock); /*