Skip to content

Commit

Permalink
io_uring: fix double poll leak on repolling
Browse files Browse the repository at this point in the history
commit c0737fa upstream.

We have re-polling for partial IO, so a request can be polled twice. If
it used two poll entries the first time then on the second
io_arm_poll_handler() it will find the old apoll entry and NULL
kmalloc()'ed second entry, i.e. apoll->double_poll, so leaking it.

Fixes: 10c8733 ("io_uring: allow re-poll if we made progress")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/fee2452494222ecc7f1f88c8fb659baef971414a.1655852245.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Pavel Begunkov authored and Greg Kroah-Hartman committed Jan 24, 2023
1 parent ddaaadf commit c1a279d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions io_uring/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -5751,10 +5751,12 @@ static int io_arm_poll_handler(struct io_kiocb *req)
mask |= POLLOUT | POLLWRNORM;
}

if (req->flags & REQ_F_POLLED)
if (req->flags & REQ_F_POLLED) {
apoll = req->apoll;
else
kfree(apoll->double_poll);
} else {
apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC);
}
if (unlikely(!apoll))
return IO_APOLL_ABORTED;
apoll->double_poll = NULL;
Expand Down

0 comments on commit c1a279d

Please sign in to comment.