projects/linux·commit 4ebf8d76

Merge tag 'io_uring-5.8-2020-07-17' of git://git.kernel.dk/linux-block into master

4ebf8d76 · Linus Torvalds <[email protected]> · 2020-07-17 10:47:51 -07:00

Pull io_uring fix from Jens Axboe:
 "Fix for a case where, with automatic buffer selection, we can leak the
  buffer descriptor for recvmsg"

* tag 'io_uring-5.8-2020-07-17' of git://git.kernel.dk/linux-block:
  io_uring: fix recvmsg memory leak with buffer selection
Commit
4ebf8d7649cd86c41c41bf48da4b7761da2d5009
Parents
c9ea87dc · 681fda8d

Merge commit. Changes below are compared with the first parent: c9ea87dc.

Changes

1 files changed · +8 −2

FileStatusAddDelContent
fs/io_uring.cmodified+8−2View file

fs/io_uring.c

View file
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 9fd7e69..74bc4a0 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3845,10 +3845,16 @@ static int io_recvmsg(struct io_kiocb *req, bool force_nonblock)
ret = __sys_recvmsg_sock(sock, &kmsg->msg, req->sr_msg.msg,
kmsg->uaddr, flags);
- if (force_nonblock && ret == -EAGAIN)
- return io_setup_async_msg(req, kmsg);
+ if (force_nonblock && ret == -EAGAIN) {
+ ret = io_setup_async_msg(req, kmsg);
+ if (ret != -EAGAIN)
+ kfree(kbuf);
+ return ret;
+ }
if (ret == -ERESTARTSYS)
ret = -EINTR;
+ if (kbuf)
+ kfree(kbuf);
}
if (kmsg && kmsg->iov != kmsg->fast_iov)