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

Commit 6b98eae6 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "time: Always make sure wall_to_monotonic isn't positive"

parents ed626508 1e914335
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -700,6 +700,7 @@ int do_settimeofday(const struct timespec *tv)
	struct timekeeper *tk = &tk_core.timekeeper;
	struct timespec64 ts_delta, xt, tmp;
	unsigned long flags;
	int ret = 0;

	if (!timespec_valid_strict(tv))
		return -EINVAL;
@@ -713,11 +714,16 @@ int do_settimeofday(const struct timespec *tv)
	ts_delta.tv_sec = tv->tv_sec - xt.tv_sec;
	ts_delta.tv_nsec = tv->tv_nsec - xt.tv_nsec;

	if (timespec64_compare(&tk->wall_to_monotonic, &ts_delta) > 0) {
		ret = -EINVAL;
		goto out;
	}

	tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, ts_delta));

	tmp = timespec_to_timespec64(*tv);
	tk_set_xtime(tk, &tmp);

out:
	timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET);

	write_seqcount_end(&tk_core.seq);
@@ -726,7 +732,7 @@ int do_settimeofday(const struct timespec *tv)
	/* signal hrtimers about time change */
	clock_was_set();

	return 0;
	return ret;
}
EXPORT_SYMBOL(do_settimeofday);

@@ -755,7 +761,8 @@ int timekeeping_inject_offset(struct timespec *ts)

	/* Make sure the proposed value is valid */
	tmp = timespec64_add(tk_xtime(tk),  ts64);
	if (!timespec64_valid_strict(&tmp)) {
	if (timespec64_compare(&tk->wall_to_monotonic, &ts64) > 0 ||
	    !timespec64_valid_strict(&tmp)) {
		ret = -EINVAL;
		goto error;
	}