All of lore.kernel.org
 help / color / mirror / Atom feed
* [ndctl PATCH] libndctl, nfit: Fix in/out sizes for error injection commands
@ 2017-11-07 22:50 Vishal Verma
  2017-11-08 18:07 ` Dan Williams
  0 siblings, 1 reply; 4+ messages in thread
From: Vishal Verma @ 2017-11-07 22:50 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: dariusz.dokupil

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 <dan.j.williams@intel.com>
Reported-by: Dariusz Dokupil <dariusz.dokupil@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 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;
 
-- 
2.9.5

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [ndctl PATCH] libndctl, nfit: Fix in/out sizes for error injection commands
  2017-11-07 22:50 [ndctl PATCH] libndctl, nfit: Fix in/out sizes for error injection commands Vishal Verma
@ 2017-11-08 18:07 ` Dan Williams
  2017-11-08 18:48   ` Dan Williams
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Williams @ 2017-11-08 18:07 UTC (permalink / raw)
  To: Vishal Verma; +Cc: Dokupil, Dariusz, linux-nvdimm@lists.01.org

On Tue, Nov 7, 2017 at 2:50 PM, Vishal Verma <vishal.l.verma@intel.com> 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 <dan.j.williams@intel.com>
> Reported-by: Dariusz Dokupil <dariusz.dokupil@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> ---
>  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);
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ndctl PATCH] libndctl, nfit: Fix in/out sizes for error injection commands
  2017-11-08 18:07 ` Dan Williams
@ 2017-11-08 18:48   ` Dan Williams
  2017-11-08 19:09     ` Verma, Vishal L
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Williams @ 2017-11-08 18:48 UTC (permalink / raw)
  To: Vishal Verma; +Cc: Dokupil, Dariusz, linux-nvdimm@lists.01.org

On Wed, Nov 8, 2017 at 10:07 AM, Dan Williams <dan.j.williams@intel.com> wrote:
> On Tue, Nov 7, 2017 at 2:50 PM, Vishal Verma <vishal.l.verma@intel.com> 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 <dan.j.williams@intel.com>
>> Reported-by: Dariusz Dokupil <dariusz.dokupil@intel.com>
>> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
>> ---
>>  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;
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [ndctl PATCH] libndctl, nfit: Fix in/out sizes for error injection commands
  2017-11-08 18:48   ` Dan Williams
@ 2017-11-08 19:09     ` Verma, Vishal L
  0 siblings, 0 replies; 4+ messages in thread
From: Verma, Vishal L @ 2017-11-08 19:09 UTC (permalink / raw)
  To: Williams, Dan J; +Cc: Dokupil, Dariusz, linux-nvdimm@lists.01.org

On Wed, 2017-11-08 at 10:48 -0800, Dan Williams wrote:
> On Wed, Nov 8, 2017 at 10:07 AM, Dan Williams <dan.j.williams@intel.c
> om> wrote:
> > On Tue, Nov 7, 2017 at 2:50 PM, Vishal Verma <vishal.l.verma@intel.
> > com> 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 <dan.j.williams@intel.com>
> > > Reported-by: Dariusz Dokupil <dariusz.dokupil@intel.com>
> > > Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> > > ---
> > >  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;

Yep, I like that. I will resend.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-08 19:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-07 22:50 [ndctl PATCH] libndctl, nfit: Fix in/out sizes for error injection commands Vishal Verma
2017-11-08 18:07 ` Dan Williams
2017-11-08 18:48   ` Dan Williams
2017-11-08 19:09     ` Verma, Vishal L

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.