diff options
author | Helge Deller <deller@gmx.de> | 2013-02-19 14:47:37 -0500 |
---|---|---|
committer | Helge Deller <deller@gmx.de> | 2013-02-20 16:56:50 -0500 |
commit | bf581e15a443fa3569d9def96b512315ba509d6f (patch) | |
tree | 248e7bce3b05c4867d33df9f96d844a78a03e654 /arch/parisc | |
parent | fee707b459da56ba83fbb4ae89151571502ee724 (diff) |
parisc: convert msgrcv and msgsnd syscalls to use compat layer
Switch over to use the existing compat_* implementation for msgrcv() and
msgsnd(). Existing code was even partly buggy since it returned on some paths
different error codes than the standard.
Signed-off-by: Helge Deller <deller@gmx.de>
Diffstat (limited to 'arch/parisc')
-rw-r--r-- | arch/parisc/Kconfig | 4 | ||||
-rw-r--r-- | arch/parisc/include/asm/compat.h | 61 | ||||
-rw-r--r-- | arch/parisc/kernel/sys_parisc32.c | 58 | ||||
-rw-r--r-- | arch/parisc/kernel/syscall_table.S | 4 |
4 files changed, 67 insertions, 60 deletions
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index 3df1c35a217a..af48d26ce287 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig | |||
@@ -272,6 +272,10 @@ config COMPAT | |||
272 | def_bool y | 272 | def_bool y |
273 | depends on 64BIT | 273 | depends on 64BIT |
274 | 274 | ||
275 | config SYSVIPC_COMPAT | ||
276 | def_bool y | ||
277 | depends on COMPAT && SYSVIPC | ||
278 | |||
275 | config HPUX | 279 | config HPUX |
276 | bool "Support for HP-UX binaries" | 280 | bool "Support for HP-UX binaries" |
277 | depends on !64BIT | 281 | depends on !64BIT |
diff --git a/arch/parisc/include/asm/compat.h b/arch/parisc/include/asm/compat.h index db7a662691a8..94710cfc1ce8 100644 --- a/arch/parisc/include/asm/compat.h +++ b/arch/parisc/include/asm/compat.h | |||
@@ -28,6 +28,7 @@ typedef u16 compat_nlink_t; | |||
28 | typedef u16 compat_ipc_pid_t; | 28 | typedef u16 compat_ipc_pid_t; |
29 | typedef s32 compat_daddr_t; | 29 | typedef s32 compat_daddr_t; |
30 | typedef u32 compat_caddr_t; | 30 | typedef u32 compat_caddr_t; |
31 | typedef s32 compat_key_t; | ||
31 | typedef s32 compat_timer_t; | 32 | typedef s32 compat_timer_t; |
32 | 33 | ||
33 | typedef s32 compat_int_t; | 34 | typedef s32 compat_int_t; |
@@ -188,6 +189,66 @@ typedef struct compat_siginfo { | |||
188 | #define COMPAT_OFF_T_MAX 0x7fffffff | 189 | #define COMPAT_OFF_T_MAX 0x7fffffff |
189 | #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL | 190 | #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL |
190 | 191 | ||
192 | struct compat_ipc64_perm { | ||
193 | compat_key_t key; | ||
194 | __compat_uid_t uid; | ||
195 | __compat_gid_t gid; | ||
196 | __compat_uid_t cuid; | ||
197 | __compat_gid_t cgid; | ||
198 | unsigned short int __pad1; | ||
199 | compat_mode_t mode; | ||
200 | unsigned short int __pad2; | ||
201 | unsigned short int seq; | ||
202 | unsigned int __pad3; | ||
203 | unsigned long __unused1; /* yes they really are 64bit pads */ | ||
204 | unsigned long __unused2; | ||
205 | }; | ||
206 | |||
207 | struct compat_semid64_ds { | ||
208 | struct compat_ipc64_perm sem_perm; | ||
209 | compat_time_t sem_otime; | ||
210 | unsigned int __unused1; | ||
211 | compat_time_t sem_ctime; | ||
212 | unsigned int __unused2; | ||
213 | compat_ulong_t sem_nsems; | ||
214 | compat_ulong_t __unused3; | ||
215 | compat_ulong_t __unused4; | ||
216 | }; | ||
217 | |||
218 | struct compat_msqid64_ds { | ||
219 | struct compat_ipc64_perm msg_perm; | ||
220 | unsigned int __unused1; | ||
221 | compat_time_t msg_stime; | ||
222 | unsigned int __unused2; | ||
223 | compat_time_t msg_rtime; | ||
224 | unsigned int __unused3; | ||
225 | compat_time_t msg_ctime; | ||
226 | compat_ulong_t msg_cbytes; | ||
227 | compat_ulong_t msg_qnum; | ||
228 | compat_ulong_t msg_qbytes; | ||
229 | compat_pid_t msg_lspid; | ||
230 | compat_pid_t msg_lrpid; | ||
231 | compat_ulong_t __unused4; | ||
232 | compat_ulong_t __unused5; | ||
233 | }; | ||
234 | |||
235 | struct compat_shmid64_ds { | ||
236 | struct compat_ipc64_perm shm_perm; | ||
237 | unsigned int __unused1; | ||
238 | compat_time_t shm_atime; | ||
239 | unsigned int __unused2; | ||
240 | compat_time_t shm_dtime; | ||
241 | unsigned int __unused3; | ||
242 | compat_time_t shm_ctime; | ||
243 | unsigned int __unused4; | ||
244 | compat_size_t shm_segsz; | ||
245 | compat_pid_t shm_cpid; | ||
246 | compat_pid_t shm_lpid; | ||
247 | compat_ulong_t shm_nattch; | ||
248 | compat_ulong_t __unused5; | ||
249 | compat_ulong_t __unused6; | ||
250 | }; | ||
251 | |||
191 | /* | 252 | /* |
192 | * A pointer passed in from user mode. This should not | 253 | * A pointer passed in from user mode. This should not |
193 | * be used for syscall parameters, just declare them | 254 | * be used for syscall parameters, just declare them |
diff --git a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c index 9cfdaa19ab63..cee60f77fc1f 100644 --- a/arch/parisc/kernel/sys_parisc32.c +++ b/arch/parisc/kernel/sys_parisc32.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/time.h> | 21 | #include <linux/time.h> |
22 | #include <linux/smp.h> | 22 | #include <linux/smp.h> |
23 | #include <linux/sem.h> | 23 | #include <linux/sem.h> |
24 | #include <linux/msg.h> | ||
25 | #include <linux/shm.h> | 24 | #include <linux/shm.h> |
26 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
27 | #include <linux/uio.h> | 26 | #include <linux/uio.h> |
@@ -73,63 +72,6 @@ asmlinkage long sys32_sched_rr_get_interval(pid_t pid, | |||
73 | return ret; | 72 | return ret; |
74 | } | 73 | } |
75 | 74 | ||
76 | struct msgbuf32 { | ||
77 | int mtype; | ||
78 | char mtext[1]; | ||
79 | }; | ||
80 | |||
81 | asmlinkage long sys32_msgsnd(int msqid, | ||
82 | struct msgbuf32 __user *umsgp32, | ||
83 | size_t msgsz, int msgflg) | ||
84 | { | ||
85 | struct msgbuf *mb; | ||
86 | struct msgbuf32 mb32; | ||
87 | int err; | ||
88 | |||
89 | if ((mb = kmalloc(msgsz + sizeof *mb + 4, GFP_KERNEL)) == NULL) | ||
90 | return -ENOMEM; | ||
91 | |||
92 | err = get_user(mb32.mtype, &umsgp32->mtype); | ||
93 | mb->mtype = mb32.mtype; | ||
94 | err |= copy_from_user(mb->mtext, &umsgp32->mtext, msgsz); | ||
95 | |||
96 | if (err) | ||
97 | err = -EFAULT; | ||
98 | else | ||
99 | KERNEL_SYSCALL(err, sys_msgsnd, msqid, (struct msgbuf __user *)mb, msgsz, msgflg); | ||
100 | |||
101 | kfree(mb); | ||
102 | return err; | ||
103 | } | ||
104 | |||
105 | asmlinkage long sys32_msgrcv(int msqid, | ||
106 | struct msgbuf32 __user *umsgp32, | ||
107 | size_t msgsz, long msgtyp, int msgflg) | ||
108 | { | ||
109 | struct msgbuf *mb; | ||
110 | struct msgbuf32 mb32; | ||
111 | int err, len; | ||
112 | |||
113 | if ((mb = kmalloc(msgsz + sizeof *mb + 4, GFP_KERNEL)) == NULL) | ||
114 | return -ENOMEM; | ||
115 | |||
116 | KERNEL_SYSCALL(err, sys_msgrcv, msqid, (struct msgbuf __user *)mb, msgsz, msgtyp, msgflg); | ||
117 | |||
118 | if (err >= 0) { | ||
119 | len = err; | ||
120 | mb32.mtype = mb->mtype; | ||
121 | err = put_user(mb32.mtype, &umsgp32->mtype); | ||
122 | err |= copy_to_user(&umsgp32->mtext, mb->mtext, len); | ||
123 | if (err) | ||
124 | err = -EFAULT; | ||
125 | else | ||
126 | err = len; | ||
127 | } | ||
128 | |||
129 | kfree(mb); | ||
130 | return err; | ||
131 | } | ||
132 | |||
133 | asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count) | 75 | asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count) |
134 | { | 76 | { |
135 | mm_segment_t old_fs = get_fs(); | 77 | mm_segment_t old_fs = get_fs(); |
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S index e5fcd4c605e2..773b4ee1e1d3 100644 --- a/arch/parisc/kernel/syscall_table.S +++ b/arch/parisc/kernel/syscall_table.S | |||
@@ -286,8 +286,8 @@ | |||
286 | ENTRY_SAME(semop) /* 185 */ | 286 | ENTRY_SAME(semop) /* 185 */ |
287 | ENTRY_SAME(semget) | 287 | ENTRY_SAME(semget) |
288 | ENTRY_DIFF(semctl) | 288 | ENTRY_DIFF(semctl) |
289 | ENTRY_DIFF(msgsnd) | 289 | ENTRY_COMP(msgsnd) |
290 | ENTRY_DIFF(msgrcv) | 290 | ENTRY_COMP(msgrcv) |
291 | ENTRY_SAME(msgget) /* 190 */ | 291 | ENTRY_SAME(msgget) /* 190 */ |
292 | ENTRY_SAME(msgctl) | 292 | ENTRY_SAME(msgctl) |
293 | ENTRY_SAME(shmat) | 293 | ENTRY_SAME(shmat) |