Skip to content

Commit 6b3d1f9

Browse files
isilencegregkh
authored andcommitted
UPSTREAM: io_uring: fix double poll leak on repolling
commit c0737fa9a5a5cf5a053bcc983f72d58919b997c6 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: 10c873334feba ("io_uring: allow re-poll if we made progress") Change-Id: Ibab2f08e9f8d1e4ae25f0666dfe70e982a29a0a5 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> (cherry picked from commit 124fb13) Bug: 268174392 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
1 parent 3749f8d commit 6b3d1f9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

io_uring/io_uring.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5896,10 +5896,12 @@ static int io_arm_poll_handler(struct io_kiocb *req)
58965896
mask |= POLLOUT | POLLWRNORM;
58975897
}
58985898

5899-
if (req->flags & REQ_F_POLLED)
5899+
if (req->flags & REQ_F_POLLED) {
59005900
apoll = req->apoll;
5901-
else
5901+
kfree(apoll->double_poll);
5902+
} else {
59025903
apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC);
5904+
}
59035905
if (unlikely(!apoll))
59045906
return IO_APOLL_ABORTED;
59055907
apoll->double_poll = NULL;

0 commit comments

Comments
 (0)