[PATCHv2 01/61] perf symbols: Do not open device files

From: Jiri Olsa
Date: Tue Sep 20 2016 - 12:13:18 EST


On Tue, Sep 20, 2016 at 05:36:47PM +0200, Jiri Olsa wrote:
> On Tue, Sep 20, 2016 at 12:28:03PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Mon, Sep 19, 2016 at 03:09:10PM +0200, Jiri Olsa escreveu:
> > > Moving the regular file check into the entry
> > > of the dso__read_binary_type_filename function.
> > >
> > > This way we can eliminate some calls and extend
> > > the file check for all cases.
> >
> > Bzzt:
> >
> > [root@jouet ~]# perf test "Test dso"
> > 8: Test dso data read : FAILED!
> > 9: Test dso data cache : FAILED!
> > 10: Test dso data reopen : FAILED!
> > [root@jouet ~]#
>
> ugh, will check.. thanks

ook, I confused this one with earlier version, sry.. correct version attached
it's pushed in the perf/c2c branch now

thanks,
jirka


---
The dso__read_binary_type_filename gets the dso's file name
to open. We need to check it for regular file before trying
to open it, otherwise we might get stuck with device file.

Link: http://lkml.kernel.org/n/tip-twbp391v8v9f5idp584hlfov@xxxxxxxxxxxxxx
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/util/dso.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 774f6ec884d5..d2c6cdd9d42b 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -363,6 +363,9 @@ static int __open_dso(struct dso *dso, struct machine *machine)
return -EINVAL;
}

+ if (!is_regular_file(name))
+ return -EINVAL;
+
fd = do_open(name);
free(name);
return fd;
--
2.7.4