All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vishal Verma <vishal.l.verma@intel.com>
To: <linux-cxl@vger.kernel.org>
Cc: Vishal Verma <vishal.l.verma@intel.com>,
	Abhi Cs <abhi.cs@intel.com>,
	stable@vger.kernel.org, Ira Weiny <ira.weiny@intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Alison Schofield <alison.schofield@intel.com>
Subject: [PATCH] cxl/mbox: Fix missing variable payload checks in cmd size validation
Date: Tue, 28 Jun 2022 14:04:27 -0600	[thread overview]
Message-ID: <20220628200427.601714-1-vishal.l.verma@intel.com> (raw)

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


             reply	other threads:[~2022-06-28 20:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28 20:04 Vishal Verma [this message]
2022-06-28 21:42 ` [PATCH] cxl/mbox: Fix missing variable payload checks in cmd size validation Alison Schofield
2022-06-28 21:46   ` Verma, Vishal L
2022-06-28 21:52     ` Dan Williams
2022-06-28 21:49 ` Dan Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220628200427.601714-1-vishal.l.verma@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=abhi.cs@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.