memremap: move dev_pagemap callbacks into a separate structure
The dev_pagemap is a growing too many callbacks. Move them into a separate ops structure so that they are not duplicated for multiple instances, and an attacker can't easily overwrite them. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Logan Gunthorpe <logang@deltatee.com> Reviewed-by: Jason Gunthorpe <jgg@mellanox.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Tested-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:

committed by
Jason Gunthorpe

parent
3ed2dcdf54
commit
1e240e8d4a
@@ -153,6 +153,11 @@ out:
|
||||
return error;
|
||||
}
|
||||
|
||||
static const struct dev_pagemap_ops pci_p2pdma_pagemap_ops = {
|
||||
.kill = pci_p2pdma_percpu_kill,
|
||||
.cleanup = pci_p2pdma_percpu_cleanup,
|
||||
};
|
||||
|
||||
/**
|
||||
* pci_p2pdma_add_resource - add memory for use as p2p memory
|
||||
* @pdev: the device to add the memory to
|
||||
@@ -208,8 +213,7 @@ int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size,
|
||||
pgmap->type = MEMORY_DEVICE_PCI_P2PDMA;
|
||||
pgmap->pci_p2pdma_bus_offset = pci_bus_address(pdev, bar) -
|
||||
pci_resource_start(pdev, bar);
|
||||
pgmap->kill = pci_p2pdma_percpu_kill;
|
||||
pgmap->cleanup = pci_p2pdma_percpu_cleanup;
|
||||
pgmap->ops = &pci_p2pdma_pagemap_ops;
|
||||
|
||||
addr = devm_memremap_pages(&pdev->dev, pgmap);
|
||||
if (IS_ERR(addr)) {
|
||||
|
Reference in New Issue
Block a user