sys/sysinfo: Respect boottime inside time namespace
PATCH 1/1 sys/sysinfo: Respect boottime inside time namespace
The sysinfo() syscall includes uptime in seconds this makes it consistent with the /proc/uptime inside of a time namespace.
--- kernel/sys.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/sys.c +2 -0
@@ -47,6 +47,7 @@#include <linux/syscalls.h> #include <linux/kprobes.h> #include <linux/user_namespace.h> +#include <linux/time_namespace.h> #include <linux/binfmts.h> #include <linux/sched.h>
@@ -2546,6 +2547,7 @@ static int do_sysinfo(struct sysinfo *info)memset (info,0 ,sizeof (struct sysinfo ));ktime_get_boottime_ts64 (&tp); +timens_add_boottime (&tp); info->uptime = tp.tv_sec + (tp.tv_nsec ?1 :0 );get_avenrun (info->loads,0 ,SI_LOAD_SHIFT -FSHIFT );
Signature · 1 line
2.24.1
Quoted 4 lines · Cyril Hrubis
The
sysinfo()syscall includes uptime in seconds this makes it consistent with the/proc/uptimeinside of a time namespace.Signed-off-by Cyril Hrubis <[email protected]>
Quoted 18 lines
--- kernel/sys.c | 2 ++ 1 file changed, 2 insertions(+)kernel/sys.c +1
-0@@ -47,6 +47,7 @@#include <linux/syscalls.h> #include <linux/kprobes.h> #include <linux/user_namespace.h> +#include <linux/time_namespace.h> #include <linux/binfmts.h> #include <linux/sched.h>
kernel/sys.c static int do_sysinfo(struct sysinfo *info) · line 2553
Quoted 7 lines
kernel/sys.c +1
-0@@ -2546,6 +2547,7 @@ static int do_sysinfo(struct sysinfo *info)memset (info,0 ,sizeof (struct sysinfo ));ktime_get_boottime_ts64 (&tp); +timens_add_boottime (&tp); info->uptime = tp.tv_sec + (tp.tv_nsec ?1 :0 );get_avenrun (info->loads,0 ,SI_LOAD_SHIFT -FSHIFT );
Thanks for noticing,
Dmitry
The following commit has been merged into the timers/urgent branch of tip:
The following commit has been merged into the timers/urgent branch of tip:
Commit-ID: ecc421e05bab97cf3ff4fe456ade47ef84dba8c2 Gitweb: https://git.kernel.org/tip/ecc421e05bab97cf3ff4fe456ade47ef84dba8c2 Author: Cyril Hrubis <[email protected]> AuthorDate: Tue, 03 Mar 2020 16:06:38 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Tue, 03 Mar 2020 19:34:32 +01:00
sys/sysinfo: Respect boottime inside time namespace
The sysinfo() syscall includes uptime in seconds but has no correction for time namespaces which makes it inconsistent with the /proc/uptime inside of a time namespace.
Add the missing time namespace adjustment call.
--- kernel/sys.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/sys.c +2 -0
@@ -47,6 +47,7 @@#include <linux/syscalls.h> #include <linux/kprobes.h> #include <linux/user_namespace.h> +#include <linux/time_namespace.h> #include <linux/binfmts.h> #include <linux/sched.h>
@@ -2546,6 +2547,7 @@ static int do_sysinfo(struct sysinfo *info)memset (info,0 ,sizeof (struct sysinfo ));ktime_get_boottime_ts64 (&tp); +timens_add_boottime (&tp); info->uptime = tp.tv_sec + (tp.tv_nsec ?1 :0 );get_avenrun (info->loads,0 ,SI_LOAD_SHIFT -FSHIFT );