From: Mark Salyzyn <salyzyn@android.com>
To: linux-kernel@vger.kernel.org
Cc: kernel-team@android.com, Chiawei Wang <chiaweiwang@google.com>,
Mark Salyzyn <salyzyn@android.com>,
stable@vger.kernel.org, Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Vincenzo Frascino <vincenzo.frascino@arm.com>
Subject: [PATCH] lib/vdso: use CLOCK_REALTIME_COARSE for time()
Date: Thu, 11 Jun 2020 08:57:50 -0700 [thread overview]
Message-ID: <20200611155804.65204-1-salyzyn@android.com> (raw)
From: Chiawei Wang <chiaweiwang@google.com>
CLOCK_REALTIME in vdso data won't be updated if
__arch_use_vsyscall() returns false. It will let time()
return an incorrect time value. Since time() is designed
to return the seconds since the Epoch, using
CLOCK_REALTIME_COARSE can still fulfill the request and
never fails.
Signed-off-by: Chiawei Wang <chiaweiwang@google.com>
Signed-off-by: Mark Salyzyn <salyzyn@android.com>
Cc: linux-kernel@vger.kernel.org
Cc: kernel-team@android.com
Cc: stable@vger.kernel.org # 5.4+
---
lib/vdso/gettimeofday.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
index a2909af4b924..7ea22096cbe2 100644
--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -324,7 +324,7 @@ __cvdso_time_data(const struct vdso_data *vd, __kernel_old_time_t *time)
vd->clock_mode == VDSO_CLOCKMODE_TIMENS)
vd = __arch_get_timens_vdso_data();
- t = READ_ONCE(vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec);
+ t = READ_ONCE(vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME_COARSE].sec);
if (time)
*time = t;
--
2.27.0.278.ge193c7cf3a9-goog
next reply other threads:[~2020-06-11 15:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-11 15:57 Mark Salyzyn [this message]
2020-06-11 19:34 ` [PATCH] lib/vdso: use CLOCK_REALTIME_COARSE for time() Thomas Gleixner
2020-06-11 19:47 ` Mark Salyzyn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200611155804.65204-1-salyzyn@android.com \
--to=salyzyn@android.com \
--cc=chiaweiwang@google.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=vincenzo.frascino@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox