Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cxl/mbox: Fix missing variable payload checks in cmd size validation

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.

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>
Reported-by: Abhi Cs <abhi.cs@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Link: https://lore.kernel.org/r/20220628220109.633564-1-vishal.l.verma@intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

authored by

Vishal Verma and committed by
Dan Williams
e35f5718 f50974ee

+4 -2
+4 -2
drivers/cxl/core/mbox.c
··· 355 355 return -EBUSY; 356 356 357 357 /* Check the input buffer is the expected size */ 358 - if (info->size_in != send_cmd->in.size) 358 + if ((info->size_in != CXL_VARIABLE_PAYLOAD) && 359 + (info->size_in != send_cmd->in.size)) 359 360 return -ENOMEM; 360 361 361 362 /* Check the output buffer is at least large enough */ 362 - if (send_cmd->out.size < info->size_out) 363 + if ((info->size_out != CXL_VARIABLE_PAYLOAD) && 364 + (send_cmd->out.size < info->size_out)) 363 365 return -ENOMEM; 364 366 365 367 *mem_cmd = (struct cxl_mem_command) {