Skip to content

Commit 34bafc7

Browse files
l1kdjbw
authored andcommitted
cxl/pci: Handle truncated CDAT header
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: c970060 ("cxl/port: Read CDAT table") Reported-by: Ming Li <[email protected]> Tested-by: Ira Weiny <[email protected]> Signed-off-by: Lukas Wunner <[email protected]> Reviewed-by: Ming Li <[email protected]> Reviewed-by: Dan Williams <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Cc: [email protected] # v6.0+ Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]> Link: https://lore.kernel.org/r/000e69cd163461c8b1bc2cf4155b6e25402c29c7.1678543498.git.lukas@wunner.de Signed-off-by: Dan Williams <[email protected]>
1 parent fbaa382 commit 34bafc7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/cxl/core/pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ static int cxl_cdat_get_length(struct device *dev,
510510
return rc;
511511
}
512512
wait_for_completion(&t.c);
513-
if (t.task.rv < sizeof(__le32))
513+
if (t.task.rv < 2 * sizeof(__le32))
514514
return -EIO;
515515

516516
*length = le32_to_cpu(t.response_pl[1]);

0 commit comments

Comments
 (0)