Skip to content

Commit

Permalink
skbuff: carry external ubuf_info in msghdr
Browse files Browse the repository at this point in the history
Make possible for network in-kernel callers like io_uring to pass in a
custom ubuf_info by setting it in a new field of struct msghdr.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Pavel Begunkov authored and Jakub Kicinski committed Jul 19, 2022
1 parent 2e07a52 commit 7c701d9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct msghdr {
unsigned int msg_flags; /* flags on received message */
__kernel_size_t msg_controllen; /* ancillary data buffer length */
struct kiocb *msg_iocb; /* ptr to iocb for async requests */
struct ubuf_info *msg_ubuf;
};

struct user_msghdr {
Expand Down
1 change: 1 addition & 0 deletions net/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ int __get_compat_msghdr(struct msghdr *kmsg,
return -EMSGSIZE;

kmsg->msg_iocb = NULL;
kmsg->msg_ubuf = NULL;
*ptr = msg.msg_iov;
*len = msg.msg_iovlen;
return 0;
Expand Down
2 changes: 2 additions & 0 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -2106,6 +2106,7 @@ int __sys_sendto(int fd, void __user *buff, size_t len, unsigned int flags,
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_namelen = 0;
msg.msg_ubuf = NULL;
if (addr) {
err = move_addr_to_kernel(addr, addr_len, &address);
if (err < 0)
Expand Down Expand Up @@ -2405,6 +2406,7 @@ int __copy_msghdr_from_user(struct msghdr *kmsg,
return -EMSGSIZE;

kmsg->msg_iocb = NULL;
kmsg->msg_ubuf = NULL;
*uiov = msg.msg_iov;
*nsegs = msg.msg_iovlen;
return 0;
Expand Down

0 comments on commit 7c701d9

Please sign in to comment.