From patchwork Tue Nov 7 22:50:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 10047339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D6B636032D for ; Tue, 7 Nov 2017 22:53:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C910C29DDF for ; Tue, 7 Nov 2017 22:53:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC09029E09; Tue, 7 Nov 2017 22:53:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 393D229DD5 for ; Tue, 7 Nov 2017 22:53:18 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B1F6C2035D11E; Tue, 7 Nov 2017 14:49:18 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=vishal.l.verma@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2BF8F2034D837 for ; Tue, 7 Nov 2017 14:49:17 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2017 14:53:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,361,1505804400"; d="scan'208";a="918738654" Received: from omniknight.lm.intel.com ([10.232.112.27]) by FMSMGA003.fm.intel.com with ESMTP; 07 Nov 2017 14:53:15 -0800 From: Vishal Verma To: Subject: [ndctl PATCH] libndctl, nfit: Fix in/out sizes for error injection commands Date: Tue, 7 Nov 2017 15:50:58 -0700 Message-Id: <20171107225058.12805-1-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.9.5 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dariusz.dokupil@intel.com MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP The input/output size bounds being set in the various nd_bus_cmd_new_* helpers for error injection commands were larger than they needed to be, and platforms could reject these. Fix the bounds to be exactly as the spec describes. Cc: Dan Williams Reported-by: Dariusz Dokupil Signed-off-by: Vishal Verma --- ndctl/lib/nfit.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ndctl/lib/nfit.c b/ndctl/lib/nfit.c index fb6af32..6346fd9 100644 --- a/ndctl/lib/nfit.c +++ b/ndctl/lib/nfit.c @@ -164,9 +164,9 @@ struct ndctl_cmd *ndctl_bus_cmd_new_err_inj(struct ndctl_bus *bus) cmd->status = 1; pkg = (struct nd_cmd_pkg *)&cmd->cmd_buf[0]; pkg->nd_command = NFIT_CMD_ARS_INJECT_SET; - pkg->nd_size_in = (2 * sizeof(u64)) + sizeof(u32); - pkg->nd_size_out = cmd_length; - pkg->nd_fw_size = cmd_length; + pkg->nd_size_in = (2 * sizeof(u64)) + sizeof(u8); + pkg->nd_size_out = sizeof(u32); + pkg->nd_fw_size = sizeof(u32); err_inj = (struct nd_cmd_ars_err_inj *)&pkg->nd_payload[0]; cmd->firmware_status = &err_inj->status; @@ -194,8 +194,8 @@ struct ndctl_cmd *ndctl_bus_cmd_new_err_inj_clr(struct ndctl_bus *bus) pkg = (struct nd_cmd_pkg *)&cmd->cmd_buf[0]; pkg->nd_command = NFIT_CMD_ARS_INJECT_CLEAR; pkg->nd_size_in = 2 * sizeof(u64); - pkg->nd_size_out = cmd_length; - pkg->nd_fw_size = cmd_length; + pkg->nd_size_out = sizeof(u32); + pkg->nd_fw_size = sizeof(u32); err_inj_clr = (struct nd_cmd_ars_err_inj_clr *)&pkg->nd_payload[0]; cmd->firmware_status = &err_inj_clr->status; @@ -224,9 +224,9 @@ struct ndctl_cmd *ndctl_bus_cmd_new_err_inj_stat(struct ndctl_bus *bus, cmd->status = 1; pkg = (struct nd_cmd_pkg *)&cmd->cmd_buf[0]; pkg->nd_command = NFIT_CMD_ARS_INJECT_GET; - pkg->nd_size_in = cmd_length; - pkg->nd_size_out = cmd_length + buf_size; - pkg->nd_fw_size = cmd_length + buf_size; + pkg->nd_size_in = 0; + pkg->nd_size_out = (2 * sizeof(u32)) + buf_size; + pkg->nd_fw_size = (2 * sizeof(u32)) + buf_size; err_inj_stat = (struct nd_cmd_ars_err_inj_stat *)&pkg->nd_payload[0]; cmd->firmware_status = &err_inj_stat->status;