diff options
author | 2023-03-11 15:40:04 +0100 | |
---|---|---|
committer | 2023-04-03 16:16:49 -0700 | |
commit | 4fe2c13d59d849be3b45371e3913ec5dc77fc0fb (patch) | |
tree | 50323597540ddc1ac7f92e2047bfcadef83ce3a8 /drivers/cxl | |
parent | cxl/pci: Handle truncated CDAT entries (diff) | |
download | linux-4fe2c13d59d849be3b45371e3913ec5dc77fc0fb.tar.gz linux-4fe2c13d59d849be3b45371e3913ec5dc77fc0fb.tar.bz2 linux-4fe2c13d59d849be3b45371e3913ec5dc77fc0fb.zip |
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: c97006046c79 ("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>
Diffstat (limited to 'drivers/cxl')
-rw-r--r-- | drivers/cxl/core/pci.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index fb600dfbf5a6..523d5b9fd7fc 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -564,6 +564,9 @@ static int cxl_cdat_read_table(struct device *dev, } } while (entry_handle != CXL_DOE_TABLE_ACCESS_LAST_ENTRY); + /* Length in CDAT header may exceed concatenation of CDAT entries */ + cdat->length -= length; + return 0; } |