Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8885063ybi; Tue, 23 Jul 2019 17:22:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/jOynKRtRuyAFktefS1ij+pg4aG2f1xPC6AZHp/Je6ht1O2NvRF0YGR0SfpD14JOzTH/d X-Received: by 2002:a17:902:2be8:: with SMTP id l95mr76775736plb.231.1563927760327; Tue, 23 Jul 2019 17:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563927760; cv=none; d=google.com; s=arc-20160816; b=Gw4ikvR1UGhj06oVuz7qXM2w69OeLxpuaX1SaS0DvCkMWbcAgE5d9soeFyaOUeT64c v5Ff7vJ39D3YMdBOVz0KJ03dsfcqyFXwxT/tn1K21MDG4wxqo50tY53WjRY6g5x9qr6t RvBL1LRrCskY3l7oD+7JI8/9ZBlcInNQvfsJEoqYdH3Dair6fUkLV7Gp3GBDcH1S45nJ Jxm89LzR7x+Oa7p8MYSu/N6KIun5kFiVXXpSv9HhoxSvwqAYvCqNnRL/ptlI0Ysc7Lgq nSq3dBpJ9VkO7zlOAu6pX4Gn6GeKcRiXBHc5rflzhWARrju46sw6BfEhz3Aq/KQG0rJh ty1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:date:from:dkim-signature; bh=aCAAdPR+vzZvbtfyN75VsMsViqAvyUvVOJJxgwLDuvQ=; b=qnMmtM300IdQIl1suwrW8sCzGcalFDM27js1qvPHAffpu8YOvXgd7ZSdWc+xVgxBoa 9LnYqndydMG1rJeCj5sdCwvt1kb5JQoyd+EfeM7khBnGcRLfxATHkNHXA5O2/xrDRysf nDxtqi/n3gk744CF+0l/5sVhXNluGW0L8PUdthw+91s2sJdeobeMKJ/mBazddW11v8sg sbBbRQJEIVHjiJUzlwkmLnVA9D8+cFrW4MWZSRFiUOf8CAKveLZ0m2+0lRouKp3FRiZd 2bcii6dNGyPZrEPbM0tfJbq476TePPH8DqQjT3mM/5JLIjkrvEx0bEIAtW568dCHVJbG YFGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@maine.edu header.s=google header.b=aXrN+CKA; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si12642834pgh.159.2019.07.23.17.22.24; Tue, 23 Jul 2019 17:22:40 -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=@maine.edu header.s=google header.b=aXrN+CKA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388532AbfGWPGH (ORCPT + 99 others); Tue, 23 Jul 2019 11:06:07 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:46021 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731767AbfGWPGH (ORCPT ); Tue, 23 Jul 2019 11:06:07 -0400 Received: by mail-qk1-f195.google.com with SMTP id s22so31384641qkj.12 for ; Tue, 23 Jul 2019 08:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maine.edu; s=google; h=from:date:to:cc:subject:message-id:user-agent:mime-version; bh=aCAAdPR+vzZvbtfyN75VsMsViqAvyUvVOJJxgwLDuvQ=; b=aXrN+CKA9Wne+VdWgteAfrggZb7XCWrZKmRzDn9qcSkxVnkxGR2A6tDBVMY/jcgYKv c6XJzZ8c19D3gaYAyeXCWH9aIJ3NUVFXrMsEtMusSz+IMaLp0vlrJ2OTMg7mlv8ztrmi MQCns1BkK7yjkrZMa59WVmRxf9ZaljT4HOF44= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:user-agent :mime-version; bh=aCAAdPR+vzZvbtfyN75VsMsViqAvyUvVOJJxgwLDuvQ=; b=Lh19J1g75w3dZJAsOlN9hPOyX0eWqDJMqM6VKeEGl8FP9TnXYLYcSmiFnoUPWCDHeR ovKoJTWy3TEjD3rk4UYeQeB8dduS/QjX31ebhZ0DXDZxi2nrbfrkGZmnotPR7Wdso1vy PivO2Sz+d6fAUnjK74C5Ur28G6X0GDHpsybY2EaouOe26TpY14hqbD/98nt0Ir/Ehho0 8rM2YpNkzetcO2lOurAFWFKG36bke9XtAtBvErNXgkLiohuWCFll0RqQvxpbeANnJyzN c5POWx2VgITOHWN4g6yb7qCB8ZEOmrTp9IhDdGmfFOGCCcpspgPS2NGkpN+13wjHpu+D yxFw== X-Gm-Message-State: APjAAAWPGcKSV1ZvPzbESCzgv+iT+7f9eNwtOVV5U32CL0fgQgUt2Lhl WNBkvzX91efxMNlnDVh+b1RORLU2n+0= X-Received: by 2002:a37:749:: with SMTP id 70mr50568757qkh.399.1563894365952; Tue, 23 Jul 2019 08:06:05 -0700 (PDT) Received: from macbook-air (weaver.eece.maine.edu. [130.111.218.23]) by smtp.gmail.com with ESMTPSA id r26sm18950094qkm.57.2019.07.23.08.06.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 23 Jul 2019 08:06:04 -0700 (PDT) From: Vince Weaver X-Google-Original-From: Vince Weaver Date: Tue, 23 Jul 2019 11:06:01 -0400 (EDT) X-X-Sender: vince@macbook-air To: linux-kernel@vger.kernel.org cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim Subject: [patch] perf tool divide by zero error if f_header.attr_size==0 Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello 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. Signed-off-by: Vince Weaver diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index c24db7f4909c..26df60ee9460 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -3559,6 +3559,10 @@ int perf_session__read_header(struct perf_session *session) data->file.path); } + if (f_header.attr_size == 0) { + return -EINVAL; + } + nr_attrs = f_header.attrs.size / f_header.attr_size; lseek(fd, f_header.attrs.offset, SEEK_SET);