[lkml]   [2011]   [Jun]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    SubjectRe: [PATCH] mm: dmapool: fix possible use after free in dmam_pool_destroy()
    On Thu, Jun 2, 2011 at 12:47 PM, Rolf Eike Beer <> wrote:
    > Maxin B John wrote:
    >> "dma_pool_destroy(pool)" calls "kfree(pool)". The freed pointer
    >> "pool" is again passed as an argument to the function "devres_destroy()".
    >> This patch fixes the possible use after free.
    > The pool itself is not used there, only the address where the pool
    > has been.This will only lead to any trouble if something else is allocated to
    > the same place and inserted into the devres list of the same device between
    > the dma_pool_destroy() and devres_destroy().

    Thank you very much for explaining it in detail.

    > But I agree that this is bad style. But if you are going to change
    > this please also have a look at devm_iounmap() in lib/devres.c. Maybe also the
    > devm_*irq* functions need the same changes.

    As per your suggestion, I have made similar modifications for lib/devres.c and

    CCed the maintainers of the respective files.

    Signed-off-by: Maxin B. John <>
    diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c
    index 1ef4ffc..bd8e788 100644
    --- a/kernel/irq/devres.c
    +++ b/kernel/irq/devres.c
    @@ -87,8 +87,8 @@ void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id)
    struct irq_devres match_data = { irq, dev_id };

    - free_irq(irq, dev_id);
    WARN_ON(devres_destroy(dev, devm_irq_release, devm_irq_match,
    + free_irq(irq, dev_id);
    diff --git a/lib/devres.c b/lib/devres.c
    index 6efddf5..7c0e953 100644
    --- a/lib/devres.c
    +++ b/lib/devres.c
    @@ -79,9 +79,9 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
    void devm_iounmap(struct device *dev, void __iomem *addr)
    - iounmap(addr);
    WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
    (void *)addr));
    + iounmap(addr);

     \ /
      Last update: 2011-06-02 16:25    [W:0.025 / U:3.892 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site