Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2621320ybl; Mon, 19 Aug 2019 05:09:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxX7OKM+DzVUc1qcfgG3czwdkTD9v0SWuZjnuIiYGJKS8bA895/JcFHWoOwKxU9bALOvKyB X-Received: by 2002:a63:7d05:: with SMTP id y5mr19750932pgc.425.1566216563861; Mon, 19 Aug 2019 05:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566216563; cv=none; d=google.com; s=arc-20160816; b=jy1/loFyUPyTforSEQYlAvcVcLkXqnJl5FRwp3ymu4PVDhrHmwD6+wOGGExIjFa17L WixCo9kASUS/8o8+ZiXfGXghRuNgsaHnfGjV7EuA8iyXiAyb14DdGkDV1WtDqLaeDGlM 2mIe465SBlPBTkSduGIh38FP2hkRH+FdgEvuWECJLaRvxfe4vxifUcXXVz2ArCcerIwF mW2VDFfPpoVlXeczqq6RWnSSjYY+XibowttiJpzXkA5DQ0WtfBzZ/sJctVlWwyccglv0 FJgeV5c/YanrCm4KmbtYlTld6pX4H/oAPZoNkBevBpUsx9hOV3iSlUxOzLyWDEvO1Zpi lEiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=FjHZhaVZ8bW1jwSB163zu6P8fnlh+RcprWunL1wBQ1c=; b=kB6zeq92WTgez9i1k+vwf0rm6m0Q8ic1FptKq2bOYwqnvX/u2yNkqAaxBXsWT5mqvT anLgxsKT1QQfNLnzEIVflDXaKHfE25igoLbT9LIVIPrMQlgT5s84430lnQsF/3f+elsv bdHBMVicEJ8v958xMn892AG7WlEUlgsK7DhYWAzSyoyBo2RCmTZbCp6kAe8SfUHEmkIJ wXWUfNFWYWzXcvTLG2u1zzUllYBNpG+qInC+UTUAkHY5yOZ5aV/caT3mmvcrhGqeAN98 DGV+x6Jsg4q/6YaRM7q+3lNh8RItY72ur32drm2mcplpX/8eTIFV2aoOJXFyUJtLaPIK dlTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Gkji77Uw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x11si9651102pll.343.2019.08.19.05.09.08; Mon, 19 Aug 2019 05:09:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Gkji77Uw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727445AbfHSMIH (ORCPT + 99 others); Mon, 19 Aug 2019 08:08:07 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45181 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbfHSMIG (ORCPT ); Mon, 19 Aug 2019 08:08:06 -0400 Received: by mail-lf1-f66.google.com with SMTP id a30so1199744lfk.12; Mon, 19 Aug 2019 05:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=FjHZhaVZ8bW1jwSB163zu6P8fnlh+RcprWunL1wBQ1c=; b=Gkji77UwvlMoaD82M8Tkxq7u5atgOhMiRrvbSXAW/ctANbqwfsTil2IW1aUdIVsGNq f8AaA6O8pkydKpWnJSswVSqJTL2iMWJYbljS8O3ZmXMNjYg1cn2FdLHIsSKZTJxtx/+5 HGf8JEOZaDQDQWCO2MqAQ/p26IGwpwUftMKLmEM85NSWVkWY62Os2EngceVVbeWu8Ir4 aot76mAr603G5SXCTamEjy/BW3sLDo5M5PPdHCNC7dbXO+ZqU1ZepzzPMqJMvvISbTj7 US6fNAA8KVLy3DYLe3CW5yEZzsbzsD+sVk2/QWXK6vr0KKzKMmMQK+XE83N6OOS6t/jO ShDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=FjHZhaVZ8bW1jwSB163zu6P8fnlh+RcprWunL1wBQ1c=; b=RXlD7YcjlZPh3BdWuTukY29ZGxy9QBf9vCbrmRJmluM5/DAG6LpnLgxcr45yA0qvmo bZZrcv4Odge5jLm77saqCzqbTNo1NzH8mEacQLicxtkjaS+4HMh8P2PQK0lS143wrv3F cffAyxZmoD8B1IRRgQhtN+cfVnOmY3kbkO2UTgAmS3jwjKGO04jQzylqEf7kvgo9e+7D F2zhY3xV5Y+EGUw8KOdkWbVoJGZzQRD9CWrQwe0yHgApBvO1yKqNMmef9J2VrXgKzL6B zQeiYYwFvZc1MaPTaAqAZnDee4n2o7BOdqYWT8x9StFjueV5BQe1aYpMckg7ZXONIJz2 +wiw== X-Gm-Message-State: APjAAAXjWrC8KXafmiUB8zNgfH43KKmxJV4Zo9MCVQQA3E7uXqjYEuP6 YMrdRnSnFDJp54vwgLog0uErS+9bd88IgWyIh6A= X-Received: by 2002:ac2:46ea:: with SMTP id q10mr11746594lfo.118.1566216484462; Mon, 19 Aug 2019 05:08:04 -0700 (PDT) MIME-Version: 1.0 References: <20190806213749.20689-1-sashal@kernel.org> <20190806213749.20689-4-sashal@kernel.org> In-Reply-To: <20190806213749.20689-4-sashal@kernel.org> From: Jack Wang Date: Mon, 19 Aug 2019 14:07:53 +0200 Message-ID: Subject: Re: [PATCH AUTOSEL 4.4 04/14] perf header: Fix divide by zero error if f_header.attr_size==0 To: Sasha Levin Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Vince Weaver , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sasha Levin =E4=BA=8E2019=E5=B9=B48=E6=9C=886=E6=97=A5= =E5=91=A8=E4=BA=8C =E4=B8=8B=E5=8D=8811:39=E5=86=99=E9=81=93=EF=BC=9A > > From: Vince Weaver > > [ 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 > Cc: Alexander Shishkin > Cc: Jiri Olsa > Cc: Namhyung Kim > Cc: Peter Zijlstra > Link: http://lkml.kernel.org/r/alpine.DEB.2.21.1907231100440.14532@macboo= k-air > Signed-off-by: Arnaldo Carvalho de Melo > Signed-off-by: Sasha Levin > --- > 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 tre= e. 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 =3D=3D 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 =3D=3D 0) { > + pr_err("ERROR: The %s file's attr size field is 0 which i= s unexpected.\n" > + "Was the 'perf record' command properly terminated= ?\n", > + data->file.path); > + return -EINVAL; > + } > + > nr_attrs =3D f_header.attrs.size / f_header.attr_size; > lseek(fd, f_header.attrs.offset, SEEK_SET); > > -- > 2.20.1 >