Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp861685pxk; Thu, 1 Oct 2020 16:08:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjQTx+40ZDCDzVOangD5Ja80v+831KXAWIO+scAnV1/22w16IF8QQXuS9Ly1ZB8whxu0Lt X-Received: by 2002:aa7:d8d8:: with SMTP id k24mr10614973eds.97.1601593704119; Thu, 01 Oct 2020 16:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601593704; cv=none; d=google.com; s=arc-20160816; b=FXvdcEEftQ46FMR2zUvTGo0/wAcoglonG0AE0OyV545fLpPD5JQ4tV/qPY+aKocGsR SxHQYu0YvIyRwJ9wQpYMC+WFKgsr6B0RplUK2zgoxtAqrO+zcNvWnxIx8WK1O9wK6K8D KMiK8wiMDM2ilvXU2JbfV3CR7lGD35UrW7h6t6fXyXEYKFM9chCVCWs1quD2y46MpTTi 0yJ7lmrADB+xBwMnit6tR+JsHz0ZNoalVbXmqa8zdOMUUXJX3gexKt1I1hT6X1b44rTQ KjPRgLLFm+azmH7STjlrzwSAgVSIfiozKp203Zp7o4sGrOhLPylyTlFmO6jVHKIy3zoA tYPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=7qqhiWkLlM0tM7DYdLYQBrHFuDrdYLOVQTgHWF3W0G4=; b=LHkRCxwcnHTFzKMyvwvqoNb1bgdXw7Hk6bSb4Iu6ehJBrB9mxzPq0FZWWc+TC48v9c oCoa55etStlcvfAkHEl1ebfleJ8fMYxLg4ZQRbxxASvfK0GPCL7RJLUFo5NFcib0g/k9 1OC+kblqAAAqR3x2Y1dvd/Q0dr0GGFNTPOQTOHwdC/YBKOTeEvM45Rw8FbOWqy25k3it tsl3h3XDeMt4uLHC/lkE1iSChZqEzpFos/EbKI5F4aW6roX/W/9lUQmGyWEllm02ioBF PS3ZnT7cYarKG1wwXA8dT+IsYv+kyb9MA1v23bXoMenJcfjxnJHDoEsV0C/6XqBAYp63 DKEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o15si4503091ejb.225.2020.10.01.16.08.02; Thu, 01 Oct 2020 16:08:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731525AbgJAXG4 (ORCPT + 99 others); Thu, 1 Oct 2020 19:06:56 -0400 Received: from mga09.intel.com ([134.134.136.24]:38805 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726855AbgJAXG4 (ORCPT ); Thu, 1 Oct 2020 19:06:56 -0400 IronPort-SDR: OT8YfXpzyf5Qfi1c7KCC2i61+pnCItzBXzFZgeq5h39FTFIt9DdACRrTLXunplFGS3NBUvX1f9 +AuyxMfsLYfg== X-IronPort-AV: E=McAfee;i="6000,8403,9761"; a="163716412" X-IronPort-AV: E=Sophos;i="5.77,325,1596524400"; d="scan'208";a="163716412" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2020 16:06:55 -0700 IronPort-SDR: uk+/ERHnTqAoNL6znz+qxeGNeHZ7ZAsPkcbsIadHN2V8DfCG2Sjj2FXP1jqpxYui4/5YAg15AR x1stSN17pswQ== X-IronPort-AV: E=Sophos;i="5.77,325,1596524400"; d="scan'208";a="346250726" Received: from tassilo.jf.intel.com ([10.54.74.11]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2020 16:06:54 -0700 Date: Thu, 1 Oct 2020 16:06:53 -0700 From: Andi Kleen To: Barry Song Cc: linux-kernel@vger.kernel.org, linuxarm@huawei.com, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Alexey Budankov Subject: Re: [PATCH] perf evlist: fix memory corruption for Kernel PMU event Message-ID: <20201001230653.GM50079@tassilo.jf.intel.com> References: <20201001115729.27116-1-song.bao.hua@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201001115729.27116-1-song.bao.hua@hisilicon.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 02, 2020 at 12:57:29AM +1300, Barry Song wrote: > Commit 7736627b865d ("perf stat: Use affinity for closing file > descriptors") will use FD(evsel, cpu, thread) to read and write > file descriptors xyarray. For a kernel PMU event, this leads to > serious memory corruption and perf crash. > I have seen evlist->core.cpus->nr is 1 while evsel has cpus->nr > with the total number of CPUs. so xyarray which is allocated by > evlist->core.cpus->nr will get overflow. This leads to various > segmentation faults in perf tool for kernel PMU events, eg: > ./perf stat -e bus_cycles sleep 1 > *** Error in `./perf': free(): invalid next size (fast): 0x00000000401e6370 *** > Aborted (core dumped) Thanks. I believe there is already a patch queued for this. The problem seems to only happen on ARM64. -Andi