hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/arch/arm/kernel/sys_oabi-compat.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * arch/arm/kernel/sys_oabi-compat.c
34 *
....@@ -7,10 +8,6 @@
78 * Author: Nicolas Pitre
89 * Created: Oct 7, 2005
910 * Copyright: MontaVista Software, Inc.
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License version 2 as
13
- * published by the Free Software Foundation.
1411 */
1512
1613 /*
....@@ -251,25 +248,21 @@
251248 __u64 data;
252249 } __attribute__ ((packed,aligned(4)));
253250
251
+#ifdef CONFIG_EPOLL
254252 asmlinkage long sys_oabi_epoll_ctl(int epfd, int op, int fd,
255253 struct oabi_epoll_event __user *event)
256254 {
257255 struct oabi_epoll_event user;
258256 struct epoll_event kernel;
259
- mm_segment_t fs;
260
- long ret;
261257
262
- if (op == EPOLL_CTL_DEL)
263
- return sys_epoll_ctl(epfd, op, fd, NULL);
264
- if (copy_from_user(&user, event, sizeof(user)))
258
+ if (ep_op_has_event(op) &&
259
+ copy_from_user(&user, event, sizeof(user)))
265260 return -EFAULT;
261
+
266262 kernel.events = user.events;
267263 kernel.data = user.data;
268
- fs = get_fs();
269
- set_fs(KERNEL_DS);
270
- ret = sys_epoll_ctl(epfd, op, fd, &kernel);
271
- set_fs(fs);
272
- return ret;
264
+
265
+ return do_epoll_ctl(epfd, op, fd, &kernel, false);
273266 }
274267
275268 asmlinkage long sys_oabi_epoll_wait(int epfd,
....@@ -285,7 +278,7 @@
285278 maxevents > (INT_MAX/sizeof(*kbuf)) ||
286279 maxevents > (INT_MAX/sizeof(*events)))
287280 return -EINVAL;
288
- if (!access_ok(VERIFY_WRITE, events, sizeof(*events) * maxevents))
281
+ if (!access_ok(events, sizeof(*events) * maxevents))
289282 return -EFAULT;
290283 kbuf = kmalloc_array(maxevents, sizeof(*kbuf), GFP_KERNEL);
291284 if (!kbuf)
....@@ -306,6 +299,20 @@
306299 kfree(kbuf);
307300 return err ? -EFAULT : ret;
308301 }
302
+#else
303
+asmlinkage long sys_oabi_epoll_ctl(int epfd, int op, int fd,
304
+ struct oabi_epoll_event __user *event)
305
+{
306
+ return -EINVAL;
307
+}
308
+
309
+asmlinkage long sys_oabi_epoll_wait(int epfd,
310
+ struct oabi_epoll_event __user *events,
311
+ int maxevents, int timeout)
312
+{
313
+ return -EINVAL;
314
+}
315
+#endif
309316
310317 struct oabi_sembuf {
311318 unsigned short sem_num;
....@@ -317,16 +324,16 @@
317324 asmlinkage long sys_oabi_semtimedop(int semid,
318325 struct oabi_sembuf __user *tsops,
319326 unsigned nsops,
320
- const struct timespec __user *timeout)
327
+ const struct old_timespec32 __user *timeout)
321328 {
322329 struct sembuf *sops;
323
- struct timespec local_timeout;
330
+ struct old_timespec32 local_timeout;
324331 long err;
325332 int i;
326333
327334 if (nsops < 1 || nsops > SEMOPM)
328335 return -EINVAL;
329
- if (!access_ok(VERIFY_READ, tsops, sizeof(*tsops) * nsops))
336
+ if (!access_ok(tsops, sizeof(*tsops) * nsops))
330337 return -EFAULT;
331338 sops = kmalloc_array(nsops, sizeof(*sops), GFP_KERNEL);
332339 if (!sops)
....@@ -350,7 +357,7 @@
350357 } else {
351358 mm_segment_t fs = get_fs();
352359 set_fs(KERNEL_DS);
353
- err = sys_semtimedop(semid, sops, nsops, timeout);
360
+ err = sys_semtimedop_time32(semid, sops, nsops, timeout);
354361 set_fs(fs);
355362 }
356363 kfree(sops);
....@@ -375,7 +382,7 @@
375382 return sys_oabi_semtimedop(first,
376383 (struct oabi_sembuf __user *)ptr,
377384 second,
378
- (const struct timespec __user *)fifth);
385
+ (const struct old_timespec32 __user *)fifth);
379386 default:
380387 return sys_ipc(call, first, second, third, ptr, fifth);
381388 }