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 20B691DFEF; Tue, 23 Jan 2024 12:50:18 +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=1706014219; cv=none; b=BTwr3ZjxGK4ZMy5MEK4FTwyPrZGgtnOupI2d3iC3aYS4FlwOxyTN3/Y2PI8zAc8KT6jeTSE0VsjIsAXiaugtpU3IEKn4qv3aKeJL3orKg3P/4TSRHwmoTowzj3lsaiOkgZgIwKcS0dlq0eZ3NSXroti5v+f8+UDoQLEDFpycbrc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706014219; c=relaxed/simple; bh=xbj1QbbQa6Ov7mSf2EyCNGNmPTpu/2y0qTLH7AXiPo8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bJLvN6QQKAFYSUfi9TMqnvSymMMUK9iBZjqg/8M459ThzCncMUjoWN1haMWZdFm0g1y6p1bHKpWEvk+bG1UNvnKC97+zhDS1Dacdbn4i2hIBW9RLQmzXUo0XzPSR/Wwxvm2zI970uszbUBegF1tDNmQzt1npm9I8rXrSuQKBmqM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BHSFQbKF; 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="BHSFQbKF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DC67C433C7; Tue, 23 Jan 2024 12:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1706014218; bh=xbj1QbbQa6Ov7mSf2EyCNGNmPTpu/2y0qTLH7AXiPo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BHSFQbKFfb1Fwi9TTkIE5peQEVFtw8D5sAbi08J6uNtwp6525WP5ZRSo2c/jyn2lq shqrxJFTYqJSUt3aNGUWtuIReh7mYP7O61xHh+NwSUJS2WvifzQMzFKcJosD8CSNq3 0tYLZ6fqwQnOHbiI/KwIaI5mxZR2tQkeA37SeMzY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sagi Grimberg , Maurizio Lombardi , Keith Busch , Sasha Levin Subject: [PATCH 5.4 172/194] nvmet-tcp: fix a crash in nvmet_req_complete() Date: Mon, 22 Jan 2024 15:58:22 -0800 Message-ID: <20240122235726.581177997@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122235719.206965081@linuxfoundation.org> References: <20240122235719.206965081@linuxfoundation.org> User-Agent: quilt/0.67 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 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maurizio Lombardi [ Upstream commit 0849a5441358cef02586fb2d60f707c0db195628 ] in nvmet_tcp_handle_h2c_data_pdu(), if the host sends a data_offset different from rbytes_done, the driver ends up calling nvmet_req_complete() passing a status error. The problem is that at this point cmd->req is not yet initialized, the kernel will crash after dereferencing a NULL pointer. Fix the bug by replacing the call to nvmet_req_complete() with nvmet_tcp_fatal_error(). Fixes: 872d26a391da ("nvmet-tcp: add NVMe over TCP target driver") Reviewed-by: Keith Busch Reviewed-by: Sagi Grimberg Signed-off-by: Maurizio Lombardi Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/target/tcp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index 1747d3c4fa32..1f584a74b17f 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -886,8 +886,7 @@ static int nvmet_tcp_handle_h2c_data_pdu(struct nvmet_tcp_queue *queue) data->ttag, le32_to_cpu(data->data_offset), cmd->rbytes_done); /* FIXME: use path and transport errors */ - nvmet_req_complete(&cmd->req, - NVME_SC_INVALID_FIELD | NVME_SC_DNR); + nvmet_tcp_fatal_error(queue); return -EPROTO; } -- 2.43.0