linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jack Wang <jack.wang.usish@gmail.com>
To: Sasha Levin <sashal@kernel.org>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Vince Weaver <vincent.weaver@maine.edu>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH AUTOSEL 4.4 04/14] perf header: Fix divide by zero error if f_header.attr_size==0
Date: Mon, 19 Aug 2019 14:07:53 +0200	[thread overview]
Message-ID: <CA+res+RryNtrD3pydEn1G9HWnkDS780AaBEQQPNRqkx8rSzGJA@mail.gmail.com> (raw)
In-Reply-To: <20190806213749.20689-4-sashal@kernel.org>

Sasha Levin <sashal@kernel.org> 于2019年8月6日周二 下午11:39写道:
>
> From: Vince Weaver <vincent.weaver@maine.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@maine.edu>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Link: http://lkml.kernel.org/r/alpine.DEB.2.21.1907231100440.14532@macbook-air
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> Signed-off-by: Sasha Levin <sashal@kernel.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;

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
>

  reply	other threads:[~2019-08-19 12:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-06 21:37 [PATCH AUTOSEL 4.4 01/14] xtensa: fix build for cores with coprocessors Sasha Levin
2019-08-06 21:37 ` [PATCH AUTOSEL 4.4 02/14] xen/pciback: remove set but not used variable 'old_state' Sasha Levin
2019-08-06 21:37 ` [PATCH AUTOSEL 4.4 03/14] irqchip/irq-imx-gpcv2: Forward irq type to parent Sasha Levin
2019-08-06 21:37 ` [PATCH AUTOSEL 4.4 04/14] perf header: Fix divide by zero error if f_header.attr_size==0 Sasha Levin
2019-08-19 12:07   ` Jack Wang [this message]
2019-08-19 14:15     ` Jiri Olsa
2019-08-06 21:37 ` [PATCH AUTOSEL 4.4 05/14] perf header: Fix use of unitialized value warning Sasha Levin
2019-08-06 21:37 ` [PATCH AUTOSEL 4.4 06/14] libata: zpodd: Fix small read overflow in zpodd_get_mech_type() Sasha Levin
2019-08-06 21:37 ` [PATCH AUTOSEL 4.4 07/14] scsi: hpsa: correct scsi command status issue after reset Sasha Levin
2019-08-06 21:37 ` [PATCH AUTOSEL 4.4 08/14] exit: make setting exit_state consistent Sasha Levin
2019-08-06 21:37 ` [PATCH AUTOSEL 4.4 09/14] ata: libahci: do not complain in case of deferred probe Sasha Levin
2019-08-06 21:37 ` [PATCH AUTOSEL 4.4 10/14] kbuild: modpost: handle KBUILD_EXTRA_SYMBOLS only for external modules Sasha Levin
2019-08-06 21:37 ` [PATCH AUTOSEL 4.4 11/14] IB/core: Add mitigation for Spectre V1 Sasha Levin
2019-08-06 21:37 ` [PATCH AUTOSEL 4.4 12/14] ocfs2: remove set but not used variable 'last_hash' Sasha Levin
2019-08-06 21:37 ` [PATCH AUTOSEL 4.4 13/14] coredump: split pipe command whitespace before expanding template Sasha Levin
2019-08-06 21:37 ` [PATCH AUTOSEL 4.4 14/14] asm-generic: fix -Wtype-limits compiler warnings Sasha Levin
2019-08-19 16:53 ` [PATCH AUTOSEL 4.4 01/14] xtensa: fix build for cores with coprocessors Ben Hutchings
2019-08-19 17:06   ` Max Filippov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+res+RryNtrD3pydEn1G9HWnkDS780AaBEQQPNRqkx8rSzGJA@mail.gmail.com \
    --to=jack.wang.usish@gmail.com \
    --cc=acme@redhat.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vincent.weaver@maine.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).