]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sourcestats: align sample time used for source report
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 12 Jan 2017 11:21:50 +0000 (12:21 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 12 Jan 2017 15:34:28 +0000 (16:34 +0100)
This reduces leak of sample times (and receive timestamps which are
related to sample times), which could be useful in off-path attacks on
unauthenticated symmetric interleaved mode.

sourcestats.c

index 27e6ce389f75c573df057e0b453fbffe383dd420..52c031468aa265f4549551140fddbcb6cbf9743e 100644 (file)
@@ -928,7 +928,7 @@ void
 SST_DoSourceReport(SST_Stats inst, RPT_SourceReport *report, struct timespec *now)
 {
   int i, j;
-  struct timespec ago;
+  struct timespec last_sample_time;
 
   if (inst->n_samples > 0) {
     i = get_runsbuf_index(inst, inst->n_samples - 1);
@@ -938,8 +938,10 @@ SST_DoSourceReport(SST_Stats inst, RPT_SourceReport *report, struct timespec *no
     report->latest_meas_err = 0.5*inst->root_delays[j] + inst->root_dispersions[j];
     report->stratum = inst->strata[j];
 
-    UTI_DiffTimespecs(&ago, now, &inst->sample_times[i]);
-    report->latest_meas_ago = ago.tv_sec;
+    /* Align the sample time to reduce the leak of the receive timestamp */
+    last_sample_time = inst->sample_times[i];
+    last_sample_time.tv_nsec = 0;
+    report->latest_meas_ago = UTI_DiffTimespecsToDouble(now, &last_sample_time);
   } else {
     report->latest_meas_ago = (uint32_t)-1;
     report->orig_latest_meas = 0;