From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751565AbcFXL5E (ORCPT ); Fri, 24 Jun 2016 07:57:04 -0400 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:41183 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750966AbcFXL5B (ORCPT ); Fri, 24 Jun 2016 07:57:01 -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> Cc: Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, Jiri Olsa From: Marc Kleine-Budde Message-ID: <2ca568c2-e6b7-fb0d-48bb-80aa3daefc98@pengutronix.de> Date: Fri, 24 Jun 2016 13:56:25 +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: <20160624115112.GD10142@krava> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2JMUIBS2IkiD5tJKOOsiH5Dsxqgu8GDAf" 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) --2JMUIBS2IkiD5tJKOOsiH5Dsxqgu8GDAf Content-Type: multipart/mixed; boundary="PhLnDffG07029nOA0WUoJ8PAjaAjv2GGN" From: Marc Kleine-Budde To: Jiri Olsa Cc: Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, Jiri Olsa Message-ID: <2ca568c2-e6b7-fb0d-48bb-80aa3daefc98@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> In-Reply-To: <20160624115112.GD10142@krava> --PhLnDffG07029nOA0WUoJ8PAjaAjv2GGN Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 uninitiali= sed 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.= c: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 (machine= =2Ec:1958) >>>> =3D=3D24515=3D=3D by 0x441B3E: process_event (builtin-script.c:79= 5) >>>> =3D=3D24515=3D=3D by 0x441B3E: process_sample_event (builtin-scri= pt.c:920) >>>> =3D=3D24515=3D=3D by 0x4BEE29: perf_evlist__deliver_sample (sessi= on.c:1192) >>>> =3D=3D24515=3D=3D by 0x4BEE29: machines__deliver_event (session.c= :1229) >>>> =3D=3D24515=3D=3D by 0x4BF770: perf_session__deliver_event (sessi= on.c:1286) >>>> =3D=3D24515=3D=3D by 0x4BF770: ordered_events__deliver_event (ses= sion.c:114) >>>> =3D=3D24515=3D=3D by 0x4C1D17: __ordered_events__flush (ordered-e= vents.c:207) >>>> =3D=3D24515=3D=3D by 0x4C1D17: ordered_events__flush.part.3 (orde= red-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 (sessi= on.c:1451) >>>> =3D=3D24515=3D=3D Address 0x807c6a0 is 0 bytes inside a block of si= ze 4,096 alloc'd >>>> =3D=3D24515=3D=3D at 0x4C29C0F: malloc (in /usr/lib/valgrind/vgpr= eload_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.= c: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 (machine= =2Ec:1958) >>>> =3D=3D24515=3D=3D by 0x441B3E: process_event (builtin-script.c:79= 5) >>>> =3D=3D24515=3D=3D by 0x441B3E: process_sample_event (builtin-scri= pt.c:920) >>>> =3D=3D24515=3D=3D by 0x4BEE29: perf_evlist__deliver_sample (sessi= on.c:1192) >>>> =3D=3D24515=3D=3D by 0x4BEE29: machines__deliver_event (session.c= :1229) >>>> =3D=3D24515=3D=3D by 0x4BF770: perf_session__deliver_event (sessi= on.c:1286) >>>> =3D=3D24515=3D=3D by 0x4BF770: ordered_events__deliver_event (ses= sion.c:114) >>>> =3D=3D24515=3D=3D by 0x4C1D17: __ordered_events__flush (ordered-e= vents.c:207) >>>> =3D=3D24515=3D=3D by 0x4C1D17: ordered_events__flush.part.3 (orde= red-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 (sessi= on.c:1451) >>>> =3D=3D24515=3D=3D by 0x4C0EAC: __perf_session__process_events (se= ssion.c:1804) >>>> =3D=3D24515=3D=3D by 0x4C0EAC: perf_session__process_events (sess= ion.c:1858) >>>> >>>> This patch fixes the problem by removing the check. >>>> >>>> Fixes: 403567217d3f perf symbols: Do not read symbols/data from devi= ce 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 *map= , 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_SIZ= E) > 0) >>>> + if (filename__read_build_id(dso->long_name, build_id, BUILD_ID_SIZ= E) > 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 suc= h file or directory) >> >> You'll look for the dso in the root file system not in the sysroot. >=20 > that seems like unrelated to the 'use of uninitialized memory' issue, r= ight? > I can't see how the patch I sent could do that.. Right. That's a different issue. You can add my: Acked-by: Marc Kleine-Budde thanks, 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 | --PhLnDffG07029nOA0WUoJ8PAjaAjv2GGN-- --2JMUIBS2IkiD5tJKOOsiH5Dsxqgu8GDAf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBCgAGBQJXbR/rAAoJED07qiWsqSVquXIH/i8F7TnPX0AKZXNA9Ag6yppI Y0rOs6HWMx0Xi+GACsUIHv+OYGWvvhEulgtQBqBwTs9lO89b/tMNOvrUneJO1cMb 1jISQwVmqB81oUjXVzYvBLPzyDynoEcjtHQbBaph3pSF0fl7h3Gru2Jzicb4RMft XPlhwH7GEM0PNenvx5WsYPiz20cT2/o8LVPN6CzIS6YwZoAEOnu2XM9AH9vI0Xf6 6EOG7TdxzTk+MBBHMR+/nYWrZd30M6vBp8umo/HcQY/efefX+kP2hPkxLlqeIxcP 2wUA99VqYWb3ifnqtKcsu2g1uuz3mW6fGiGK/T9vkR6UCGPrKp1AD7YPQ5/Vb4Q= =+f0o -----END PGP SIGNATURE----- --2JMUIBS2IkiD5tJKOOsiH5Dsxqgu8GDAf--