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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5188454A.4070700@gmail.com>
Date:	Mon, 06 May 2013 18:05:30 -0600
From:	David Ahern <dsahern@...il.com>
To:	Stephane Eranian <eranian@...gle.com>
CC:	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	LKML <linux-kernel@...r.kernel.org>,
	Mike Galbraith <efault@....de>, Ingo Molnar <mingo@...nel.org>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Jiri Olsa <jolsa@...hat.com>,
	Namhyung Kim <namhyung@...nel.org>
Subject: Re: [PATCH] perf record: handle death by SIGTERM

On 5/6/13 4:40 PM, Stephane Eranian wrote:
> This is a good fix. I have run into this infinite loop in perf report
> many times.

The perf_file_header could use an 'I am sane' bit which is only set when 
the file is closed properly. Perhaps we could overload the magic field 
like this:

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 326068a..cd9fad6 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2364,7 +2364,6 @@ out_err_write:
     }

     f_header = (struct perf_file_header){
-       .magic     = PERF_MAGIC,
         .size      = sizeof(f_header),
         .attr_size = sizeof(f_attr),
         .attrs = {
@@ -2382,6 +2381,8 @@ out_err_write:
     };

     memcpy(&f_header.adds_features, &header->adds_features, 
sizeof(header->adds_features));
+   if (at_exit)
+       f_header.magic     = PERF_MAGIC,

     lseek(fd, 0, SEEK_SET);
     err = do_write(fd, &f_header, sizeof(f_header));

The perf magic is only written when the file is closed properly. In 
Mike's case you end up with the message (which can be enhanced)

   magic/endian check failed
   incompatible file format (rerun with -v to learn more)

which is better than an infinite loop.

David

--
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