Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2768965ybl; Mon, 19 Aug 2019 07:16:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqycIYV18mx8CPdhq3y7ER6BU1CZ+pF3FZk4ffRS06UdFo99w6KG4xTXlwgMXI1OYnuvy3Yb X-Received: by 2002:a63:36cc:: with SMTP id d195mr19879514pga.157.1566224215998; Mon, 19 Aug 2019 07:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566224215; cv=none; d=google.com; s=arc-20160816; b=f4bfDDyWe2UIMuJa/bf7P8uGCZ4yQM4/kpsO2Y+oYriMwb6cXy2/nS+AsitPky7EOy C/eBj92z+iFNwAuWH/VGgzzTAWbUIKXSdDdMI6gY1hcK+IvfnfW1yIXWTwRpm145NQQN tpe4L/3bEMNXorLiK7sZ6s1Ne3j/ChzxZzIadK7gEjLB0kU36SZ+TeIxnBtgV2u+eefo vwTFK1Ia5+jJm0PvKt/mHDeESbVlaQRa8CZ8bYJ/7GcISAWU3szkrB1DCSvCoOx4ywha OcwkCmafRE7I8oXzNlspNO8G7fuAHbf6S5QsIAEZFON3ewnzCY5f8vUfysNicVluATwB DZtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=t3Pvg8pXCaNeUutv1NUKtlrmoJhd7bkgJbc4s3cW7k8=; b=IndTNXOHOpSdiz3C5z8CbMRu7s+EvPlk966w5xmlRaaW4vgsyD3cGIeLND+bCTGaq/ wDa/NXA+o9O98McZlqbvjbDxrsp8LpuwsODYwm9cxh8L/OybPCDi1xxtUh8RRLJZZ4zb 7GGQPXOfM3QIad8XkhCCdpG7S3UXbUATHExTtbQTlQTtjHHxqzbXUsnuaSXaulxqZGGK e295FFMuiZfK8bIXq0oWr4hwsQ7DnEca8++X76U7pvLO53dkYl/eHGJa7fUTzngn7tRj yDdXk0ovGBJ7DNEQXGO+FhqEaGKK7PQnRZy1ens4K9jvMORTm7Y/602w3MQKXVMWoBLF diZw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6si10340176pgs.333.2019.08.19.07.16.40; Mon, 19 Aug 2019 07:16:55 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727172AbfHSOPp (ORCPT + 99 others); Mon, 19 Aug 2019 10:15:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11932 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726751AbfHSOPp (ORCPT ); Mon, 19 Aug 2019 10:15:45 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD5433A20F; Mon, 19 Aug 2019 14:15:44 +0000 (UTC) Received: from krava (unknown [10.43.17.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07983831A3; Mon, 19 Aug 2019 14:15:40 +0000 (UTC) Date: Mon, 19 Aug 2019 16:15:40 +0200 From: Jiri Olsa To: Jack Wang Cc: Sasha Levin , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Vince Weaver , Alexander Shishkin , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: Re: [PATCH AUTOSEL 4.4 04/14] perf header: Fix divide by zero error if f_header.attr_size==0 Message-ID: <20190819141540.GC9637@krava> References: <20190806213749.20689-1-sashal@kernel.org> <20190806213749.20689-4-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 19 Aug 2019 14:15:45 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 19, 2019 at 02:07:53PM +0200, Jack Wang wrote: > Sasha Levin 于2019年8月6日周二 下午11:39写道: > > > > 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@macbook-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 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 > >