Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ead25417 authored by Deepa Dinamani's avatar Deepa Dinamani Committed by Arnd Bergmann
Browse files

timex: use __kernel_timex internally



struct timex is not y2038 safe.
Replace all uses of timex with y2038 safe __kernel_timex.

Note that struct __kernel_timex is an ABI interface definition.
We could define a new structure based on __kernel_timex that
is only available internally instead. Right now, there isn't
a strong motivation for this as the structure is isolated to
a few defined struct timex interfaces and such a structure would
be exactly the same as struct timex.

The patch was generated by the following coccinelle script:

virtual patch

@depends on patch forall@
identifier ts;
expression e;
@@
(
- struct timex ts;
+ struct __kernel_timex ts;
|
- struct timex ts = {};
+ struct __kernel_timex ts = {};
|
- struct timex ts = e;
+ struct __kernel_timex ts = e;
|
- struct timex *ts;
+ struct __kernel_timex *ts;
|
(memset \| copy_from_user \| copy_to_user \)(...,
- sizeof(struct timex))
+ sizeof(struct __kernel_timex))
)

@depends on patch forall@
identifier ts;
identifier fn;
@@
fn(...,
- struct timex *ts,
+ struct __kernel_timex *ts,
...) {
...
}

@depends on patch forall@
identifier ts;
identifier fn;
@@
fn(...,
- struct timex *ts) {
+ struct __kernel_timex *ts) {
...
}

Signed-off-by: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
Cc: linux-alpha@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 1a596398
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1253,7 +1253,7 @@ struct timex32 {

SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
{
        struct timex txc;
	struct __kernel_timex txc;
	int ret;

	/* copy relevant bits of struct timex. */
@@ -1270,7 +1270,8 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
	if (copy_to_user(txc_p, &txc, offsetof(struct timex32, time)) ||
	    (copy_to_user(&txc_p->tick, &txc.tick, sizeof(struct timex32) - 
			  offsetof(struct timex32, tick))) ||
	    (put_tv_to_tv32(&txc_p->time, &txc.time)))
	    (put_user(txc.time.tv_sec, &txc_p->time.tv_sec)) ||
	    (put_user(txc.time.tv_usec, &txc_p->time.tv_usec)))
	  return -EFAULT;

	return ret;
+2 −2
Original line number Diff line number Diff line
@@ -548,7 +548,7 @@ SYSCALL_DEFINE2(getdomainname, char __user *, name, int, len)
SYSCALL_DEFINE1(sparc_adjtimex, struct timex __user *, txc_p)
{
	struct timex txc;		/* Local copy of parameter */
	struct timex *kt = (void *)&txc;
	struct __kernel_timex *kt = (void *)&txc;
	int ret;

	/* Copy the user data space into the kernel copy
@@ -572,7 +572,7 @@ SYSCALL_DEFINE1(sparc_adjtimex, struct timex __user *, txc_p)
SYSCALL_DEFINE2(sparc_clock_adjtime, const clockid_t, which_clock,struct timex __user *, txc_p)
{
	struct timex txc;		/* Local copy of parameter */
	struct timex *kt = (void *)&txc;
	struct __kernel_timex *kt = (void *)&txc;
	int ret;

	if (!IS_ENABLED(CONFIG_POSIX_TIMERS)) {
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ static int ptp_clock_gettime(struct posix_clock *pc, struct timespec64 *tp)
	return err;
}

static int ptp_clock_adjtime(struct posix_clock *pc, struct timex *tx)
static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx)
{
	struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
	struct ptp_clock_info *ops;
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ struct posix_clock;
struct posix_clock_operations {
	struct module *owner;

	int  (*clock_adjtime)(struct posix_clock *pc, struct timex *tx);
	int  (*clock_adjtime)(struct posix_clock *pc, struct __kernel_timex *tx);

	int  (*clock_gettime)(struct posix_clock *pc, struct timespec64 *ts);

+3 −3
Original line number Diff line number Diff line
@@ -69,9 +69,9 @@ extern int get_old_itimerspec32(struct itimerspec64 *its,
			const struct old_itimerspec32 __user *uits);
extern int put_old_itimerspec32(const struct itimerspec64 *its,
			struct old_itimerspec32 __user *uits);
struct timex;
int get_old_timex32(struct timex *, const struct old_timex32 __user *);
int put_old_timex32(struct old_timex32 __user *, const struct timex *);
struct __kernel_timex;
int get_old_timex32(struct __kernel_timex *, const struct old_timex32 __user *);
int put_old_timex32(struct old_timex32 __user *, const struct __kernel_timex *);

#if __BITS_PER_LONG == 64

Loading