um: time-travel: fix time corruption
authorJohannes Berg <johannes.berg@intel.com>
Wed, 25 Oct 2023 20:45:05 +0000 (22:45 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Feb 2024 20:14:31 +0000 (20:14 +0000)
commitde3e9d8e8d1ae0a4d301109d1ec140796901306c
treef22d325e616d2129f4a543d26504a9f1e5419290
parent857710e1b11da7e32cc17cdb4eeb2c40db1dff72
um: time-travel: fix time corruption

[ Upstream commit abe4eaa8618bb36c2b33e9cdde0499296a23448c ]

In 'basic' time-travel mode (without =inf-cpu or =ext), we
still get timer interrupts. These can happen at arbitrary
points in time, i.e. while in timer_read(), which pushes
time forward just a little bit. Then, if we happen to get
the interrupt after calculating the new time to push to,
but before actually finishing that, the interrupt will set
the time to a value that's incompatible with the forward,
and we'll crash because time goes backwards when we do the
forwarding.

Fix this by reading the time_travel_time, calculating the
adjustment, and doing the adjustment all with interrupts
disabled.

Reported-by: Vincent Whitchurch <Vincent.Whitchurch@axis.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/um/kernel/time.c