From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751459AbcGUHVT (ORCPT ); Thu, 21 Jul 2016 03:21:19 -0400 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:47911 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750975AbcGUHVR (ORCPT ); Thu, 21 Jul 2016 03:21:17 -0400 Subject: Re: [PATCH] perf: symbols: dso__load(): remove check of file on uninitialized memory To: Jiri Olsa References: <1466691621-29488-1-git-send-email-mkl@pengutronix.de> <20160624064345.GB32753@krava> <0d026547-6805-fe34-3430-67ae979eed57@pengutronix.de> <20160624115112.GD10142@krava> <2ca568c2-e6b7-fb0d-48bb-80aa3daefc98@pengutronix.de> Cc: Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, Jiri Olsa , Uwe Kleine-Koenig From: Marc Kleine-Budde Message-ID: <2064e6de-8535-d06a-4f0d-010377a42f5a@pengutronix.de> Date: Thu, 21 Jul 2016 09:21:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.1.0 MIME-Version: 1.0 In-Reply-To: <2ca568c2-e6b7-fb0d-48bb-80aa3daefc98@pengutronix.de> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="HjJfxXgbgVGwvphnCukM4DQsM0BqhBucs" X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --HjJfxXgbgVGwvphnCukM4DQsM0BqhBucs Content-Type: multipart/mixed; boundary="gDQsncGE6Lf4790CwOgnP4k5DNQVHWaJh" From: Marc Kleine-Budde To: Jiri Olsa Cc: Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, Jiri Olsa , Uwe Kleine-Koenig Message-ID: <2064e6de-8535-d06a-4f0d-010377a42f5a@pengutronix.de> Subject: Re: [PATCH] perf: symbols: dso__load(): remove check of file on uninitialized memory References: <1466691621-29488-1-git-send-email-mkl@pengutronix.de> <20160624064345.GB32753@krava> <0d026547-6805-fe34-3430-67ae979eed57@pengutronix.de> <20160624115112.GD10142@krava> <2ca568c2-e6b7-fb0d-48bb-80aa3daefc98@pengutronix.de> In-Reply-To: <2ca568c2-e6b7-fb0d-48bb-80aa3daefc98@pengutronix.de> --gDQsncGE6Lf4790CwOgnP4k5DNQVHWaJh Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/24/2016 01:56 PM, Marc Kleine-Budde wrote: > On 06/24/2016 01:51 PM, Jiri Olsa wrote: >> On Fri, Jun 24, 2016 at 09:54:22AM +0200, Marc Kleine-Budde wrote: >>> On 06/24/2016 08:43 AM, Jiri Olsa wrote: >>>> On Thu, Jun 23, 2016 at 04:20:21PM +0200, Marc Kleine-Budde wrote: >>>>> In commit "403567217d3f perf symbols: Do not read symbols/data from= >>>>> device files" a check to uninitialzied memory was added. This leads= to >>>>> the following valgrind output: >>>>> >>>>> =3D=3D24515=3D=3D Syscall param stat(file_name) points to uninitial= ised byte(s) >>>>> =3D=3D24515=3D=3D at 0x75B26D5: _xstat (in /lib/x86_64-linux-gnu= /libc-2.22.so) >>>>> =3D=3D24515=3D=3D by 0x4E548D: stat (stat.h:454) >>>>> =3D=3D24515=3D=3D by 0x4E548D: is_regular_file (util.c:687) >>>>> =3D=3D24515=3D=3D by 0x4A5BEE: dso__load (symbol.c:1435) >>>>> =3D=3D24515=3D=3D by 0x4BB1AE: map__load (map.c:289) >>>>> =3D=3D24515=3D=3D by 0x4BB1AE: map__find_symbol (map.c:333) >>>>> =3D=3D24515=3D=3D by 0x4835B3: thread__find_addr_location (event= =2Ec:1300) >>>>> =3D=3D24515=3D=3D by 0x4B5342: add_callchain_ip (machine.c:1652)= >>>>> =3D=3D24515=3D=3D by 0x4B5342: thread__resolve_callchain_sample = (machine.c:1906) >>>>> =3D=3D24515=3D=3D by 0x4B9E7D: thread__resolve_callchain (machin= e.c:1958) >>>>> =3D=3D24515=3D=3D by 0x441B3E: process_event (builtin-script.c:7= 95) >>>>> =3D=3D24515=3D=3D by 0x441B3E: process_sample_event (builtin-scr= ipt.c:920) >>>>> =3D=3D24515=3D=3D by 0x4BEE29: perf_evlist__deliver_sample (sess= ion.c:1192) >>>>> =3D=3D24515=3D=3D by 0x4BEE29: machines__deliver_event (session.= c:1229) >>>>> =3D=3D24515=3D=3D by 0x4BF770: perf_session__deliver_event (sess= ion.c:1286) >>>>> =3D=3D24515=3D=3D by 0x4BF770: ordered_events__deliver_event (se= ssion.c:114) >>>>> =3D=3D24515=3D=3D by 0x4C1D17: __ordered_events__flush (ordered-= events.c:207) >>>>> =3D=3D24515=3D=3D by 0x4C1D17: ordered_events__flush.part.3 (ord= ered-events.c:274) >>>>> =3D=3D24515=3D=3D by 0x4BF44C: perf_session__process_user_event = (session.c:1325) >>>>> =3D=3D24515=3D=3D by 0x4BF44C: perf_session__process_event (sess= ion.c:1451) >>>>> =3D=3D24515=3D=3D Address 0x807c6a0 is 0 bytes inside a block of s= ize 4,096 alloc'd >>>>> =3D=3D24515=3D=3D at 0x4C29C0F: malloc (in /usr/lib/valgrind/vgp= reload_memcheck-amd64-linux.so) >>>>> =3D=3D24515=3D=3D by 0x4A5BCB: dso__load (symbol.c:1421) >>>>> =3D=3D24515=3D=3D by 0x4BB1AE: map__load (map.c:289) >>>>> =3D=3D24515=3D=3D by 0x4BB1AE: map__find_symbol (map.c:333) >>>>> =3D=3D24515=3D=3D by 0x4835B3: thread__find_addr_location (event= =2Ec:1300) >>>>> =3D=3D24515=3D=3D by 0x4B5342: add_callchain_ip (machine.c:1652)= >>>>> =3D=3D24515=3D=3D by 0x4B5342: thread__resolve_callchain_sample = (machine.c:1906) >>>>> =3D=3D24515=3D=3D by 0x4B9E7D: thread__resolve_callchain (machin= e.c:1958) >>>>> =3D=3D24515=3D=3D by 0x441B3E: process_event (builtin-script.c:7= 95) >>>>> =3D=3D24515=3D=3D by 0x441B3E: process_sample_event (builtin-scr= ipt.c:920) >>>>> =3D=3D24515=3D=3D by 0x4BEE29: perf_evlist__deliver_sample (sess= ion.c:1192) >>>>> =3D=3D24515=3D=3D by 0x4BEE29: machines__deliver_event (session.= c:1229) >>>>> =3D=3D24515=3D=3D by 0x4BF770: perf_session__deliver_event (sess= ion.c:1286) >>>>> =3D=3D24515=3D=3D by 0x4BF770: ordered_events__deliver_event (se= ssion.c:114) >>>>> =3D=3D24515=3D=3D by 0x4C1D17: __ordered_events__flush (ordered-= events.c:207) >>>>> =3D=3D24515=3D=3D by 0x4C1D17: ordered_events__flush.part.3 (ord= ered-events.c:274) >>>>> =3D=3D24515=3D=3D by 0x4BF44C: perf_session__process_user_event = (session.c:1325) >>>>> =3D=3D24515=3D=3D by 0x4BF44C: perf_session__process_event (sess= ion.c:1451) >>>>> =3D=3D24515=3D=3D by 0x4C0EAC: __perf_session__process_events (s= ession.c:1804) >>>>> =3D=3D24515=3D=3D by 0x4C0EAC: perf_session__process_events (ses= sion.c:1858) >>>>> >>>>> This patch fixes the problem by removing the check. >>>>> >>>>> Fixes: 403567217d3f perf symbols: Do not read symbols/data from dev= ice files >>>>> Signed-off-by: Marc Kleine-Budde >>>>> --- >>>>> tools/perf/util/symbol.c | 3 +-- >>>>> 1 file changed, 1 insertion(+), 2 deletions(-) >>>>> >>>>> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c >>>>> index 8a747dc6cf86..b4070daeb17f 100644 >>>>> --- a/tools/perf/util/symbol.c >>>>> +++ b/tools/perf/util/symbol.c >>>>> @@ -1432,8 +1432,7 @@ int dso__load(struct dso *dso, struct map *ma= p, symbol_filter_t filter) >>>>> * Read the build id if possible. This is required for >>>>> * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work >>>>> */ >>>>> - if (is_regular_file(name) && >>>>> - filename__read_build_id(dso->long_name, build_id, BUILD_ID_SI= ZE) > 0) >>>>> + if (filename__read_build_id(dso->long_name, build_id, BUILD_ID_SI= ZE) > 0) >>>>> dso__set_build_id(dso, build_id); >>>> >>>> ouch copy&paste error.. we better fix it properly, >>>> could you please check attached patch? >>> >>> The use of uninitialized memory is gone, but the "--symfs" option is >>> ignored: >>> >>>> stat("/lib/libpthread-2.20.so", 0x7ffe440c1270) =3D -1 ENOENT (No su= ch file or directory) >>> >>> You'll look for the dso in the root file system not in the sysroot. >> >> that seems like unrelated to the 'use of uninitialized memory' issue, = right? >> I can't see how the patch I sent could do that.. >=20 > Right. That's a different issue. You can add my: >=20 > Acked-by: Marc Kleine-Budde I don't see this patch on mainline nor on linux-next, or am I missing something? Marc --=20 Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de | --gDQsncGE6Lf4790CwOgnP4k5DNQVHWaJh-- --HjJfxXgbgVGwvphnCukM4DQsM0BqhBucs Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBCgAGBQJXkHfcAAoJED07qiWsqSVqYiYH/14RIIHPcAtwieD6VTEtQF/x rDdzfVCHfrMdsstCYjA28nnqOYjvyfmli/5MshmSCXqLFdL/jroSPZuLrTN9uN5w vOZLDHraKx89i4RnGKZ3kfd2f9MTH+k4+lPbbSVCFNOM6puWqMyUiGFxcCkO4bDQ Cb4ZV4Wdz8P3B39o3KlU1OpZy1XTZiVB4B4rAGhX1eI+O2pYpbyTFHmi6YRFpnVn 0kDUuDTyCkw2T2asks6S9dD6DNW/gbSeWfyUDF35XV21Ir7vZAqc9UpLLODeJp4E T89y8ci7SE3NxpsR095nH8AZ8NF8plYB5Pj8Xh7hg10HrDOXt4gaQqGRXigRBcw= =dWgC -----END PGP SIGNATURE----- --HjJfxXgbgVGwvphnCukM4DQsM0BqhBucs--