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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1487169069-15721-4-git-send-email-immortalguardian1@gmail.com>
Date:   Wed, 15 Feb 2017 17:31:04 +0300
From:   Andrey Drobyshev <immortalguardian1@...il.com>
To:     linux-kernel@...r.kernel.org
Cc:     gq@...msu.su, giometti@...eenne.com
Subject: [PATCH 3/8] hardpps: fix some pps_jitter issues.

Handle possible overflow, implementation-defined result of signed right shift
and replace unsuitable constant.

Signed-off-by: Andrey Drobyshev <immortalguardian1@...il.com>
Signed-off-by: Alexander GQ Gerasiov <gq@...msu.su>
---
 kernel/time/ntp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 22f2235..9cef1b9 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -91,6 +91,7 @@ static time64_t			ntp_next_leap_sec = TIME64_MAX;
  */
 #define PPS_VALID	10	/* PPS signal watchdog max (s) */
 #define PPS_POPCORN	4	/* popcorn spike threshold (shift) */
+#define PPS_JITUPD	2	/* pps_jitter update factor (shift) */
 #define PPS_INTMIN	2	/* min freq interval (s) (shift) */
 #define PPS_INTMAX	8	/* max freq interval (s) (shift) */
 #define PPS_INTCOUNT	4	/* number of consecutive good intervals to
@@ -941,7 +942,7 @@ static void hardpps_update_phase(long error)
 	 * threshold, the sample is discarded; otherwise, if so enabled,
 	 * the time offset is updated.
 	 */
-	if (jitter > (pps_jitter << PPS_POPCORN)) {
+	if (pps_jitter && (jitter > ((long long)pps_jitter << PPS_POPCORN))) {
 		printk_deferred(KERN_WARNING
 				"hardpps: PPSJITTER: jitter=%ld, limit=%ld\n",
 				jitter, (pps_jitter << PPS_POPCORN));
@@ -955,7 +956,7 @@ static void hardpps_update_phase(long error)
 		time_adjust = 0;
 	}
 	/* update jitter */
-	pps_jitter += (jitter - pps_jitter) >> PPS_INTMIN;
+	pps_jitter += shift_right(jitter - pps_jitter, PPS_JITUPD);
 }
 
 /*
-- 
2.1.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ