This is a note to let you know that I've just added the patch titled cxl/pci: Handle truncated CDAT header to the 6.2-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: cxl-pci-handle-truncated-cdat-header.patch and it can be found in the queue-6.2 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 34bafc747c54fb58c1908ec3116fa6137393e596 Mon Sep 17 00:00:00 2001 From: Lukas Wunner <lukas@xxxxxxxxx> Date: Sat, 11 Mar 2023 15:40:02 +0100 Subject: cxl/pci: Handle truncated CDAT header From: Lukas Wunner <lukas@xxxxxxxxx> commit 34bafc747c54fb58c1908ec3116fa6137393e596 upstream. cxl_cdat_get_length() only checks whether the DOE response size is sufficient for the Table Access response header (1 dword), but not the succeeding CDAT header (1 dword length plus other fields). It thus returns whatever uninitialized memory happens to be on the stack if a truncated DOE response with only 1 dword was received. Fix it. Fixes: c97006046c79 ("cxl/port: Read CDAT table") Reported-by: Ming Li <ming4.li@xxxxxxxxx> Tested-by: Ira Weiny <ira.weiny@xxxxxxxxx> Signed-off-by: Lukas Wunner <lukas@xxxxxxxxx> Reviewed-by: Ming Li <ming4.li@xxxxxxxxx> Reviewed-by: Dan Williams <dan.j.williams@xxxxxxxxx> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> Cc: stable@xxxxxxxxxxxxxxx # v6.0+ Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/000e69cd163461c8b1bc2cf4155b6e25402c29c7.1678543498.git.lukas@xxxxxxxxx Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/cxl/core/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -528,7 +528,7 @@ static int cxl_cdat_get_length(struct de return rc; } wait_for_completion(&t.c); - if (t.task.rv < sizeof(__le32)) + if (t.task.rv < 2 * sizeof(__le32)) return -EIO; *length = le32_to_cpu(t.response_pl[1]); Patches currently in stable-queue which might be from lukas@xxxxxxxxx are queue-6.2/pci-doe-fix-memory-leak-with-config_debug_objects-y.patch queue-6.2/cxl-pci-handle-truncated-cdat-entries.patch queue-6.2/cxl-pci-handle-truncated-cdat-header.patch queue-6.2/cxl-pci-fix-cdat-retrieval-on-big-endian.patch queue-6.2/pci-doe-silence-warn-splat-with-config_debug_objects-y.patch queue-6.2/cxl-pci-handle-excessive-cdat-length.patch