From patchwork Wed Nov 8 18:48:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10048969 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 B6AF56032D for ; Wed, 8 Nov 2017 18:48:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACE742A738 for ; Wed, 8 Nov 2017 18:48:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1CEB2A74A; Wed, 8 Nov 2017 18:48:12 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no 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 475DB2A738 for ; Wed, 8 Nov 2017 18:48:11 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A98402034D814; Wed, 8 Nov 2017 10:44:10 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Permerror (SPF Permanent Error: Void lookup limit of 2 exceeded) identity=mailfrom; client-ip=2607:f8b0:4003:c06::243; helo=mail-oi0-x243.google.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mail-oi0-x243.google.com (mail-oi0-x243.google.com [IPv6:2607:f8b0:4003:c06::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A7F2C2034AB1E for ; Wed, 8 Nov 2017 10:44:09 -0800 (PST) Received: by mail-oi0-x243.google.com with SMTP id y206so1399849oiy.4 for ; Wed, 08 Nov 2017 10:48:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=9rpcfcRQYlXaIzDNFsyiArEWvhEy3BeoqxvtutFurcg=; b=bdhnpRRc9DuIIJdIny8eDqitYAg+lGaRQSkKSeh53VEIls6rpbvwH6oO3ln6sIdAId MK8p4g3Spnat8KFpBiAwW1RnnDXjRrgXVnFIFpuXgcx7Wl7KhvqeaLatJBDMYRo4FkRY seyD0c28tl/0eM3QGUNkUaPhL+2t77mjhtG4Xt3eJQCNEHMRQFYkjoHYqOhbMEiyylnj qhi4Iot2ZmdxZ8rPsNSduTpAWnzcpcaTm3VRIUhfyrnKf3M6x7lpk1ni5+G219wK7jku iWAZCYCeQYPmTu8oZGez8cRmFZMRz4ydPRp+qntBNEomLQh/VJaJMKXEdiP9EOMvwhrT 0uFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=9rpcfcRQYlXaIzDNFsyiArEWvhEy3BeoqxvtutFurcg=; b=YDX+ab4Sy+jrZS6yMQxBHQTGkYHS6hZB8PlrfG3VLNX15bFr7hVXk3T1OY1cACbZ7r PfJEYM0pihlA0wR2KJuUoxgQwUFgTwhXIhT7HrOAff7j+lq5Daau59905aL5aG7Hkyhc 2feRQJySyJgnFQyeBvATF7V06wMBFTFvxH/2l9Ehgk3G11LXvYB8jUQJ8Xs5AKFqdJ7e XO1G2MWjOKmbtQAp4P9YIgWw22Nwg4bpVa7MBTBk8r7Gmr1TeRzYVZHS381A/alSLtrF oSb0SApWAo55qhC/O90GZWhv2w7DPykwtuQZ0Rh2ao0oKMarEu1hpqc7sBjKHkHg0u+j 0skQ== X-Gm-Message-State: AJaThX4H4vhLGE/Uqdwd+PH4sN1BbicvjG1LR1lZAS6+K+SwfOeuqBc8 4DbjQqaBmfph6opZco3Y5jMYdhIWOSC2eUC84i1p+g== X-Google-Smtp-Source: ABhQp+TTGKLmTXKgLNwDD/iEgdCspcEIkChcgpwFPkO1ZtWGklDDtDwaikBcgCrzvQVwqUSntvxrfxCLnNxpPGIPBMo= X-Received: by 10.202.75.205 with SMTP id y196mr928074oia.141.1510166889773; Wed, 08 Nov 2017 10:48:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.24.2 with HTTP; Wed, 8 Nov 2017 10:48:09 -0800 (PST) In-Reply-To: References: <20171107225058.12805-1-vishal.l.verma@intel.com> From: Dan Williams Date: Wed, 8 Nov 2017 10:48:09 -0800 Message-ID: Subject: Re: [ndctl PATCH] libndctl, nfit: Fix in/out sizes for error injection commands To: Vishal Verma 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: "Dokupil, Dariusz" , "linux-nvdimm@lists.01.org" Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP On Wed, Nov 8, 2017 at 10:07 AM, Dan Williams wrote: > On Tue, Nov 7, 2017 at 2:50 PM, Vishal Verma wrote: >> 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); > > How about: > > pkg->nd_size_in = offset_of(struct nd_cmd_ars_err_inj, status); Actually, something like this to make the pkg-> settings and inter-relations clearer: diff --git a/ndctl/lib/nfit.c b/ndctl/lib/nfit.c index 6346fd90f0e2..21c567ad5d4a 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(u8); - pkg->nd_size_out = sizeof(u32); - pkg->nd_fw_size = sizeof(u32); + pkg->nd_size_in = offsetof(struct nd_cmd_ars_err_inj, status); + pkg->nd_size_out = sizeof(struct nd_cmd_ars_err_inj) - pkg->nd_size_in; + pkg->nd_fw_size = pkg->nd_size_out; err_inj = (struct nd_cmd_ars_err_inj *)&pkg->nd_payload[0]; cmd->firmware_status = &err_inj->status;