Skip to content

Commit 4fe2c13

Browse files
l1kdjbw
authored andcommitted
cxl/pci: Handle excessive CDAT length
If the length in the CDAT header is larger than the concatenation of the header and all table entries, then the CDAT exposed to user space contains trailing null bytes. Not every consumer may be able to handle that. Per Postel's robustness principle, "be liberal in what you accept" and silently reduce the cached length to avoid exposing those null bytes. Fixes: c970060 ("cxl/port: Read CDAT table") Tested-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Lukas Wunner <lukas@wunner.de> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: stable@vger.kernel.org # v6.0+ Link: https://lore.kernel.org/r/6d98b3c7da5343172bd3ccabfabbc1f31c079d74.1678543498.git.lukas@wunner.de Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent b56faef commit 4fe2c13

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/cxl/core/pci.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,9 @@ static int cxl_cdat_read_table(struct device *dev,
564564
}
565565
} while (entry_handle != CXL_DOE_TABLE_ACCESS_LAST_ENTRY);
566566

567+
/* Length in CDAT header may exceed concatenation of CDAT entries */
568+
cdat->length -= length;
569+
567570
return 0;
568571
}
569572

0 commit comments

Comments
 (0)