^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef NET_COMPAT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define NET_COMPAT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) struct sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #if defined(CONFIG_COMPAT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/compat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct compat_msghdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) compat_uptr_t msg_name; /* void * */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) compat_int_t msg_namelen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) compat_uptr_t msg_iov; /* struct compat_iovec * */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) compat_size_t msg_iovlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) compat_uptr_t msg_control; /* void * */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) compat_size_t msg_controllen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) compat_uint_t msg_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct compat_mmsghdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct compat_msghdr msg_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) compat_uint_t msg_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct compat_cmsghdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) compat_size_t cmsg_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) compat_int_t cmsg_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) compat_int_t cmsg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct compat_rtentry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) u32 rt_pad1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct sockaddr rt_dst; /* target address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct sockaddr rt_genmask; /* target network mask (IP) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) unsigned short rt_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) short rt_pad2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) u32 rt_pad3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) unsigned char rt_tos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) unsigned char rt_class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) short rt_pad4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) short rt_metric; /* +1 for binary compatibility! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) compat_uptr_t rt_dev; /* forcing the device at add */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) u32 rt_mtu; /* per route MTU/Window */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) u32 rt_window; /* Window clamping */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) unsigned short rt_irtt; /* Initial RTT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #else /* defined(CONFIG_COMPAT) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * To avoid compiler warnings:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define compat_msghdr msghdr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define compat_mmsghdr mmsghdr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #endif /* defined(CONFIG_COMPAT) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) int __get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct sockaddr __user **save_addr, compat_uptr_t *ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) compat_size_t *len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) int get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct sockaddr __user **, struct iovec **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) int put_cmsg_compat(struct msghdr*, int, int, int, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) int cmsghdr_from_user_compat_to_kern(struct msghdr *, struct sock *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) unsigned char *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct compat_group_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) __u32 gr_interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct __kernel_sockaddr_storage gr_group
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) __aligned(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct compat_group_source_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) __u32 gsr_interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct __kernel_sockaddr_storage gsr_group
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) __aligned(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct __kernel_sockaddr_storage gsr_source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) __aligned(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct compat_group_filter {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) __u32 gf_interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct __kernel_sockaddr_storage gf_group
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) __aligned(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) __u32 gf_fmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) __u32 gf_numsrc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) struct __kernel_sockaddr_storage gf_slist[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) __aligned(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #endif /* NET_COMPAT_H */