msgrcv(2), msgsnd(2): move compat to native

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 9b1404c2 20bc2a3a

+43 -47
-8
include/linux/msg.h
··· 31 31 struct list_head q_senders; 32 32 }; 33 33 34 - /* Helper routines for sys_msgsnd and sys_msgrcv */ 35 - extern long do_msgsnd(int msqid, long mtype, void __user *mtext, 36 - size_t msgsz, int msgflg); 37 - extern long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, 38 - int msgflg, 39 - long (*msg_fill)(void __user *, struct msg_msg *, 40 - size_t)); 41 - 42 34 #endif /* _LINUX_MSG_H */
-37
ipc/compat.c
··· 34 34 35 35 #include "util.h" 36 36 37 - struct compat_msgbuf { 38 - compat_long_t mtype; 39 - char mtext[1]; 40 - }; 41 - 42 37 int get_compat_ipc64_perm(struct ipc64_perm *to, 43 38 struct compat_ipc64_perm __user *from) 44 39 { ··· 78 83 SET_GID(to->cgid, from->cgid); 79 84 to->mode = from->mode; 80 85 to->seq = from->seq; 81 - } 82 - 83 - static long compat_do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz) 84 - { 85 - struct compat_msgbuf __user *msgp = dest; 86 - size_t msgsz; 87 - 88 - if (put_user(msg->m_type, &msgp->mtype)) 89 - return -EFAULT; 90 - 91 - msgsz = (bufsz > msg->m_ts) ? msg->m_ts : bufsz; 92 - if (store_msg(msgp->mtext, msg, msgsz)) 93 - return -EFAULT; 94 - return msgsz; 95 - } 96 - 97 - COMPAT_SYSCALL_DEFINE4(msgsnd, int, msqid, compat_uptr_t, msgp, 98 - compat_ssize_t, msgsz, int, msgflg) 99 - { 100 - struct compat_msgbuf __user *up = compat_ptr(msgp); 101 - compat_long_t mtype; 102 - 103 - if (get_user(mtype, &up->mtype)) 104 - return -EFAULT; 105 - return do_msgsnd(msqid, mtype, up->mtext, (ssize_t)msgsz, msgflg); 106 - } 107 - 108 - COMPAT_SYSCALL_DEFINE5(msgrcv, int, msqid, compat_uptr_t, msgp, 109 - compat_ssize_t, msgsz, compat_long_t, msgtyp, int, msgflg) 110 - { 111 - return do_msgrcv(msqid, compat_ptr(msgp), (ssize_t)msgsz, (long)msgtyp, 112 - msgflg, compat_do_msg_fill); 113 86 } 114 87 115 88 #ifndef COMPAT_SHMLBA
+43 -2
ipc/msg.c
··· 730 730 return 0; 731 731 } 732 732 733 - long do_msgsnd(int msqid, long mtype, void __user *mtext, 733 + static long do_msgsnd(int msqid, long mtype, void __user *mtext, 734 734 size_t msgsz, int msgflg) 735 735 { 736 736 struct msg_queue *msq; ··· 853 853 return do_msgsnd(msqid, mtype, msgp->mtext, msgsz, msgflg); 854 854 } 855 855 856 + #ifdef CONFIG_COMPAT 857 + 858 + struct compat_msgbuf { 859 + compat_long_t mtype; 860 + char mtext[1]; 861 + }; 862 + 863 + COMPAT_SYSCALL_DEFINE4(msgsnd, int, msqid, compat_uptr_t, msgp, 864 + compat_ssize_t, msgsz, int, msgflg) 865 + { 866 + struct compat_msgbuf __user *up = compat_ptr(msgp); 867 + compat_long_t mtype; 868 + 869 + if (get_user(mtype, &up->mtype)) 870 + return -EFAULT; 871 + return do_msgsnd(msqid, mtype, up->mtext, (ssize_t)msgsz, msgflg); 872 + } 873 + #endif 874 + 856 875 static inline int convert_mode(long *msgtyp, int msgflg) 857 876 { 858 877 if (msgflg & MSG_COPY) ··· 968 949 return found ?: ERR_PTR(-EAGAIN); 969 950 } 970 951 971 - long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, int msgflg, 952 + static long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, int msgflg, 972 953 long (*msg_handler)(void __user *, struct msg_msg *, size_t)) 973 954 { 974 955 int mode; ··· 1132 1113 return do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg, do_msg_fill); 1133 1114 } 1134 1115 1116 + #ifdef CONFIG_COMPAT 1117 + static long compat_do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz) 1118 + { 1119 + struct compat_msgbuf __user *msgp = dest; 1120 + size_t msgsz; 1121 + 1122 + if (put_user(msg->m_type, &msgp->mtype)) 1123 + return -EFAULT; 1124 + 1125 + msgsz = (bufsz > msg->m_ts) ? msg->m_ts : bufsz; 1126 + if (store_msg(msgp->mtext, msg, msgsz)) 1127 + return -EFAULT; 1128 + return msgsz; 1129 + } 1130 + 1131 + COMPAT_SYSCALL_DEFINE5(msgrcv, int, msqid, compat_uptr_t, msgp, 1132 + compat_ssize_t, msgsz, compat_long_t, msgtyp, int, msgflg) 1133 + { 1134 + return do_msgrcv(msqid, compat_ptr(msgp), (ssize_t)msgsz, (long)msgtyp, 1135 + msgflg, compat_do_msg_fill); 1136 + } 1137 + #endif 1135 1138 1136 1139 void msg_init_ns(struct ipc_namespace *ns) 1137 1140 {