From: "Michael Weiß" <michael.weiss@aisec.fraunhofer.de>
To: Thomas Gleixner <tglx@linutronix.de>,
Andrei Vagin <avagin@gmail.com>,
Dmitry Safonov <0x7f454c46@gmail.com>,
Christian Brauner <christian.brauner@ubuntu.com>
Cc: linux-kernel@vger.kernel.org,
"Michael Weiß" <michael.weiss@aisec.fraunhofer.de>
Subject: [PATCH 0/4] time namespace aware system boot time
Date: Wed, 7 Oct 2020 22:00:11 +0200 [thread overview]
Message-ID: <20201007200015.30868-1-michael.weiss@aisec.fraunhofer.de> (raw)
Time namespaces make it possible to virtualize time inside of
containers, e.g., it is feasible to reset the uptime of a container
to zero by setting the time namespace offset for boottime to the
negated current value of the CLOCK_BOOTTIME.
However, the boot time stamp provided by getboottime64() does not
take care of time namespaces. The resulting boot time stamp 'btime'
provided by /proc/stat does not show a plausible time stamp inside
the time namespace of a container.
We address this by shifting the value returned by getboottime64()
by subtracting the boottime offset of the time namespace.
(A selftest to check the expected /proc/stat 'btime' inside the
namespace is provided.)
Further, to avoid to show processes as time travelers inside of the
time namespace the boottime offset then needs to be added to the
start_bootime provided by the task_struct.
Michael Weiß (4):
timens: additional helper function to add boottime in nsec
time: make getboottime64 aware of time namespace
fs/proc: apply timens offset for start_boottime of processes
selftests/timens: added selftest for /proc/stat btime
fs/proc/array.c | 6 ++-
include/linux/time_namespace.h | 7 +++
kernel/time/timekeeping.c | 3 ++
tools/testing/selftests/timens/procfs.c | 58 ++++++++++++++++++++++++-
4 files changed, 71 insertions(+), 3 deletions(-)
--
2.20.1
next reply other threads:[~2020-10-07 20:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-07 20:00 Michael Weiß [this message]
2020-10-07 20:00 ` [PATCH 1/4] timens: additional helper function to add boottime in nsec Michael Weiß
2020-10-07 20:00 ` [PATCH 2/4] time: make getboottime64 aware of time namespace Michael Weiß
2020-10-07 20:00 ` [PATCH 3/4] fs/proc: apply timens offset for start_boottime of processes Michael Weiß
2020-10-07 22:38 ` kernel test robot
2020-10-07 20:00 ` [PATCH 4/4] selftests/timens: added selftest for /proc/stat btime Michael Weiß
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=20201007200015.30868-1-michael.weiss@aisec.fraunhofer.de \
--to=michael.weiss@aisec.fraunhofer.de \
--cc=0x7f454c46@gmail.com \
--cc=avagin@gmail.com \
--cc=christian.brauner@ubuntu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).