From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0846C2367CE; Tue, 8 Jul 2025 16:29:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751992174; cv=none; b=C5IVuV+O473NYyiu5GgDRgF3yLay9Bv5hjRqbPLwAKbQJkMIVp2N5m7aMI1Vtnm8sFUdiGxfcIxgyhMBR9qSZyB30KD9wNjCpASBBQlpp1tH49NA0xf2n+ZVjTCqVN9t2ei4G3Lrb1f8DGXpz5d6xvKL0Jtk8pgSJ1jYVolVLvg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751992174; c=relaxed/simple; bh=WTeUAqumBLemHLTCG4fyxIoMNelRs7pF3TI/x14N6rY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mYOK6a5749I+5y2lnqd17l+VubFNnzqiSAgey9jIJ18U6HvFlqQudqGTpWfiF8kGSTi+WTnB3gCsN7VFcfHgiVeL6FbFPTs6hkmXxPfLU4Pjp7fS1XbY1dyZZELU6bmdnxLUED8vVhwlzcuhBk8+kjsfElcfbcpAGihTEvaLjk4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jFH59i+y; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jFH59i+y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8188BC4CEED; Tue, 8 Jul 2025 16:29:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1751992173; bh=WTeUAqumBLemHLTCG4fyxIoMNelRs7pF3TI/x14N6rY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jFH59i+y1VfB+bTQ0UED4WF/8HlVO5D+FhUnJfHjMnFS6r+Agb0o+/wq6hj8Z1zOv 7WxBf1TgW94r6IHDhB6zddEr45wY0gfWLA65R+ZZcIAl0OQ2Dy+yqMJEk0wRRdmjOd tLVuOLCO/891j8QMQxcUKvEk3T9fngvmJDLkkZ+o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Maurizio Lombardi , Mike Christie , John Meneghini , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 6.1 52/81] scsi: target: Fix NULL pointer dereference in core_scsi3_decode_spec_i_port() Date: Tue, 8 Jul 2025 18:23:44 +0200 Message-ID: <20250708162226.661803615@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250708162224.795155912@linuxfoundation.org> References: <20250708162224.795155912@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maurizio Lombardi [ Upstream commit d8ab68bdb294b09a761e967dad374f2965e1913f ] The function core_scsi3_decode_spec_i_port(), in its error code path, unconditionally calls core_scsi3_lunacl_undepend_item() passing the dest_se_deve pointer, which may be NULL. This can lead to a NULL pointer dereference if dest_se_deve remains unset. SPC-3 PR SPEC_I_PT: Unable to locate dest_tpg Unable to handle kernel paging request at virtual address dfff800000000012 Call trace: core_scsi3_lunacl_undepend_item+0x2c/0xf0 [target_core_mod] (P) core_scsi3_decode_spec_i_port+0x120c/0x1c30 [target_core_mod] core_scsi3_emulate_pro_register+0x6b8/0xcd8 [target_core_mod] target_scsi3_emulate_pr_out+0x56c/0x840 [target_core_mod] Fix this by adding a NULL check before calling core_scsi3_lunacl_undepend_item() Signed-off-by: Maurizio Lombardi Link: https://lore.kernel.org/r/20250612101556.24829-1-mlombard@redhat.com Reviewed-by: Mike Christie Reviewed-by: John Meneghini Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/target/target_core_pr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 1493b1d01194f..a355661e82027 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -1841,7 +1841,9 @@ core_scsi3_decode_spec_i_port( } kmem_cache_free(t10_pr_reg_cache, dest_pr_reg); - core_scsi3_lunacl_undepend_item(dest_se_deve); + + if (dest_se_deve) + core_scsi3_lunacl_undepend_item(dest_se_deve); if (is_local) continue; -- 2.39.5