]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
aio: prevent double free in ioctx_alloc
authorSasha Levin <sasha.levin@oracle.com>
Tue, 19 Nov 2013 22:33:02 +0000 (17:33 -0500)
committerBenjamin LaHaise <bcrl@kvack.org>
Tue, 19 Nov 2013 22:40:48 +0000 (17:40 -0500)
ioctx_alloc() calls aio_setup_ring() to allocate a ring. If aio_setup_ring()
fails to do so it would call aio_free_ring() before returning, but
ioctx_alloc() would call aio_free_ring() again causing a double free of
the ring.

This is easily reproducible from userspace.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
fs/aio.c

index ee77dc13d5b22370899ed96e12be13e26a4aaad3..63135331cec27b3801375835165726077f61cc35 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -610,7 +610,6 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
 err_cleanup:
        aio_nr_sub(ctx->max_reqs);
 err:
-       aio_free_ring(ctx);
        free_percpu(ctx->cpu);
        free_percpu(ctx->reqs.pcpu_count);
        free_percpu(ctx->users.pcpu_count);