@@ -16,6 +16,7 @@
#include "net.h"
#include "notif.h"
#include "rsrc.h"
+#include "fused_cmd.h"
#if defined(CONFIG_NET)
struct io_shutdown {
@@ -69,6 +70,13 @@ struct io_sr_msg {
struct io_kiocb *notif;
};
+#define user_ptr_to_u64(x) ( \
+{ \
+ typecheck(void __user *, (x)); \
+ (u64)(unsigned long)(x); \
+} \
+)
+
static inline bool io_check_multishot(struct io_kiocb *req,
unsigned int issue_flags)
{
@@ -379,7 +387,11 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags)
if (unlikely(!sock))
return -ENOTSOCK;
- ret = import_ubuf(ITER_SOURCE, sr->buf, sr->len, &msg.msg_iter);
+ if (!io_req_use_fused_buf(req))
+ ret = import_ubuf(ITER_SOURCE, sr->buf, sr->len, &msg.msg_iter);
+ else
+ ret = io_import_buf_from_fused(user_ptr_to_u64(sr->buf),
+ sr->len, ITER_SOURCE, &msg.msg_iter, req);
if (unlikely(ret))
return ret;
@@ -870,7 +882,11 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
sr->buf = buf;
}
- ret = import_ubuf(ITER_DEST, sr->buf, len, &msg.msg_iter);
+ if (!io_req_use_fused_buf(req))
+ ret = import_ubuf(ITER_DEST, sr->buf, len, &msg.msg_iter);
+ else
+ ret = io_import_buf_from_fused(user_ptr_to_u64(sr->buf),
+ sr->len, ITER_DEST, &msg.msg_iter, req);
if (unlikely(ret))
goto out_free;
@@ -984,6 +1000,9 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
if (zc->flags & IORING_RECVSEND_FIXED_BUF) {
unsigned idx = READ_ONCE(sqe->buf_index);
+ if (io_req_use_fused_buf(req))
+ return -EINVAL;
+
if (unlikely(idx >= ctx->nr_user_bufs))
return -EFAULT;
idx = array_index_nospec(idx, ctx->nr_user_bufs);
@@ -1120,8 +1139,15 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
if (unlikely(ret))
return ret;
msg.sg_from_iter = io_sg_from_iter;
+ } else if (io_req_use_fused_buf(req)) {
+ ret = io_import_buf_from_fused(user_ptr_to_u64(zc->buf),
+ zc->len, ITER_SOURCE, &msg.msg_iter, req);
+ if (unlikely(ret))
+ return ret;
+ msg.sg_from_iter = io_sg_from_iter;
} else {
io_notif_set_extended(zc->notif);
+
ret = import_ubuf(ITER_SOURCE, zc->buf, zc->len, &msg.msg_iter);
if (unlikely(ret))
return ret;
@@ -273,6 +273,8 @@ const struct io_issue_def io_issue_defs[] = {
.audit_skip = 1,
.ioprio = 1,
.manual_alloc = 1,
+ .fused_secondary = 1,
+ .buf_dir = READ,
#if defined(CONFIG_NET)
.prep = io_sendmsg_prep,
.issue = io_send,
@@ -287,6 +289,8 @@ const struct io_issue_def io_issue_defs[] = {
.buffer_select = 1,
.audit_skip = 1,
.ioprio = 1,
+ .fused_secondary = 1,
+ .buf_dir = WRITE,
#if defined(CONFIG_NET)
.prep = io_recvmsg_prep,
.issue = io_recv,
@@ -413,6 +417,8 @@ const struct io_issue_def io_issue_defs[] = {
.audit_skip = 1,
.ioprio = 1,
.manual_alloc = 1,
+ .fused_secondary = 1,
+ .buf_dir = READ,
#if defined(CONFIG_NET)
.prep = io_send_zc_prep,
.issue = io_send_zc,