Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2250122ybd; Mon, 24 Jun 2019 03:18:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqx86HS2XfKFaVK1SrN5yMIlJO8KQXKKRKo8u/lCygMyMishxC964CHuL4O443kFNk/wMiQN X-Received: by 2002:a65:6495:: with SMTP id e21mr31550000pgv.383.1561371489108; Mon, 24 Jun 2019 03:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561371489; cv=none; d=google.com; s=arc-20160816; b=OuDeFyZM3158FzYYxYcAaXFDmxAt4Fd01ZHCti+46Hf6RNqBYWeo81mCrCDskSzXtW cDOCdw5t6zaNJM9lBZMeIQBwuIQi4NhYnS2cMZCyYeMnrXQr3KniqEIRJ1olfhgd3cnn SBPk/S0EOwDtH73bFM0l0KeYRvJ4nc50PcKfxQxwsoKcobBwkJTpqqhVmL1KGkQboDoA nUBp8Q/z1I5FQXwdk3RXaK+ge9eo+j3ahZ8xDI5YRIpX4F+K4/f8Au0hIZsR6xUQNB33 3Zz3woOm8dnzlE89UEG4Bi2ajuafhK0aNocDUt6BbHoTdZa5lFmQkpJnnuAttAt/EhpL Y77Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MKkUytCe69gQ+g07P5H1Y+96NgVrYhjBkhsEdjHPjT0=; b=H3Ot2DiHlNhyyXV27ERY5Y/4+q8YtaZD9pvMmxuec8ZsgQX7ecbJvp6RBCgD0SXv4z hImlda5WWY7kEkbNQBqxYUFu6bseq1gvkOFTSAJAXAvwDI9sDqPyt6Z6zDxtMT1Ymlyk vhbvmnWjmG6VvxbkrNDdQM6I5PJiSXLsmSVT9mN9N8fr2WLqxk78LqwECB6p/lOYVbUR nVba7+ACpkP/nbSSLihT3hMqi/izB6aEBJ0rRNISKpKe/gikZLvdeXmhQz/rG1P2qv/i yqWJWr6ViJ6vXUTogLEnwNjy0cAjRDiTwKU46/rLBceWCVUVsUB8V1huwIi/Ax1yOfoC 5eCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TibkNip2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x10si11336280pfj.93.2019.06.24.03.17.53; Mon, 24 Jun 2019 03:18:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TibkNip2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730910AbfFXKRM (ORCPT + 99 others); Mon, 24 Jun 2019 06:17:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:54784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730892AbfFXKRK (ORCPT ); Mon, 24 Jun 2019 06:17:10 -0400 Received: from localhost (f4.8f.5177.ip4.static.sl-reverse.com [119.81.143.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A39DE208E3; Mon, 24 Jun 2019 10:17:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561371430; bh=+KfCsSf9cYDwN4DOPUvD9G5PeFr0B/VpnI23mCJ6rCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TibkNip2Gqab86yhOPYctryX60N4azhWXvm5b6P4U4ywISFY1qiQWv0zM5s2c0ly7 JSySHoZw2XnGknG4iY2hrpMi3Hn7kK8k57OrvbP3VTq6F1vFwXPXWtNDtppsIeqH4L RvXrTKWEQoYOS4OLWKRXHOWPhGqsXYfULli12+tA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Minwoo Im , Chaitanya Kulkarni , Sasha Levin Subject: [PATCH 5.1 073/121] nvmet: fix data_len to 0 for bdev-backed write_zeroes Date: Mon, 24 Jun 2019 17:56:45 +0800 Message-Id: <20190624092324.637277726@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624092320.652599624@linuxfoundation.org> References: <20190624092320.652599624@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 3562f5d9f21e7779ae442a45197fed6cb247fd22 ] The WRITE ZEROES command has no data transfer so that we need to initialize the struct (nvmet_req *req)->data_len to 0x0. While (nvmet_req *req)->transfer_len is initialized in nvmet_req_init(), data_len will be initialized by nowhere which might cause the failure with status code NVME_SC_SGL_INVALID_DATA | NVME_SC_DNR randomly. It's because nvmet_req_execute() checks like: if (unlikely(req->data_len != req->transfer_len)) { req->error_loc = offsetof(struct nvme_common_command, dptr); nvmet_req_complete(req, NVME_SC_SGL_INVALID_DATA | NVME_SC_DNR); } else req->execute(req); This patch fixes req->data_len not to be a randomly assigned by initializing it to 0x0 when preparing the command in nvmet_bdev_parse_io_cmd(). nvmet_file_parse_io_cmd() which is for file-backed I/O has already initialized the data_len field to 0x0, though. Cc: Christoph Hellwig Cc: Sagi Grimberg Cc: Chaitanya Kulkarni Signed-off-by: Minwoo Im Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig Signed-off-by: Sagi Grimberg Signed-off-by: Sasha Levin --- drivers/nvme/target/io-cmd-bdev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c index a065dbfc43b1..a77fd8674ecf 100644 --- a/drivers/nvme/target/io-cmd-bdev.c +++ b/drivers/nvme/target/io-cmd-bdev.c @@ -295,6 +295,7 @@ u16 nvmet_bdev_parse_io_cmd(struct nvmet_req *req) return 0; case nvme_cmd_write_zeroes: req->execute = nvmet_bdev_execute_write_zeroes; + req->data_len = 0; return 0; default: pr_err("unhandled cmd %d on qid %d\n", cmd->common.opcode, -- 2.20.1