[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240531211211.12628-2-krisman@suse.de>
Date: Fri, 31 May 2024 17:12:07 -0400
From: Gabriel Krisman Bertazi <krisman@...e.de>
To: axboe@...nel.dk
Cc: io-uring@...r.kernel.org,
netdev@...r.kernel.org,
Gabriel Krisman Bertazi <krisman@...e.de>
Subject: [PATCH 1/5] io_uring: Fix leak of async data when connect prep fails
move_addr_to_kernel can fail, like if the user provides a bad sockaddr
pointer. In this case where the failure happens on ->prep() we don't
have a chance to clean the request later, so handle it here.
Signed-off-by: Gabriel Krisman Bertazi <krisman@...e.de>
---
io_uring/net.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/io_uring/net.c b/io_uring/net.c
index 0a48596429d9..c3377e70aeeb 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -1657,6 +1657,7 @@ int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
{
struct io_connect *conn = io_kiocb_to_cmd(req, struct io_connect);
struct io_async_msghdr *io;
+ int ret;
if (sqe->len || sqe->buf_index || sqe->rw_flags || sqe->splice_fd_in)
return -EINVAL;
@@ -1669,7 +1670,10 @@ int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
if (unlikely(!io))
return -ENOMEM;
- return move_addr_to_kernel(conn->addr, conn->addr_len, &io->addr);
+ ret = move_addr_to_kernel(conn->addr, conn->addr_len, &io->addr);
+ if (ret)
+ io_netmsg_recycle(req, 0);
+ return ret;
}
int io_connect(struct io_kiocb *req, unsigned int issue_flags)
--
2.44.0
Powered by blists - more mailing lists