Skip to content

Commit 251ec1c

Browse files
committed
y2038: sparc: remove use of struct timex
'struct timex' is one of the last users of 'struct timeval' and is only referenced in one place in the kernel any more, to convert the user space timex into the kernel-internal version on sparc64, with a different tv_usec member type. As a preparation for hiding the time_t definition and everything using that in the kernel, change the implementation once more to only convert the timeval member, and then enclose the struct definition in an #ifdef. Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 4f9fbd8 commit 251ec1c

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

arch/sparc/kernel/sys_sparc_64.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -548,34 +548,35 @@ SYSCALL_DEFINE2(getdomainname, char __user *, name, int, len)
548548
return err;
549549
}
550550

551-
SYSCALL_DEFINE1(sparc_adjtimex, struct timex __user *, txc_p)
551+
SYSCALL_DEFINE1(sparc_adjtimex, struct __kernel_timex __user *, txc_p)
552552
{
553-
struct timex txc; /* Local copy of parameter */
554-
struct __kernel_timex *kt = (void *)&txc;
553+
struct __kernel_timex txc;
554+
struct __kernel_old_timeval *tv = (void *)&txc_p->time;
555555
int ret;
556556

557557
/* Copy the user data space into the kernel copy
558558
* structure. But bear in mind that the structures
559559
* may change
560560
*/
561-
if (copy_from_user(&txc, txc_p, sizeof(struct timex)))
561+
if (copy_from_user(&txc, txc_p, sizeof(txc)))
562562
return -EFAULT;
563563

564564
/*
565565
* override for sparc64 specific timeval type: tv_usec
566566
* is 32 bit wide instead of 64-bit in __kernel_timex
567567
*/
568-
kt->time.tv_usec = txc.time.tv_usec;
569-
ret = do_adjtimex(kt);
570-
txc.time.tv_usec = kt->time.tv_usec;
568+
txc.time.tv_usec = tv->tv_usec;
569+
ret = do_adjtimex(&txc);
570+
tv->tv_usec = txc.time.tv_usec;
571571

572-
return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret;
572+
return copy_to_user(txc_p, &txc, sizeof(txc)) ? -EFAULT : ret;
573573
}
574574

575-
SYSCALL_DEFINE2(sparc_clock_adjtime, const clockid_t, which_clock,struct timex __user *, txc_p)
575+
SYSCALL_DEFINE2(sparc_clock_adjtime, const clockid_t, which_clock,
576+
struct __kernel_timex __user *, txc_p)
576577
{
577-
struct timex txc; /* Local copy of parameter */
578-
struct __kernel_timex *kt = (void *)&txc;
578+
struct __kernel_timex txc;
579+
struct __kernel_old_timeval *tv = (void *)&txc_p->time;
579580
int ret;
580581

581582
if (!IS_ENABLED(CONFIG_POSIX_TIMERS)) {
@@ -590,18 +591,18 @@ SYSCALL_DEFINE2(sparc_clock_adjtime, const clockid_t, which_clock,struct timex _
590591
* structure. But bear in mind that the structures
591592
* may change
592593
*/
593-
if (copy_from_user(&txc, txc_p, sizeof(struct timex)))
594+
if (copy_from_user(&txc, txc_p, sizeof(txc)))
594595
return -EFAULT;
595596

596597
/*
597598
* override for sparc64 specific timeval type: tv_usec
598599
* is 32 bit wide instead of 64-bit in __kernel_timex
599600
*/
600-
kt->time.tv_usec = txc.time.tv_usec;
601-
ret = do_clock_adjtime(which_clock, kt);
602-
txc.time.tv_usec = kt->time.tv_usec;
601+
txc.time.tv_usec = tv->tv_usec;
602+
ret = do_clock_adjtime(which_clock, &txc);
603+
tv->tv_usec = txc.time.tv_usec;
603604

604-
return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret;
605+
return copy_to_user(txc_p, &txc, sizeof(txc)) ? -EFAULT : ret;
605606
}
606607

607608
SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type,

include/uapi/linux/timex.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
#define NTP_API 4 /* NTP API version */
5959

60+
#ifndef __KERNEL__
6061
/*
6162
* syscall interface - used (mainly by NTP daemon)
6263
* to discipline kernel clock oscillator
@@ -91,6 +92,7 @@ struct timex {
9192
int :32; int :32; int :32; int :32;
9293
int :32; int :32; int :32;
9394
};
95+
#endif
9496

9597
struct __kernel_timex_timeval {
9698
__kernel_time64_t tv_sec;

0 commit comments

Comments
 (0)