Commit 51e158d4 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe
Browse files

io_uring/net: unify *mshot_prep calls with compat



Instead of duplicating a io_recvmsg_mshot_prep() call in the compat
path, let the common code handle it. For that, copy necessary compat
fields into struct user_msghdr. Note, it zeroes user_msghdr to be on the
safe side as compat is not that interesting and overhead shouldn't be
high.

Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/94e62386dec570f83b4a4270a46ac60bc415fb71.1740569495.git.asml.silence@gmail.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 0c623f48
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -714,20 +714,20 @@ static int io_recvmsg_copy_hdr(struct io_kiocb *req,
	iomsg->msg.msg_name = &iomsg->addr;
	iomsg->msg.msg_iter.nr_segs = 0;

#ifdef CONFIG_COMPAT
	if (io_is_compat(req->ctx)) {
#ifdef CONFIG_COMPAT
		struct compat_msghdr cmsg;

		ret = io_compat_msg_copy_hdr(req, iomsg, &cmsg, ITER_DEST,
					     &iomsg->uaddr);
		if (unlikely(ret))
			return ret;
		return io_recvmsg_mshot_prep(req, iomsg, cmsg.msg_namelen,
						cmsg.msg_controllen);
	}
		memset(&msg, 0, sizeof(msg));
		msg.msg_namelen = cmsg.msg_namelen;
		msg.msg_controllen = cmsg.msg_controllen;
#endif

	} else {
		ret = io_msg_copy_hdr(req, iomsg, &msg, ITER_DEST, &iomsg->uaddr);
	}

	if (unlikely(ret))
		return ret;
	return io_recvmsg_mshot_prep(req, iomsg, msg.msg_namelen,