From: Pavel Begunkov Date: Wed, 26 Feb 2025 11:41:20 +0000 (+0000) Subject: io_uring/net: unify *mshot_prep calls with compat X-Git-Tag: v6.15-rc1~167^2~54 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=51e158d40589f3576c598e67a741d398d1ca2189;p=thirdparty%2Flinux.git 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: Pavel Begunkov Link: https://lore.kernel.org/r/94e62386dec570f83b4a4270a46ac60bc415fb71.1740569495.git.asml.silence@gmail.com Signed-off-by: Jens Axboe --- diff --git a/io_uring/net.c b/io_uring/net.c index 36e218b62319c..efa2d901762f5 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -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); + } - 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,