Skip to content

Commit

Permalink
time: Enable get/put_compat_itimerspec64 always
Browse files Browse the repository at this point in the history
This will aid in enabling the compat syscalls on 32-bit architectures later
on.

Also move compat_itimerspec and related defines to compat_time.h.  The
compat_time.h file will eventually be deleted.

Signed-off-by: Deepa Dinamani <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
deepa-hub authored and KAGA-KOKO committed Jun 24, 2018
1 parent d0dd63a commit afef05c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 38 deletions.
9 changes: 0 additions & 9 deletions include/linux/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ typedef compat_ulong_t compat_aio_context_t;
struct compat_sel_arg_struct;
struct rusage;

struct compat_itimerspec {
struct compat_timespec it_interval;
struct compat_timespec it_value;
};

struct compat_utimbuf {
compat_time_t actime;
compat_time_t modtime;
Expand Down Expand Up @@ -294,10 +289,6 @@ extern int compat_get_timespec(struct timespec *, const void __user *);
extern int compat_put_timespec(const struct timespec *, void __user *);
extern int compat_get_timeval(struct timeval *, const void __user *);
extern int compat_put_timeval(const struct timeval *, void __user *);
extern int get_compat_itimerspec64(struct itimerspec64 *its,
const struct compat_itimerspec __user *uits);
extern int put_compat_itimerspec64(const struct itimerspec64 *its,
struct compat_itimerspec __user *uits);

struct compat_iovec {
compat_uptr_t iov_base;
Expand Down
9 changes: 9 additions & 0 deletions include/linux/compat_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ struct compat_timeval {
s32 tv_usec;
};

struct compat_itimerspec {
struct compat_timespec it_interval;
struct compat_timespec it_value;
};

extern int compat_get_timespec64(struct timespec64 *, const void __user *);
extern int compat_put_timespec64(const struct timespec64 *, void __user *);
extern int get_compat_itimerspec64(struct itimerspec64 *its,
const struct compat_itimerspec __user *uits);
extern int put_compat_itimerspec64(const struct itimerspec64 *its,
struct compat_itimerspec __user *uits);

#endif /* _LINUX_COMPAT_TIME_H */
29 changes: 0 additions & 29 deletions kernel/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,35 +324,6 @@ COMPAT_SYSCALL_DEFINE3(sched_getaffinity, compat_pid_t, pid, unsigned int, len,
return ret;
}

/* Todo: Delete these extern declarations when get/put_compat_itimerspec64()
* are moved to kernel/time/time.c .
*/
extern int __compat_get_timespec64(struct timespec64 *ts64,
const struct compat_timespec __user *cts);
extern int __compat_put_timespec64(const struct timespec64 *ts64,
struct compat_timespec __user *cts);

int get_compat_itimerspec64(struct itimerspec64 *its,
const struct compat_itimerspec __user *uits)
{

if (__compat_get_timespec64(&its->it_interval, &uits->it_interval) ||
__compat_get_timespec64(&its->it_value, &uits->it_value))
return -EFAULT;
return 0;
}
EXPORT_SYMBOL_GPL(get_compat_itimerspec64);

int put_compat_itimerspec64(const struct itimerspec64 *its,
struct compat_itimerspec __user *uits)
{
if (__compat_put_timespec64(&its->it_interval, &uits->it_interval) ||
__compat_put_timespec64(&its->it_value, &uits->it_value))
return -EFAULT;
return 0;
}
EXPORT_SYMBOL_GPL(put_compat_itimerspec64);

/*
* We currently only need the following fields from the sigevent
* structure: sigev_value, sigev_signo, sig_notify and (sometimes
Expand Down
21 changes: 21 additions & 0 deletions kernel/time/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -955,3 +955,24 @@ int put_itimerspec64(const struct itimerspec64 *it,
return ret;
}
EXPORT_SYMBOL_GPL(put_itimerspec64);

int get_compat_itimerspec64(struct itimerspec64 *its,
const struct compat_itimerspec __user *uits)
{

if (__compat_get_timespec64(&its->it_interval, &uits->it_interval) ||
__compat_get_timespec64(&its->it_value, &uits->it_value))
return -EFAULT;
return 0;
}
EXPORT_SYMBOL_GPL(get_compat_itimerspec64);

int put_compat_itimerspec64(const struct itimerspec64 *its,
struct compat_itimerspec __user *uits)
{
if (__compat_put_timespec64(&its->it_interval, &uits->it_interval) ||
__compat_put_timespec64(&its->it_value, &uits->it_value))
return -EFAULT;
return 0;
}
EXPORT_SYMBOL_GPL(put_compat_itimerspec64);

0 comments on commit afef05c

Please sign in to comment.