summaryrefslogtreecommitdiff
path: root/drivers/dax/device.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-06-26 15:27:08 +0300
committerJason Gunthorpe <jgg@mellanox.com>2019-07-02 20:32:44 +0300
commit1e240e8d4a7d92232b6214e02a0a4197a53afd6c (patch)
tree79627ced555b058e23eedd971352ee51918e5dcd /drivers/dax/device.c
parent3ed2dcdf54d5bf1f9823b5faf1a702e7cee53982 (diff)
downloadlinux-1e240e8d4a7d92232b6214e02a0a4197a53afd6c.tar.xz
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>
Diffstat (limited to 'drivers/dax/device.c')
-rw-r--r--drivers/dax/device.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/dax/device.c b/drivers/dax/device.c
index 79014baa782d..f390083a64d7 100644
--- a/drivers/dax/device.c
+++ b/drivers/dax/device.c
@@ -36,9 +36,8 @@ static void dev_dax_percpu_exit(struct percpu_ref *ref)
percpu_ref_exit(ref);
}
-static void dev_dax_percpu_kill(struct percpu_ref *data)
+static void dev_dax_percpu_kill(struct percpu_ref *ref)
{
- struct percpu_ref *ref = data;
struct dev_dax *dev_dax = ref_to_dev_dax(ref);
dev_dbg(&dev_dax->dev, "%s\n", __func__);
@@ -442,6 +441,11 @@ static void dev_dax_kill(void *dev_dax)
kill_dev_dax(dev_dax);
}
+static const struct dev_pagemap_ops dev_dax_pagemap_ops = {
+ .kill = dev_dax_percpu_kill,
+ .cleanup = dev_dax_percpu_exit,
+};
+
int dev_dax_probe(struct device *dev)
{
struct dev_dax *dev_dax = to_dev_dax(dev);
@@ -466,9 +470,8 @@ int dev_dax_probe(struct device *dev)
return rc;
dev_dax->pgmap.ref = &dev_dax->ref;
- dev_dax->pgmap.kill = dev_dax_percpu_kill;
- dev_dax->pgmap.cleanup = dev_dax_percpu_exit;
dev_dax->pgmap.type = MEMORY_DEVICE_DEVDAX;
+ dev_dax->pgmap.ops = &dev_dax_pagemap_ops;
addr = devm_memremap_pages(dev, &dev_dax->pgmap);
if (IS_ERR(addr))
return PTR_ERR(addr);