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]
Date:	Thu, 12 Dec 2013 16:47:19 +0200
From:	Ciprian Barbu <ciprian.barbu@...aro.org>
To:	Clark Williams <williams@...hat.com>,
	RT <linux-rt-users@...r.kernel.org>
CC:	LKML <linux-kernel@...r.kernel.org>,
	Linaro Networking <linaro-networking@...aro.org>
Subject: [PATCH] rt-tests: hackbench: fix for uninitialized start time

Hello,

While playing around with hackbench I discovered that I would sometimes 
get an enormous time reported, even if the run time would be less than a 
second or so. The problem was that the struct timeval start was not 
initialized until after all children have been created. But if the 
program receives a signal before this is done, the start time is left 
uninitialized.

I propose that in such situations an error message be displayed, like 
the following patch does.

Please let me know if this is acceptable.

Regards,
/Ciprian

---
diff -rupN rt-tests/src/hackbench/hackbench.c 
rt-tests2/src/hackbench/hackbench.c
--- rt-tests/src/hackbench/hackbench.c  2013-12-12 16:27:06.273731063 +0200
+++ rt-tests2/src/hackbench/hackbench.c 2013-12-12 16:24:01.945738814 +0200
@@ -442,6 +442,7 @@ int main(int argc, char *argv[])
     struct timeval start, stop, diff;
     int readyfds[2], wakefds[2];
     char dummy;
+   int timer_started = 0;
     struct sched_param sp;

     process_options (argc, argv);
@@ -490,6 +491,7 @@ int main(int argc, char *argv[])
             }

         gettimeofday(&start, NULL);
+       timer_started = 1;

         /* Kick them off */
         if (write(wakefds[1], &dummy, 1) != 1) {
@@ -509,8 +511,12 @@ int main(int argc, char *argv[])
     gettimeofday(&stop, NULL);

     /* Print time... */
-   timersub(&stop, &start, &diff);
-   printf("Time: %lu.%03lu\n", diff.tv_sec, diff.tv_usec/1000);
+   if (timer_started) {
+       timersub(&stop, &start, &diff);
+       printf("Time: %lu.%03lu\n", diff.tv_sec, diff.tv_usec/1000);
+   } else {
+       fprintf(stderr, "No measurements available\n");
+   }
     free(child_tab);
     exit(0);
  }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ