Skip to content

Commit

Permalink
net: fix compat pointer in get_compat_msghdr()
Browse files Browse the repository at this point in the history
A previous change enabled external users to copy the data before
calling __get_compat_msghdr(), but didn't modify get_compat_msghdr() or
__io_compat_recvmsg_copy_hdr() to take that into account. They are both
stil passing in the __user pointer rather than the copied version.

Ensure we pass in the kernel struct, not the pointer to the user data.

Link: https://lore.kernel.org/all/46439555-644d-08a1-7d66-16f8f9a320f0@samsung.com/
Fixes: 1a3e4e94a1b9 ("net: copy from user before calling __get_compat_msghdr")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
axboe committed Jul 25, 2022
1 parent 4890422 commit 4f6a94d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion io_uring/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ static int __io_compat_recvmsg_copy_hdr(struct io_kiocb *req,
if (copy_from_user(&msg, sr->umsg_compat, sizeof(msg)))
return -EFAULT;

ret = __get_compat_msghdr(&iomsg->msg, sr->umsg_compat, &iomsg->uaddr);
ret = __get_compat_msghdr(&iomsg->msg, &msg, &iomsg->uaddr);
if (ret)
return ret;

Expand Down
2 changes: 1 addition & 1 deletion net/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int get_compat_msghdr(struct msghdr *kmsg,
if (copy_from_user(&msg, umsg, sizeof(*umsg)))
return -EFAULT;

err = __get_compat_msghdr(kmsg, umsg, save_addr);
err = __get_compat_msghdr(kmsg, &msg, save_addr);
if (err)
return err;

Expand Down

0 comments on commit 4f6a94d

Please sign in to comment.