time: make adjtime compat handling available for 32 bit
We want to reuse the compat_timex handling on 32-bit architectures the same way we are using the compat handling for timespec when moving to 64-bit time_t. Move all definitions related to compat_timex out of the compat code into the normal timekeeping code, along with a rename to old_timex32, corresponding to the timespec/timeval structures, and make it controlled by CONFIG_COMPAT_32BIT_TIME, which 32-bit architectures will then select. Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
@@ -278,20 +278,82 @@ SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)
|
||||
return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
#ifdef CONFIG_COMPAT_32BIT_TIME
|
||||
int get_old_timex32(struct timex *txc, const struct old_timex32 __user *utp)
|
||||
{
|
||||
struct old_timex32 tx32;
|
||||
|
||||
COMPAT_SYSCALL_DEFINE1(adjtimex, struct compat_timex __user *, utp)
|
||||
memset(txc, 0, sizeof(struct timex));
|
||||
if (copy_from_user(&tx32, utp, sizeof(struct old_timex32)))
|
||||
return -EFAULT;
|
||||
|
||||
txc->modes = tx32.modes;
|
||||
txc->offset = tx32.offset;
|
||||
txc->freq = tx32.freq;
|
||||
txc->maxerror = tx32.maxerror;
|
||||
txc->esterror = tx32.esterror;
|
||||
txc->status = tx32.status;
|
||||
txc->constant = tx32.constant;
|
||||
txc->precision = tx32.precision;
|
||||
txc->tolerance = tx32.tolerance;
|
||||
txc->time.tv_sec = tx32.time.tv_sec;
|
||||
txc->time.tv_usec = tx32.time.tv_usec;
|
||||
txc->tick = tx32.tick;
|
||||
txc->ppsfreq = tx32.ppsfreq;
|
||||
txc->jitter = tx32.jitter;
|
||||
txc->shift = tx32.shift;
|
||||
txc->stabil = tx32.stabil;
|
||||
txc->jitcnt = tx32.jitcnt;
|
||||
txc->calcnt = tx32.calcnt;
|
||||
txc->errcnt = tx32.errcnt;
|
||||
txc->stbcnt = tx32.stbcnt;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int put_old_timex32(struct old_timex32 __user *utp, const struct timex *txc)
|
||||
{
|
||||
struct old_timex32 tx32;
|
||||
|
||||
memset(&tx32, 0, sizeof(struct old_timex32));
|
||||
tx32.modes = txc->modes;
|
||||
tx32.offset = txc->offset;
|
||||
tx32.freq = txc->freq;
|
||||
tx32.maxerror = txc->maxerror;
|
||||
tx32.esterror = txc->esterror;
|
||||
tx32.status = txc->status;
|
||||
tx32.constant = txc->constant;
|
||||
tx32.precision = txc->precision;
|
||||
tx32.tolerance = txc->tolerance;
|
||||
tx32.time.tv_sec = txc->time.tv_sec;
|
||||
tx32.time.tv_usec = txc->time.tv_usec;
|
||||
tx32.tick = txc->tick;
|
||||
tx32.ppsfreq = txc->ppsfreq;
|
||||
tx32.jitter = txc->jitter;
|
||||
tx32.shift = txc->shift;
|
||||
tx32.stabil = txc->stabil;
|
||||
tx32.jitcnt = txc->jitcnt;
|
||||
tx32.calcnt = txc->calcnt;
|
||||
tx32.errcnt = txc->errcnt;
|
||||
tx32.stbcnt = txc->stbcnt;
|
||||
tx32.tai = txc->tai;
|
||||
if (copy_to_user(utp, &tx32, sizeof(struct old_timex32)))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
COMPAT_SYSCALL_DEFINE1(adjtimex, struct old_timex32 __user *, utp)
|
||||
{
|
||||
struct timex txc;
|
||||
int err, ret;
|
||||
|
||||
err = compat_get_timex(&txc, utp);
|
||||
err = get_old_timex32(&txc, utp);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
ret = do_adjtimex(&txc);
|
||||
|
||||
err = compat_put_timex(utp, &txc);
|
||||
err = put_old_timex32(utp, &txc);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
Reference in New Issue
Block a user