From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 46562C35274 for ; Thu, 21 Dec 2023 16:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date :Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gz9u2x+CCEOXoZRoRgSgkoUNfVEjbxhWg+eCwj4e2+4=; b=ADRodcZoUQz1fF+vNF3f+OPtDq YPtby0m5vZu9ZUqP9Huyy9d8hahli/6icbFM/snkfnBqRlTi1KsshfwaNAaFTP+TJBhCVXijnD/IP ZrFWbwqmzBBYlVsVNFsujCnHHbhRJvNEDmqCEKJmRrJbeW367bWa7w59yd1bISu9rM16z0a/N4CJ2 UilMbzhWF40aaIl305AdQHxRVqmK2acfE4AOMCN6ubf7l9the8+FuTBe0eoLKiiwKEmnMxyp9L0jB giuQj0sqfwHGLCOkRBuVg6DqsP+X9e2OSKX30tKO26/M/8dHK+JHqZ2Le3Be33otTqBvbWKtmk9Ms L22shwlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rGLxx-003WRc-2Q; Thu, 21 Dec 2023 16:32:09 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rGLxv-003WQE-0r for linux-nvme@lists.infradead.org; Thu, 21 Dec 2023 16:32:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703176324; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gz9u2x+CCEOXoZRoRgSgkoUNfVEjbxhWg+eCwj4e2+4=; b=Ch78PEZJG8wx87CbGX/dl5MxVglNHlhnv+UVmkEJB/igcNyZmeqS3j51uQabOtBdrqGo1r YbOCWZrnAFg7iHovBTzTTU3NKpx8Mlt93fh+hRfExrcCaUumRb6f+69h3MpMG7XCc/7JK2 0ilHgZkHlNSAJdAPh6pvWop7hjD9ft4= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-JJs9KNgmOwmR4NfWEiNoRQ-1; Thu, 21 Dec 2023 11:32:02 -0500 X-MC-Unique: JJs9KNgmOwmR4NfWEiNoRQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4A69428040C1; Thu, 21 Dec 2023 16:32:02 +0000 (UTC) Received: from kalibr.redhat.com (unknown [10.47.238.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C3F62026D66; Thu, 21 Dec 2023 16:32:00 +0000 (UTC) From: Maurizio Lombardi To: sagi@grimberg.me Cc: zahavi.alon@gmail.com, hch@lst.de, chaitanyak@nvidia.com, linux-nvme@lists.infradead.org, kbusch@kernel.org Subject: [PATCH 2/2] nvmet-tcp: fix a crash in nvmet_req_complete() Date: Thu, 21 Dec 2023 17:31:54 +0100 Message-Id: <20231221163154.605669-3-mlombard@redhat.com> In-Reply-To: <20231221163154.605669-1-mlombard@redhat.com> References: <20231221163154.605669-1-mlombard@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231221_083207_393500_61530BAE X-CRM114-Status: GOOD ( 12.35 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org 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(). Signed-off-by: Maurizio Lombardi --- 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 44eda6081e99..0e719460199f 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -997,8 +997,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.39.3