compat: use scoped user access in get_compat_sigevent()
Changes
1 files changed · +12 −8
| File | Status | Add | Del | Content |
|---|---|---|---|---|
| kernel/compat.c | modified | +12 | −8 | View file |
kernel/compat.c
View filediff --git a/kernel/compat.c b/kernel/compat.c
index fb50f29..c754793 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -180,14 +180,18 @@ int get_compat_sigevent(struct sigevent *event,
const struct compat_sigevent __user *u_event)
{
memset(event, 0, sizeof(*event));
- return (!access_ok(u_event, sizeof(*u_event)) ||
- __get_user(event->sigev_value.sival_int,
- &u_event->sigev_value.sival_int) ||
- __get_user(event->sigev_signo, &u_event->sigev_signo) ||
- __get_user(event->sigev_notify, &u_event->sigev_notify) ||
- __get_user(event->sigev_notify_thread_id,
- &u_event->sigev_notify_thread_id))
- ? -EFAULT : 0;
+ scoped_user_read_access(u_event, Efault) {
+ unsafe_get_user(event->sigev_value.sival_int,
+ &u_event->sigev_value.sival_int, Efault);
+ unsafe_get_user(event->sigev_signo, &u_event->sigev_signo, Efault);
+ unsafe_get_user(event->sigev_notify, &u_event->sigev_notify, Efault);
+ unsafe_get_user(event->sigev_notify_thread_id,
+ &u_event->sigev_notify_thread_id, Efault);
+ }
+ return 0;
+
+Efault:
+ return -EFAULT;
}
long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,