Commit ceb30747 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull y2038 cleanups from Arnd Bergmann:
 "y2038 syscall implementation cleanups

  This is a series of cleanups for the y2038 work, mostly intended for
  namespace cleaning: the kernel defines the traditional time_t, timeval
  and timespec types that often lead to y2038-unsafe code. Even though
  the unsafe usage is mostly gone from the kernel, having the types and
  associated functions around means that we can still grow new users,
  and that we may be missing conversions to safe types that actually
  matter.

  There are still a number of driver specific patches needed to get the
  last users of these types removed, those have been submitted to the
  respective maintainers"

Link: https://lore.kernel.org/lkml/20191108210236.1296047-1-arnd@arndb.de/

* tag 'y2038-cleanups-5.5' of git://git.kernel.org:/pub/scm/linux/kernel/git/arnd/playground: (26 commits)
  y2038: alarm: fix half-second cut-off
  y2038: ipc: fix x32 ABI breakage
  y2038: fix typo in powerpc vdso "LOPART"
  y2038: allow disabling time32 system calls
  y2038: itimer: change implementation to timespec64
  y2038: move itimer reset into itimer.c
  y2038: use compat_{get,set}_itimer on alpha
  y2038: itimer: compat handling to itimer.c
  y2038: time: avoid timespec usage in settimeofday()
  y2038: timerfd: Use timespec64 internally
  y2038: elfcore: Use __kernel_old_timeval for process times
  y2038: make ns_to_compat_timeval use __kernel_old_timeval
  y2038: socket: use __kernel_old_timespec instead of timespec
  y2038: socket: remove timespec reference in timestamping
  y2038: syscalls: change remaining timeval to __kernel_old_timeval
  y2038: rusage: use __kernel_old_timeval
  y2038: uapi: change __kernel_time_t to __kernel_old_time_t
  y2038: stat: avoid 'time_t' in 'struct stat'
  y2038: ipc: remove __kernel_time_t reference from headers
  y2038: vdso: powerpc: avoid timespec references
  ...
parents 0da52210 b111df84
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -796,16 +796,9 @@ config OLD_SIGACTION
config COMPAT_OLD_SIGACTION
	bool

config 64BIT_TIME
	def_bool y
	help
	  This should be selected by all architectures that need to support
	  new system calls with a 64-bit time_t. This is relevant on all 32-bit
	  architectures, and 64-bit architectures as part of compat syscall
	  handling.

config COMPAT_32BIT_TIME
	def_bool !64BIT || COMPAT
	bool "Provide system calls for 32-bit time_t"
	default !64BIT || COMPAT
	help
	  This enables 32 bit time_t support in addition to 64 bit time_t support.
	  This is relevant on all 32-bit architectures, and 64-bit architectures
+1 −66
Original line number Diff line number Diff line
@@ -963,7 +963,7 @@ put_tv32(struct timeval32 __user *o, struct timespec64 *i)
}

static inline long
put_tv_to_tv32(struct timeval32 __user *o, struct timeval *i)
put_tv_to_tv32(struct timeval32 __user *o, struct __kernel_old_timeval *i)
{
	return copy_to_user(o, &(struct timeval32){
				.tv_sec = i->tv_sec,
@@ -971,30 +971,6 @@ put_tv_to_tv32(struct timeval32 __user *o, struct timeval *i)
			    sizeof(struct timeval32));
}

static inline long
get_it32(struct itimerval *o, struct itimerval32 __user *i)
{
	struct itimerval32 itv;
	if (copy_from_user(&itv, i, sizeof(struct itimerval32)))
		return -EFAULT;
	o->it_interval.tv_sec = itv.it_interval.tv_sec;
	o->it_interval.tv_usec = itv.it_interval.tv_usec;
	o->it_value.tv_sec = itv.it_value.tv_sec;
	o->it_value.tv_usec = itv.it_value.tv_usec;
	return 0;
}

static inline long
put_it32(struct itimerval32 __user *o, struct itimerval *i)
{
	return copy_to_user(o, &(struct itimerval32){
				.it_interval.tv_sec = o->it_interval.tv_sec,
				.it_interval.tv_usec = o->it_interval.tv_usec,
				.it_value.tv_sec = o->it_value.tv_sec,
				.it_value.tv_usec = o->it_value.tv_usec},
			    sizeof(struct itimerval32));
}

static inline void
jiffies_to_timeval32(unsigned long jiffies, struct timeval32 *value)
{
@@ -1039,47 +1015,6 @@ SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv,

asmlinkage long sys_ni_posix_timers(void);

SYSCALL_DEFINE2(osf_getitimer, int, which, struct itimerval32 __user *, it)
{
	struct itimerval kit;
	int error;

	if (!IS_ENABLED(CONFIG_POSIX_TIMERS))
		return sys_ni_posix_timers();

	error = do_getitimer(which, &kit);
	if (!error && put_it32(it, &kit))
		error = -EFAULT;

	return error;
}

SYSCALL_DEFINE3(osf_setitimer, int, which, struct itimerval32 __user *, in,
		struct itimerval32 __user *, out)
{
	struct itimerval kin, kout;
	int error;

	if (!IS_ENABLED(CONFIG_POSIX_TIMERS))
		return sys_ni_posix_timers();

	if (in) {
		if (get_it32(&kin, in))
			return -EFAULT;
	} else
		memset(&kin, 0, sizeof(kin));

	error = do_setitimer(which, &kin, out ? &kout : NULL);
	if (error || !out)
		return error;

	if (put_it32(out, &kout))
		return -EFAULT;

	return 0;

}

SYSCALL_DEFINE2(osf_utimes, const char __user *, filename,
		struct timeval32 __user *, tvs)
{
+2 −2
Original line number Diff line number Diff line
@@ -89,10 +89,10 @@
80	common	setgroups			sys_setgroups
81	common	osf_old_getpgrp			sys_ni_syscall
82	common	setpgrp				sys_setpgid
83	common	osf_setitimer			sys_osf_setitimer
83	common	osf_setitimer			compat_sys_setitimer
84	common	osf_old_wait			sys_ni_syscall
85	common	osf_table			sys_ni_syscall
86	common	osf_getitimer			sys_osf_getitimer
86	common	osf_getitimer			compat_sys_getitimer
87	common	gethostname			sys_gethostname
88	common	sethostname			sys_sethostname
89	common	getdtablesize			sys_getdtablesize
+1 −1
Original line number Diff line number Diff line
@@ -211,7 +211,7 @@ void foo(void)
	       offsetof (struct cpuinfo_ia64, ptce_stride));
	BLANK();
	DEFINE(IA64_TIMESPEC_TV_NSEC_OFFSET,
	       offsetof (struct timespec, tv_nsec));
	       offsetof (struct __kernel_old_timespec, tv_nsec));
	DEFINE(IA64_TIME_SN_SPEC_SNSEC_OFFSET,
	       offsetof (struct time_sn_spec, snsec));

+3 −3
Original line number Diff line number Diff line
@@ -15,9 +15,9 @@
#if defined(__mips64)
struct msqid64_ds {
	struct ipc64_perm msg_perm;
	__kernel_time_t msg_stime;	/* last msgsnd time */
	__kernel_time_t msg_rtime;	/* last msgrcv time */
	__kernel_time_t msg_ctime;	/* last change time */
	long msg_stime;			/* last msgsnd time */
	long msg_rtime;			/* last msgrcv time */
	long msg_ctime;			/* last change time */
	unsigned long  msg_cbytes;	/* current number of bytes on queue */
	unsigned long  msg_qnum;	/* number of messages in queue */
	unsigned long  msg_qbytes;	/* max number of bytes on queue */
Loading