Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp322214rdb; Mon, 18 Sep 2023 16:57:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJp9w4WFmZdvyjxdJKABM2qGK51VZrLGKZoFfqnxXcDKNgt8P0j29tO+99vEkq/Tswu6VU X-Received: by 2002:a05:6a20:a110:b0:13d:ee19:7727 with SMTP id q16-20020a056a20a11000b0013dee197727mr9592837pzk.18.1695081440549; Mon, 18 Sep 2023 16:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695081440; cv=none; d=google.com; s=arc-20160816; b=vAFiWGCBaNWXX63eJ554Z/kqUgzdAjpEbbcOLU+gdim3BiQdOhIpuKTMCtWG6/b32U wOh2ee1QwzQJVQstYPJudXWPfk0wUPeizYE3Fnks3dXwFVfcBqZ+XA8FF6zvlgn3xuh4 0DabdXCFlnHlXKmvh6QkhqE4xEpmFDNIpo6JMS1zftAI8tLW9ngUIUHREHQKolzZK0OM /6oyhQxBqphRsKjw6CIyrP3z+/jpzws8abxWxeHFKmWU5AyBfK41D/Q1LZPA+E1gAp8S keIQL8/XVk+0Km1ucKzPHsttJUbPzXVBUG1Y57bjuhJmHyiJmuCBQWg8FsDrUzYiwbxB N99w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=7RuwddHG39ULdl6HOOkmdnrDcr9c9ZqYkhHCX+epmyQ=; fh=5oP/1UXqGTJCn9EhtPaD4mnUJdzyrxl2TCHfeacTi9c=; b=TNNz+BV65jGXLKVkx8fJJSxRDSLoRZzKzYPGNlt7leRHfaRJmBrKSrDmje6aRt4OeP klmf5KYCynjgUQpN1ookWs2DVZv8BV3r20re6by+pEFghh4o79GmINGO6OO5sjg+tln7 cuYuK0yW/XRltpOr4N0HEIQKpZtxqCCJEgskuCGXiVw+XRf8bwuPrd3fX6gfzkEehR31 dFRZNlGToZaEMApGHaeDF5DZJlPeIzZpKsWiAmcfiqkY2e9uZnrqOPvIdsl5tTzZspvT H9Hg6xtn8ES3ODXG08LaS1DoqXBNiMyuXDUyF0gCCRafPmFLVXp+8UzTMWxacy6OvgQx ztOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j5-20020a170902da8500b001c57270c11fsi2344960plx.365.2023.09.18.16.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 16:57:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E5E07809E735; Mon, 18 Sep 2023 16:55:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230203AbjIRXz0 convert rfc822-to-8bit (ORCPT + 99 others); Mon, 18 Sep 2023 19:55:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjIRXz0 (ORCPT ); Mon, 18 Sep 2023 19:55:26 -0400 Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EAD190; Mon, 18 Sep 2023 16:55:20 -0700 (PDT) Received: by mail-io1-f41.google.com with SMTP id ca18e2360f4ac-76c64da0e46so197314939f.0; Mon, 18 Sep 2023 16:55:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695081319; x=1695686119; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=32Geyxo6Wez9nlnCFYhmzhhOce0/GBBaedRUh12+AWQ=; b=eNrCgjAUmeEIj7twHIZGxY4JubrMUMdsrLWjMhqfmhrFAc938GuTVS22J2O6Rf33mD IywOJnYjDvpKJOnMQCIh3QSTcBMg6EMJk2YPtzptniL9bgz5ctrhBJOBJYrQuQhMLrT2 tlKsyJugKwruv+WhPK7575yK/DIsWWDI3uK5IOW3e+bLX+tyz2QL9ITnkE4McQ5FjVZ9 cZmE2RBXLoPIPjslazcWaQgsCOORKFp0xKm1FNfc54Bcfrs6JkZlck90UNX3dmUu6QoW 5YSqd5BAF6rtJyN/5Cq8YCxAy3h7y6tiyrQayh/jYxJKmGPr8wF6PoW6AZ8L294H5VbF 4aYQ== X-Gm-Message-State: AOJu0Yy45BwIFf9rU30/zD7yUPUvMGrHqvJuLjHeh7EMZnGZ6nTqgih2 +bYjOcXrV7Mpf2a11liX5D5uZbrAXPCGHOIxEIk= X-Received: by 2002:a5d:84c5:0:b0:790:f866:d71b with SMTP id z5-20020a5d84c5000000b00790f866d71bmr10706784ior.13.1695081319684; Mon, 18 Sep 2023 16:55:19 -0700 (PDT) MIME-Version: 1.0 References: <20230918030304.24832-1-yangjihong1@huawei.com> In-Reply-To: <20230918030304.24832-1-yangjihong1@huawei.com> From: Namhyung Kim Date: Mon, 18 Sep 2023 16:55:08 -0700 Message-ID: Subject: Re: [PATCH] perf jevents: Fix segfault in perf_pmu__find_events_table To: Yang Jihong Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 18 Sep 2023 16:55:29 -0700 (PDT) Hello, On Sun, Sep 17, 2023 at 8:05 PM Yang Jihong wrote: > > Before caching the JSON events table, perf_pmu__find_events_table() need > to check whether table is empty. > > For example, AuthenticAMD-15-6B-1 is used. The matching events table cannot > be found. As a result, a null pointer is accessed when caching JSON events > table, causing segfault. > > Before: > # perf record -vv true > DEBUGINFOD_URLS= > Using CPUID AuthenticAMD-15-6B-1 > Segmentation fault (core dumped) > > After: > # perf record -vv true > DEBUGINFOD_URLS= > Using CPUID AuthenticAMD-15-6B-1 > > [ perf record: Woken up 1 times to write data ] > [ perf record: Captured and wrote 0.005 MB perf.data ] > > Fixes: 7c52f10c0d4d ("perf pmu: Cache JSON events table") > Signed-off-by: Yang Jihong Thanks for the fix but please see https://lore.kernel.org/all/20230913125157.2790375-1-tmricht@linux.ibm.com/ Thanks, Namhyung > --- > tools/perf/pmu-events/jevents.py | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py > index a7e88332276d..72ba4a9239c6 100755 > --- a/tools/perf/pmu-events/jevents.py > +++ b/tools/perf/pmu-events/jevents.py > @@ -991,7 +991,7 @@ const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu) > } > } > free(cpuid); > - if (!pmu) > + if (!pmu || !table) > return table; > > for (i = 0; i < table->num_pmus; i++) { > -- > 2.34.1 >