linux-stable/drivers/cxl/core
Kwangjin Ko 9bd1891cac cxl/core: Fix initialization of mbox_cmd.size_out in get event
[ Upstream commit f7c52345cc ]

Since mbox_cmd.size_out is overwritten with the actual output size in
the function below, it needs to be initialized every time.

cxl_internal_send_cmd -> __cxl_pci_mbox_send_cmd

Problem scenario:

1) The size_out variable is initially set to the size of the mailbox.
2) Read an event.
   - size_out is set to 160 bytes(header 32B + one event 128B).
   - Two event are created while reading.
3) Read the new *two* events.
   - size_out is still set to 160 bytes.
   - Although the value of out_len is 288 bytes, only 160 bytes are
     copied from the mailbox register to the local variable.
   - record_count is set to 2.
   - Accessing records[1] will result in reading incorrect data.

Fixes: 6ebe28f9ec ("cxl/mem: Read, trace, and clear events on driver load")
Tested-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Kwangjin Ko <kwangjin.ko@sk.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-17 11:19:27 +02:00
..
Makefile cxl/pci: Find and register CXL PMU devices 2023-05-30 11:20:35 -07:00
core.h cxl/memdev: Fix sanitize vs decoder setup locking 2023-11-20 11:59:30 +01:00
hdm.c cxl/hdm: Fix a benign lockdep splat 2024-01-10 17:17:02 +01:00
mbox.c cxl/core: Fix initialization of mbox_cmd.size_out in get event 2024-04-17 11:19:27 +02:00
memdev.c cxl/memdev: Hold region_rwsem during inject and clear poison ops 2024-01-10 17:17:02 +01:00
pci.c cxl/pci: Fix disabling memory if DVSEC CXL Range does not match a CFMWS window 2024-03-01 13:34:59 +01:00
pmem.c cxl/memdev: Formalize endpoint port linkage 2023-06-25 14:31:33 -07:00
pmu.c cxl/pmu: Ensure put_device on pmu devices 2024-01-10 17:16:59 +01:00
port.c cxl/port: Fix missing target list lock 2024-01-25 15:35:55 -08:00
region.c cxl/region: Allow out of order assembly of autodiscovered regions 2024-03-26 18:19:12 -04:00
regs.c cxl/core/regs: Fix usage of map->reg_type in cxl_decode_regblock() before assigned 2024-04-17 11:19:27 +02:00
suspend.c PM: CXL: Disable suspend 2022-04-22 16:09:42 -07:00
trace.c cxl/trace: Add an HPA to cxl_poison trace events 2023-04-23 11:46:13 -07:00
trace.h cxl/trace: Properly initialize cxl_poison region name 2024-04-03 15:28:36 +02:00