lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1472402439-1146-1-git-send-email-yu.c.chen@intel.com>
Date:   Mon, 29 Aug 2016 00:40:39 +0800
From:   Chen Yu <yu.c.chen@...el.com>
To:     x86@...nel.org
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        John Stultz <john.stultz@...aro.org>,
        Ingo Molnar <mingo@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org,
        Xunlei Pang <xlpang@...hat.com>,
        "Rafael J. Wysocki" <rjw@...ysocki.net>,
        Chen Yu <yu.c.chen@...el.com>, stable@...r.kernel.org (3.17+),
        Zhang Rui <rui.zhang@...el.com>, linux-pm@...r.kernel.org
Subject: [PATCH][RFC v5] timekeeping: Ignore the bogus sleep time if pm_trace is enabled

Previously we encountered some memory overflow issues due to
the bogus sleep time brought by inconsistent rtc, which is
triggered when pm_trace is enabled, and we have fixed it
in recent kernel. However it's improper in the first place
to call __timekeeping_inject_sleeptime() in case that pm_trace
is enabled simply because that "hash" time value will wreckage
the timekeeping subsystem.

So this patch ignores the sleep time if pm_trace is enabled in
the following situation:
1. rtc is used as persist clock to compensate for sleep time,
   or
2. rtc is used to calculate the sleep time in rtc_resume.

Cc: stable@...r.kernel.org  (3.17+)
Cc: Rafael J. Wysocki <rjw@...ysocki.net>
Cc: John Stultz <john.stultz@...aro.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Xunlei Pang <xlpang@...hat.com>
Cc: Zhang Rui <rui.zhang@...el.com>
Cc: linux-kernel@...r.kernel.org
Cc: linux-pm@...r.kernel.org
Suggested-by: Xunlei Pang <xlpang@...hat.com>
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
Suggested-by: Thomas Gleixner <tglx@...utronix.de>
Reported-by: Janek Kozicki <cosurgi@...il.com>
Signed-off-by: Chen Yu <yu.c.chen@...el.com>
---
 arch/x86/kernel/rtc.c     | 12 ++++++++++++
 kernel/time/timekeeping.c |  3 ++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
index 79c6311c..5c28197 100644
--- a/arch/x86/kernel/rtc.c
+++ b/arch/x86/kernel/rtc.c
@@ -8,6 +8,7 @@
 #include <linux/export.h>
 #include <linux/pnp.h>
 #include <linux/of.h>
+#include <linux/pm-trace.h>
 
 #include <asm/vsyscall.h>
 #include <asm/x86_init.h>
@@ -144,6 +145,17 @@ int update_persistent_clock(struct timespec now)
 void read_persistent_clock(struct timespec *ts)
 {
 	x86_platform.get_wallclock(ts);
+
+	/*
+	 * Make rtc-based persistent clock unusable
+	 * if pm_trace is enabled, only take effect
+	 * for timekeeping_suspend/resume.
+	 */
+	if (pm_trace_is_enabled() &&
+	    x86_platform.get_wallclock == mach_get_cmos_time) {
+		ts->tv_sec = 0;
+		ts->tv_nsec = 0;
+	}
 }
 
 
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 3b65746..9af885d 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -23,6 +23,7 @@
 #include <linux/stop_machine.h>
 #include <linux/pvclock_gtod.h>
 #include <linux/compiler.h>
+#include <linux/pm-trace.h>
 
 #include "tick-internal.h"
 #include "ntp_internal.h"
@@ -1551,7 +1552,7 @@ static void __timekeeping_inject_sleeptime(struct timekeeper *tk,
  */
 bool timekeeping_rtc_skipresume(void)
 {
-	return sleeptime_injected;
+	return sleeptime_injected || pm_trace_is_enabled();
 }
 
 /**
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ