[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190819141540.GC9637@krava>
Date: Mon, 19 Aug 2019 16:15:40 +0200
From: Jiri Olsa <jolsa@...hat.com>
To: Jack Wang <jack.wang.usish@...il.com>
Cc: Sasha Levin <sashal@...nel.org>, linux-kernel@...r.kernel.org,
stable@...r.kernel.org, Vince Weaver <vincent.weaver@...ne.edu>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Namhyung Kim <namhyung@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Arnaldo Carvalho de Melo <acme@...hat.com>
Subject: Re: [PATCH AUTOSEL 4.4 04/14] perf header: Fix divide by zero error
if f_header.attr_size==0
On Mon, Aug 19, 2019 at 02:07:53PM +0200, Jack Wang wrote:
> Sasha Levin <sashal@...nel.org> 于2019年8月6日周二 下午11:39写道:
> >
> > From: Vince Weaver <vincent.weaver@...ne.edu>
> >
> > [ Upstream commit 7622236ceb167aa3857395f9bdaf871442aa467e ]
> >
> > So I have been having lots of trouble with hand-crafted perf.data files
> > causing segfaults and the like, so I have started fuzzing the perf tool.
> >
> > First issue found:
> >
> > If f_header.attr_size is 0 in the perf.data file, then perf will crash
> > with a divide-by-zero error.
> >
> > Committer note:
> >
> > Added a pr_err() to tell the user why the command failed.
> >
> > Signed-off-by: Vince Weaver <vincent.weaver@...ne.edu>
> > Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
> > Cc: Jiri Olsa <jolsa@...hat.com>
> > Cc: Namhyung Kim <namhyung@...nel.org>
> > Cc: Peter Zijlstra <peterz@...radead.org>
> > Link: http://lkml.kernel.org/r/alpine.DEB.2.21.1907231100440.14532@macbook-air
> > Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
> > Signed-off-by: Sasha Levin <sashal@...nel.org>
> > ---
> > tools/perf/util/header.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> Hi all,
>
> This on cause build failure when I rebased to 4.14.140-rc1 in stable-rc tree.
>
> util/header.c: In function 'perf_session__read_header':
> util/header.c:2907:10: error: 'data' undeclared (first use in this
> function); did you mean 'dots'?
> data->file.path);
> Should be fixed by:
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -2904,7 +2904,7 @@ int perf_session__read_header(struct
> perf_session *session)
> if (f_header.attr_size == 0) {
> pr_err("ERROR: The %s file's attr size field is 0
> which is unexpected.\n"
> "Was the 'perf record' command properly terminated?\n",
> - data->file.path);
> + file->path);
> return -EINVAL;
seems as good fix for 4.4, we took following commit in 4.15:
eae8ad8042d8 perf tools: Add struct perf_data_file
that added the file layer
jirka
>
> Regards,
> Jack Wang
>
> > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> > index 304f5d7101436..0102dd46fb6da 100644
> > --- a/tools/perf/util/header.c
> > +++ b/tools/perf/util/header.c
> > @@ -2591,6 +2591,13 @@ int perf_session__read_header(struct perf_session *session)
> > file->path);
> > }
> >
> > + if (f_header.attr_size == 0) {
> > + pr_err("ERROR: The %s file's attr size field is 0 which is unexpected.\n"
> > + "Was the 'perf record' command properly terminated?\n",
> > + data->file.path);
> > + return -EINVAL;
> > + }
> > +
> > nr_attrs = f_header.attrs.size / f_header.attr_size;
> > lseek(fd, f_header.attrs.offset, SEEK_SET);
> >
> > --
> > 2.20.1
> >
Powered by blists - more mailing lists