PCI/P2PDMA: Fix undefined behavior bug in struct pci_p2pdma_pagemap
Struct dev_pagemap is a flexible structure, which means that it contains a flexible-array member. If dev_pagemap.nr_range > 1, the memory following the dev_pagemap could be overwritten. This is currently not an issue because pci_p2pdma_pagemap is not exposed outside p2pdma.c, and p2pdma.c only sets dev_pagemap.nr_range to 1. To prevent problems if p2pdma.c ever uses nr_range > 1, move the flexible struct dev_pagemap to the end of struct pci_p2pdma_pagemap. -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting ready to enable it globally. Link: https://lore.kernel.org/r/ZRsUL/hATNruwtla@work Signed-off-by:"Gustavo A. R. Silva" <gustavoars@kernel.org> [bhelgaas: commit log] Signed-off-by:
Bjorn Helgaas <bhelgaas@google.com> Reviewed-by:
Logan Gunthorpe <logang@deltatee.com>
Loading
Please register or sign in to comment