* [PATCH] cxl/mbox: Fix missing variable payload checks in cmd size validation
@ 2022-06-28 20:04 Vishal Verma
2022-06-28 21:42 ` Alison Schofield
2022-06-28 21:49 ` Dan Williams
0 siblings, 2 replies; 5+ messages in thread
From: Vishal Verma @ 2022-06-28 20:04 UTC (permalink / raw)
To: linux-cxl
Cc: Vishal Verma, Abhi Cs, stable, Ira Weiny, Dan Williams, Alison Schofield
The conversion of command sizes to unsigned missed a couple of checks
against variable size payloads during command validation, which made all
variable payload commands unconditionally fail. Add the checks back using
the new CXL_VARIABLE_PAYLOAD scheme.
Reported-by: Abhi Cs <abhi.cs@intel.com>
Fixes: 26f89535a5bb ("cxl/mbox: Use type __u32 for mailbox payload sizes")
Cc: <stable@vger.kernel.org>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Alison Schofield <alison.schofield@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
drivers/cxl/core/mbox.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
index 40e3ccb2bf3e..d929b89d12a7 100644
--- a/drivers/cxl/core/mbox.c
+++ b/drivers/cxl/core/mbox.c
@@ -355,12 +355,14 @@ static int cxl_to_mem_cmd(struct cxl_mem_command *mem_cmd,
return -EBUSY;
/* Check the input buffer is the expected size */
- if (info->size_in != send_cmd->in.size)
- return -ENOMEM;
+ if (info->size_in != CXL_VARIABLE_PAYLOAD)
+ if (info->size_in != send_cmd->in.size)
+ return -ENOMEM;
/* Check the output buffer is at least large enough */
- if (send_cmd->out.size < info->size_out)
- return -ENOMEM;
+ if (info->size_out != CXL_VARIABLE_PAYLOAD)
+ if (send_cmd->out.size < info->size_out)
+ return -ENOMEM;
*mem_cmd = (struct cxl_mem_command) {
.info = {
base-commit: 1985cf58850562e4b960e19d46f0d8f19d6c7cbd
--
2.36.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] cxl/mbox: Fix missing variable payload checks in cmd size validation
2022-06-28 20:04 [PATCH] cxl/mbox: Fix missing variable payload checks in cmd size validation Vishal Verma
@ 2022-06-28 21:42 ` Alison Schofield
2022-06-28 21:46 ` Verma, Vishal L
2022-06-28 21:49 ` Dan Williams
1 sibling, 1 reply; 5+ messages in thread
From: Alison Schofield @ 2022-06-28 21:42 UTC (permalink / raw)
To: Verma, Vishal L; +Cc: linux-cxl, Cs, Abhi, stable, Weiny, Ira, Williams, Dan J
On Tue, Jun 28, 2022 at 01:04:27PM -0700, Vishal Verma wrote:
> The conversion of command sizes to unsigned missed a couple of checks
> against variable size payloads during command validation, which made all
> variable payload commands unconditionally fail. Add the checks back using
> the new CXL_VARIABLE_PAYLOAD scheme.
>
> Reported-by: Abhi Cs <abhi.cs@intel.com>
> Fixes: 26f89535a5bb ("cxl/mbox: Use type __u32 for mailbox payload sizes")
> Cc: <stable@vger.kernel.org>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Alison Schofield <alison.schofield@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
with one caveat below...
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
> ---
> drivers/cxl/core/mbox.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> index 40e3ccb2bf3e..d929b89d12a7 100644
> --- a/drivers/cxl/core/mbox.c
> +++ b/drivers/cxl/core/mbox.c
> @@ -355,12 +355,14 @@ static int cxl_to_mem_cmd(struct cxl_mem_command *mem_cmd,
> return -EBUSY;
>
> /* Check the input buffer is the expected size */
> - if (info->size_in != send_cmd->in.size)
> - return -ENOMEM;
> + if (info->size_in != CXL_VARIABLE_PAYLOAD)
> + if (info->size_in != send_cmd->in.size)
> + return -ENOMEM;
We can leave it to Dan to arbitrate, but I don't think nested
if's without brackets follow kernel coding style.
However, Dan didn't like my nested if's with brackets either.
He'd prefer using &&
>
> /* Check the output buffer is at least large enough */
> - if (send_cmd->out.size < info->size_out)
> - return -ENOMEM;
> + if (info->size_out != CXL_VARIABLE_PAYLOAD)
> + if (send_cmd->out.size < info->size_out)
> + return -ENOMEM;
>
> *mem_cmd = (struct cxl_mem_command) {
> .info = {
>
> base-commit: 1985cf58850562e4b960e19d46f0d8f19d6c7cbd
> --
> 2.36.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cxl/mbox: Fix missing variable payload checks in cmd size validation
2022-06-28 21:42 ` Alison Schofield
@ 2022-06-28 21:46 ` Verma, Vishal L
2022-06-28 21:52 ` Dan Williams
0 siblings, 1 reply; 5+ messages in thread
From: Verma, Vishal L @ 2022-06-28 21:46 UTC (permalink / raw)
To: Schofield, Alison
Cc: Williams, Dan J, linux-cxl, stable, Cs, Abhi, Weiny, Ira
On Tue, 2022-06-28 at 14:42 -0700, Alison Schofield wrote:
> On Tue, Jun 28, 2022 at 01:04:27PM -0700, Vishal Verma wrote:
> > The conversion of command sizes to unsigned missed a couple of
> > checks
> > against variable size payloads during command validation, which
> > made all
> > variable payload commands unconditionally fail. Add the checks back
> > using
> > the new CXL_VARIABLE_PAYLOAD scheme.
> >
> > Reported-by: Abhi Cs <abhi.cs@intel.com>
> > Fixes: 26f89535a5bb ("cxl/mbox: Use type __u32 for mailbox payload
> > sizes")
> > Cc: <stable@vger.kernel.org>
> > Cc: Ira Weiny <ira.weiny@intel.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Cc: Alison Schofield <alison.schofield@intel.com>
> > Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
>
> with one caveat below...
> Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Thanks for the review!
> > ---
> > drivers/cxl/core/mbox.c | 10 ++++++----
> > 1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> > index 40e3ccb2bf3e..d929b89d12a7 100644
> > --- a/drivers/cxl/core/mbox.c
> > +++ b/drivers/cxl/core/mbox.c
> > @@ -355,12 +355,14 @@ static int cxl_to_mem_cmd(struct
> > cxl_mem_command *mem_cmd,
> > return -EBUSY;
> >
> > /* Check the input buffer is the expected size */
> > - if (info->size_in != send_cmd->in.size)
> > - return -ENOMEM;
> > + if (info->size_in != CXL_VARIABLE_PAYLOAD)
> > + if (info->size_in != send_cmd->in.size)
> > + return -ENOMEM;
>
> We can leave it to Dan to arbitrate, but I don't think nested
> if's without brackets follow kernel coding style.
>
> However, Dan didn't like my nested if's with brackets either.
> He'd prefer using &&
Ha funny - I had && originally, but then I spotted nested if () a few
lines above in the same file in cxl_mbox_send_cmd(), and switched to
the same style :)
I'd be happy to change to &&.
>
> >
> > /* Check the output buffer is at least large enough */
> > - if (send_cmd->out.size < info->size_out)
> > - return -ENOMEM;
> > + if (info->size_out != CXL_VARIABLE_PAYLOAD)
> > + if (send_cmd->out.size < info->size_out)
> > + return -ENOMEM;
> >
> > *mem_cmd = (struct cxl_mem_command) {
> > .info = {
> >
> > base-commit: 1985cf58850562e4b960e19d46f0d8f19d6c7cbd
> > --
> > 2.36.1
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] cxl/mbox: Fix missing variable payload checks in cmd size validation
2022-06-28 20:04 [PATCH] cxl/mbox: Fix missing variable payload checks in cmd size validation Vishal Verma
2022-06-28 21:42 ` Alison Schofield
@ 2022-06-28 21:49 ` Dan Williams
1 sibling, 0 replies; 5+ messages in thread
From: Dan Williams @ 2022-06-28 21:49 UTC (permalink / raw)
To: Vishal Verma, linux-cxl
Cc: Vishal Verma, Abhi Cs, stable, Ira Weiny, Dan Williams, Alison Schofield
Vishal Verma wrote:
> The conversion of command sizes to unsigned missed a couple of checks
> against variable size payloads during command validation, which made all
> variable payload commands unconditionally fail. Add the checks back using
> the new CXL_VARIABLE_PAYLOAD scheme.
Ah, looks good. Need to get label read/write regression test into
cxl-cli post-haste.
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cxl/mbox: Fix missing variable payload checks in cmd size validation
2022-06-28 21:46 ` Verma, Vishal L
@ 2022-06-28 21:52 ` Dan Williams
0 siblings, 0 replies; 5+ messages in thread
From: Dan Williams @ 2022-06-28 21:52 UTC (permalink / raw)
To: Verma, Vishal L, Schofield, Alison
Cc: Williams, Dan J, linux-cxl, stable, Cs, Abhi, Weiny, Ira
Verma, Vishal L wrote:
> On Tue, 2022-06-28 at 14:42 -0700, Alison Schofield wrote:
> > On Tue, Jun 28, 2022 at 01:04:27PM -0700, Vishal Verma wrote:
> > > The conversion of command sizes to unsigned missed a couple of
> > > checks
> > > against variable size payloads during command validation, which
> > > made all
> > > variable payload commands unconditionally fail. Add the checks back
> > > using
> > > the new CXL_VARIABLE_PAYLOAD scheme.
> > >
> > > Reported-by: Abhi Cs <abhi.cs@intel.com>
> > > Fixes: 26f89535a5bb ("cxl/mbox: Use type __u32 for mailbox payload
> > > sizes")
> > > Cc: <stable@vger.kernel.org>
> > > Cc: Ira Weiny <ira.weiny@intel.com>
> > > Cc: Dan Williams <dan.j.williams@intel.com>
> > > Cc: Alison Schofield <alison.schofield@intel.com>
> > > Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> >
> > with one caveat below...
> > Reviewed-by: Alison Schofield <alison.schofield@intel.com>
>
> Thanks for the review!
>
>
> > > ---
> > > drivers/cxl/core/mbox.c | 10 ++++++----
> > > 1 file changed, 6 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> > > index 40e3ccb2bf3e..d929b89d12a7 100644
> > > --- a/drivers/cxl/core/mbox.c
> > > +++ b/drivers/cxl/core/mbox.c
> > > @@ -355,12 +355,14 @@ static int cxl_to_mem_cmd(struct
> > > cxl_mem_command *mem_cmd,
> > > return -EBUSY;
> > >
> > > /* Check the input buffer is the expected size */
> > > - if (info->size_in != send_cmd->in.size)
> > > - return -ENOMEM;
> > > + if (info->size_in != CXL_VARIABLE_PAYLOAD)
> > > + if (info->size_in != send_cmd->in.size)
> > > + return -ENOMEM;
> >
> > We can leave it to Dan to arbitrate, but I don't think nested
> > if's without brackets follow kernel coding style.
> >
> > However, Dan didn't like my nested if's with brackets either.
> > He'd prefer using &&
>
> Ha funny - I had && originally, but then I spotted nested if () a few
> lines above in the same file in cxl_mbox_send_cmd(), and switched to
> the same style :)
>
> I'd be happy to change to &&.
Yeah, lets go that route.
/me thanks Alison for catching it.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-06-28 21:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-28 20:04 [PATCH] cxl/mbox: Fix missing variable payload checks in cmd size validation Vishal Verma
2022-06-28 21:42 ` Alison Schofield
2022-06-28 21:46 ` Verma, Vishal L
2022-06-28 21:52 ` Dan Williams
2022-06-28 21:49 ` Dan Williams
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.