diff options
| author | David S. Miller <davem@davemloft.net> | 2020-05-11 16:59:16 -0700 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2020-05-11 16:59:16 -0700 |
| commit | 97cf0ef9305bba857f04b914fd59e83813f1eae2 (patch) | |
| tree | 1f8ca24224e9aa0dbaf924bec224deb08d1ab505 /include/linux | |
| parent | 3242956bd610af40e884b530b6c6f76f5bf85f3b (diff) | |
| parent | 1f466e1f15cf1dac7c86798d694649fc42cd868a (diff) | |
Merge branch 'improve-msg_control-kernel-vs-user-pointer-handling'
Christoph Hellwig says:
====================
improve msg_control kernel vs user pointer handling
this series replace the msg_control in the kernel msghdr structure
with an anonymous union and separate fields for kernel vs user
pointers. In addition to helping a bit with type safety and reducing
sparse warnings, this also allows to remove the set_fs() in
kernel_recvmsg, helping with an eventual entire removal of set_fs().
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/socket.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/include/linux/socket.h b/include/linux/socket.h index 54338fac45cb..04d2bc97f497 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -50,7 +50,17 @@ struct msghdr { void *msg_name; /* ptr to socket address structure */ int msg_namelen; /* size of socket address structure */ struct iov_iter msg_iter; /* data */ - void *msg_control; /* ancillary data */ + + /* + * Ancillary data. msg_control_user is the user buffer used for the + * recv* side when msg_control_is_user is set, msg_control is the kernel + * buffer used for all other cases. + */ + union { + void *msg_control; + void __user *msg_control_user; + }; + bool msg_control_is_user : 1; __kernel_size_t msg_controllen; /* ancillary data buffer length */ unsigned int msg_flags; /* flags on received message */ struct kiocb *msg_iocb; /* ptr to iocb for async requests */ @@ -94,7 +104,10 @@ struct cmsghdr { #define CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) ) -#define CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + sizeof(struct cmsghdr))) +#define CMSG_DATA(cmsg) \ + ((void *)(cmsg) + sizeof(struct cmsghdr)) +#define CMSG_USER_DATA(cmsg) \ + ((void __user *)(cmsg) + sizeof(struct cmsghdr)) #define CMSG_SPACE(len) (sizeof(struct cmsghdr) + CMSG_ALIGN(len)) #define CMSG_LEN(len) (sizeof(struct cmsghdr) + (len)) |
