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 4A5C418595E; Tue, 10 Sep 2024 09:58:39 +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=1725962319; cv=none; b=VtUCdNlT83+z8j1vLIuGtSbTVSc7xST6vdVQTz1ylD/C2TX3tZ0lVcGTLi36qPeehM9BNDrUEpvduALa+b1SFWXUfcXNnN8UICu+zzgcEsdGV0LKrFP9oeMc4ZoPJgjLgl2r0CptuqIaEVO6kNtnqmVQMkBi0va1/SEPvEHMnIU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725962319; c=relaxed/simple; bh=3mlZlLYSbgf7hAZRfKxIG7XjoylRoo5DYYiPP7y/qfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YokB3kz0MpvGgQQDc9Bfv1khwVbWlC7gRrKq9YD3LIoowjjWpUV/jL6u352VxUIsIFlsfrkoHdaHrEGz3K6G1RCwddfqwlAUhYIyVbJiZFXHF50QE6GfuiOyfnUG4Y+xcgrONnD+OBga4/8yzY+ErU7D84TjL6tccaYCQV/VhRo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GLL6/Y2U; 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="GLL6/Y2U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C47DDC4CEC3; Tue, 10 Sep 2024 09:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725962319; bh=3mlZlLYSbgf7hAZRfKxIG7XjoylRoo5DYYiPP7y/qfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GLL6/Y2USO84xc9PppomH5lWTbOdOj32mvUuBEfgzTnJQliSAbFTZIYYfpwbTaV0E a5keMAQJz9lv8DIN4SV/GUxRkYWU5VLc2WmDMFT87W0z9xW7P4jPT5MWxQha406xBC gwcSJ9cvutPh53CCJ22oXA0cRipUNAWXlvFXZ/9U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Maurizio Lombardi , Christoph Hellwig , Keith Busch , Sasha Levin Subject: [PATCH 6.10 343/375] nvmet-tcp: fix kernel crash if commands allocation fails Date: Tue, 10 Sep 2024 11:32:20 +0200 Message-ID: <20240910092634.111458151@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240910092622.245959861@linuxfoundation.org> References: <20240910092622.245959861@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maurizio Lombardi [ Upstream commit 5572a55a6f830ee3f3a994b6b962a5c327d28cb3 ] If the commands allocation fails in nvmet_tcp_alloc_cmds() the kernel crashes in nvmet_tcp_release_queue_work() because of a NULL pointer dereference. nvmet: failed to install queue 0 cntlid 1 ret 6 Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 Fix the bug by setting queue->nr_cmds to zero in case nvmet_tcp_alloc_cmd() fails. Fixes: 872d26a391da ("nvmet-tcp: add NVMe over TCP target driver") Signed-off-by: Maurizio Lombardi Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/target/tcp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index 380f22ee3ebb..ebf25819a7da 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -2146,8 +2146,10 @@ static u16 nvmet_tcp_install_queue(struct nvmet_sq *sq) } queue->nr_cmds = sq->size * 2; - if (nvmet_tcp_alloc_cmds(queue)) + if (nvmet_tcp_alloc_cmds(queue)) { + queue->nr_cmds = 0; return NVME_SC_INTERNAL; + } return 0; } -- 2.43.0