io_uring: refactor compat_msghdr import

Add an entry for user pointer to compat_msghdr into io_connect, so it's
explicit that we may use it as this, and removes annoying casts.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/73fd644dea1518f528d3648981cf777ce6e537e9.1618101759.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Pavel Begunkov 2021-04-11 01:46:30 +01:00 коммит произвёл Jens Axboe
Родитель 0bdf3398b0
Коммит 4af3417a34
1 изменённых файлов: 5 добавлений и 6 удалений

Просмотреть файл

@ -570,8 +570,9 @@ struct io_connect {
struct io_sr_msg { struct io_sr_msg {
struct file *file; struct file *file;
union { union {
struct user_msghdr __user *umsg; struct compat_msghdr __user *umsg_compat;
void __user *buf; struct user_msghdr __user *umsg;
void __user *buf;
}; };
int msg_flags; int msg_flags;
int bgid; int bgid;
@ -4435,16 +4436,14 @@ static int __io_recvmsg_copy_hdr(struct io_kiocb *req,
static int __io_compat_recvmsg_copy_hdr(struct io_kiocb *req, static int __io_compat_recvmsg_copy_hdr(struct io_kiocb *req,
struct io_async_msghdr *iomsg) struct io_async_msghdr *iomsg)
{ {
struct compat_msghdr __user *msg_compat;
struct io_sr_msg *sr = &req->sr_msg; struct io_sr_msg *sr = &req->sr_msg;
struct compat_iovec __user *uiov; struct compat_iovec __user *uiov;
compat_uptr_t ptr; compat_uptr_t ptr;
compat_size_t len; compat_size_t len;
int ret; int ret;
msg_compat = (struct compat_msghdr __user *) sr->umsg; ret = __get_compat_msghdr(&iomsg->msg, sr->umsg_compat, &iomsg->uaddr,
ret = __get_compat_msghdr(&iomsg->msg, msg_compat, &iomsg->uaddr, &ptr, &len);
&ptr, &len);
if (ret) if (ret)
return ret; return ret;