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: <20151104140811.GA32664@krava.brq.redhat.com>
Date:	Wed, 4 Nov 2015 15:08:11 +0100
From:	Jiri Olsa <jolsa@...hat.com>
To:	Markus Trippelsdorf <markus@...ppelsdorf.de>
Cc:	Ingo Molnar <mingo@...nel.org>, linux-kernel@...r.kernel.org,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Arnaldo Carvalho de Melo <acme@...radead.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: [PATCH] perf tools: Insert split maps correctly into origin group

On Wed, Nov 04, 2015 at 01:41:37PM +0100, Markus Trippelsdorf wrote:

SNIP

> > > Apparently it started with:
> > > 
> > > commit cfc5acd4c80b875d2f739d6a93562034aee5563f
> > > Author: Arnaldo Carvalho de Melo <acme@...hat.com>
> > > Date:   Wed Sep 23 15:15:54 2015 -0300
> > > 
> > >     perf top: Filter symbols based on __map__is_kernel(map)
> > 
> > I think it's correct to assume map->groups != NULL,
> > IMO the change just uncovered another bug
> > 
> > I couldn't reproduce this, but I could find one place where this
> > assumption is broken.. could you please try attached patch?
> 
> Your patch fixes the issue. 
> Thanks.

thanks, sending patch

jirka


---
When new maps are cloned out of split map they are added into
origin map's group, but their groups pointer is not updated.

This could lead to segfault, because map::groups is expected
to be always set as reported by Markus:

  __map__is_kernel (map=map@...ry=0x1abb7a0) at util/map.c:238
  238             return __machine__kernel_map(map->groups->machine, map->type) =
  (gdb) bt
  #0  __map__is_kernel (map=map@...ry=0x1abb7a0) at util/map.c:238
  #1  0x00000000004393e4 in symbol_filter (map=map@...ry=0x1abb7a0, sym=sym@...ry
  #2  0x00000000004fcd4d in dso__load_sym (dso=dso@...ry=0x166dae0, map=map@...ry
  #3  0x00000000004a64e0 in dso__load (dso=0x166dae0, map=map@...ry=0x1abb7a0, fi
  #4  0x00000000004b941f in map__load (filter=0x4393c0 <symbol_filter>, map=<opti
  #5  map__find_symbol (map=0x1abb7a0, addr=40188, filter=0x4393c0 <symbol_filter
  ...

Adding __map_groups__insert function to add map into groups
together with map::groups pointer update. It takes no lock
as opposed to existing map_groups__insert.

Using __map_groups__insert to add new maps after map split.

Reported-by: Markus Trippelsdorf <markus@...ppelsdorf.de>
Tested-by: Markus Trippelsdorf <markus@...ppelsdorf.de>
Link: http://lkml.kernel.org/n/tip-b66q3nbv0m456f2evlhtuw3u@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
 tools/perf/util/map.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 4e38c396a897..afc6b56cf749 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -644,6 +644,12 @@ size_t map_groups__fprintf(struct map_groups *mg, FILE *fp)
 	return printed;
 }
 
+static void __map_groups__insert(struct map_groups *mg, struct map *map)
+{
+	__maps__insert(&mg->maps[map->type], map);
+	map->groups = mg;
+}
+
 static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
 {
 	struct rb_root *root;
@@ -682,7 +688,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp
 			}
 
 			before->end = map->start;
-			__maps__insert(maps, before);
+			__map_groups__insert(pos->groups, before);
 			if (verbose >= 2)
 				map__fprintf(before, fp);
 		}
@@ -696,7 +702,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp
 			}
 
 			after->start = map->end;
-			__maps__insert(maps, after);
+			__map_groups__insert(pos->groups, after);
 			if (verbose >= 2)
 				map__fprintf(after, fp);
 		}
-- 
2.4.3

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