Skip to content

Commit 86dc8f2

Browse files
isilenceaxboe
authored andcommitted
io_uring/net: improve zc addr import error handling
We may account memory to a memcg of a request that didn't even got to the network layer. It's not a bug as it'll be routinely cleaned up on flush, but it might be confusing for the userspace. Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/b8aae61f4c3ddc4da97c1da876bb73871f352d50.1660566179.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 0636042 commit 86dc8f2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

io_uring/net.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,14 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags)
977977
msg.msg_controllen = 0;
978978
msg.msg_namelen = 0;
979979

980+
if (zc->addr) {
981+
ret = move_addr_to_kernel(zc->addr, zc->addr_len, &address);
982+
if (unlikely(ret < 0))
983+
return ret;
984+
msg.msg_name = (struct sockaddr *)&address;
985+
msg.msg_namelen = zc->addr_len;
986+
}
987+
980988
if (zc->flags & IORING_RECVSEND_FIXED_BUF) {
981989
ret = io_import_fixed(WRITE, &msg.msg_iter, req->imu,
982990
(u64)(uintptr_t)zc->buf, zc->len);
@@ -992,14 +1000,6 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags)
9921000
return ret;
9931001
}
9941002

995-
if (zc->addr) {
996-
ret = move_addr_to_kernel(zc->addr, zc->addr_len, &address);
997-
if (unlikely(ret < 0))
998-
return ret;
999-
msg.msg_name = (struct sockaddr *)&address;
1000-
msg.msg_namelen = zc->addr_len;
1001-
}
1002-
10031003
msg_flags = zc->msg_flags | MSG_ZEROCOPY;
10041004
if (issue_flags & IO_URING_F_NONBLOCK)
10051005
msg_flags |= MSG_DONTWAIT;

0 commit comments

Comments
 (0)