linux/drivers/cxl
Robert Richter 8441c7d3bd cxl: Check for invalid addresses returned from translation functions on errors
Translation functions may return an invalid address in case of errors.
If the address is not checked the further use of the invalid value
will cause an address corruption.

Consistently check for a valid address returned by translation
functions. Use RESOURCE_SIZE_MAX to indicate an invalid address for
type resource_size_t. Depending on the type either RESOURCE_SIZE_MAX
or ULLONG_MAX is used to indicate an address error.

Propagating an invalid address from a failed translation may cause
userspace to think it has received a valid SPA, when in fact it is
wrong. The CXL userspace API, using trace events, expects ULLONG_MAX
to indicate a translation failure. If ULLONG_MAX is not returned
immediately, subsequent calculations can transform that bad address
into a different value (!ULLONG_MAX), and an invalid SPA may be
returned to userspace. This can lead to incorrect diagnostics and
erroneous corrective actions.

[ dj: Added user impact statement from Alison. ]
[ dj: Fixed checkpatch tab alignment issue. ]

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Robert Richter <rrichter@amd.com>
Fixes: c3dd67681c ("cxl/region: Add inject and clear poison by region offset")
Fixes: b78b9e7b79 ("cxl/region: Refactor address translation funcs for testing")
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Link: https://patch.msgid.link/20260107120544.410993-1-rrichter@amd.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
2026-01-13 08:30:40 -07:00
..
core cxl: Check for invalid addresses returned from translation functions on errors 2026-01-13 08:30:40 -07:00
acpi.c cxl/acpi: Restore HBIW check before dereferencing platform_data 2026-01-09 17:12:03 -07:00
cxl.h Merge branch 'for-6.19/cxl-prm' into cxl-for-next 2025-11-14 11:11:46 -07:00
cxlmem.h cxl/core: Add locked variants of the poison inject and clear funcs 2025-08-12 16:02:00 -07:00
cxlpci.h cxl/port: Remove devm_cxl_port_enumerate_dports() 2025-11-03 09:16:02 -07:00
Kconfig cxl/edac: Support for finding memory operation attributes from the current boot 2025-05-23 13:24:38 -07:00
Makefile cxl/port: Fix CXL port initialization order when the subsystem is built-in 2024-10-25 16:06:49 -05:00
mem.c cxl/edac: Add CXL memory device patrol scrub control feature 2025-05-23 13:24:09 -07:00
pci.c cxl/pci: replace use of system_wq with system_percpu_wq 2025-11-03 09:16:03 -07:00
pmem.c cxl/pci: Drop the parameter is_port of cxl_gpf_get_dvsec() 2025-04-09 12:48:18 -07:00
pmu.h cxl/pci: Find and register CXL PMU devices 2023-05-30 11:20:35 -07:00
port.c cxl: Defer dport allocation for switch ports 2025-09-18 09:55:22 -07:00
security.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00