From nobody Mon Feb 9 06:25:27 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D284C7EE2F for ; Wed, 7 Jun 2023 01:46:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240673AbjFGBqO (ORCPT ); Tue, 6 Jun 2023 21:46:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240571AbjFGBoo (ORCPT ); Tue, 6 Jun 2023 21:44:44 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E1381BC8 for ; Tue, 6 Jun 2023 18:44:43 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-565a33c35b1so102597737b3.0 for ; Tue, 06 Jun 2023 18:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686102282; x=1688694282; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=h5i/HcXWZK6yNAnvq9kN2ruEXhS3nctm8EhXDDQYxW0=; b=t7gIuC7RMSZxifslee8OkIZwaZvgm8eHWrgQsoRbPEqRSzohhLm5euXvuOaHTMGjTW ZQClMPQyMlfx1RwmBzKAQvCsfJOaqsVeBK4ngDOTz1Eh7sRrslTD4+9cNSM5YFstL4p6 Pfeqp3G0SF2J6BRCKSbjLoM158ia7k30ps3q/fyd+LAg9RF5185Ion/Z4bs6ke9rs8uI IhpznhPojPzY9Eyow9Ff4Jirl7l6AC6o9kttvqYEZsjSu2XeB9liT7TWhpi/47lQHrP1 Hw31TFt/y9n9bOl+SCCVm82dnuV+Yku5+kXZX0GNKqtGjMFHVVckk0jUGtRvSVOO2KX0 RpDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686102282; x=1688694282; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h5i/HcXWZK6yNAnvq9kN2ruEXhS3nctm8EhXDDQYxW0=; b=f7Sww3I03s70HIUPKpAgYGgQKt8Z5drZiSsasNnHtoQ3h1ruQTHheZaHcbiTp2PA1i ns1agbTPqOddLKmILs3CndP542Be/WnqcvGqKeCiuxenHmbT8Kqd8MMxKCB996uy/SlV trgChZq2kbhE0LwG9Kaa7Tuk2aJBKBzyxzl3Xxmp5WhBvR/jCzUQuGPVTtdzs4ajWY/I HzqIriOHa+Cubzn5iEaAq/W50hAvQ+mEmvMnbzk8IeyQ01u1bE++rC5Ze0+flvSrccw5 PHDWZy9kjmcQ79P5JrItBXMDP7V7ZGc6Rl8c+XaS9/c8C7ZX9pVx5RGeITRp90qedD/M BUVQ== X-Gm-Message-State: AC+VfDwKwcPKjiKibyXYlmDKxzIaFFAtCDHQdJej42iffcnzfcjCaPBd WOTF6ziOeqFct+j9dCfuEGM+O2ai3ols X-Google-Smtp-Source: ACHHUZ6sXa4pQEp7493QMMx/+lFm2yYaX/H67xkftwZIrCy4G77CgeVMKsJI+bSIONd37E/2O8+CJYx/NMxP X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:3c35:209f:5d38:b7a1]) (user=irogers job=sendgmr) by 2002:a81:ac57:0:b0:565:9bee:22e0 with SMTP id z23-20020a81ac57000000b005659bee22e0mr2032744ywj.0.1686102282285; Tue, 06 Jun 2023 18:44:42 -0700 (PDT) Date: Tue, 6 Jun 2023 18:43:47 -0700 In-Reply-To: <20230607014353.3172466-1-irogers@google.com> Message-Id: <20230607014353.3172466-15-irogers@google.com> Mime-Version: 1.0 References: <20230607014353.3172466-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Subject: [PATCH v1 14/20] perf python: Avoid 2 leak sanitizer issues From: Ian Rogers To: John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Suzuki K Poulose , "Naveen N. Rao" , Kan Liang , German Gomez , Ali Saidi , Jing Zhang , "=?UTF-8?q?Martin=20Li=C5=A1ka?=" , Athira Rajeev , Miguel Ojeda , ye xingchen , Liam Howlett , Dmitrii Dolgov <9erthalion6@gmail.com>, "Shawn M. Chapla" , Yang Jihong , K Prateek Nayak , Changbin Du , Ravi Bangoria , Sean Christopherson , Raul Silvera , Andi Kleen , "Steinar H. Gunderson" , Yuan Can , Brian Robbins , liuwenyu , Ivan Babrou , Fangrui Song , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, coresight@lists.linaro.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Leak sanitizer complains about the variable size bf allocation and store to bf if sized 0. Signed-off-by: Ian Rogers --- tools/perf/util/scripting-engines/trace-event-python.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools= /perf/util/scripting-engines/trace-event-python.c index 6b89eec98dd7..59944fef8108 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -735,6 +735,9 @@ static void regs_map(struct regs_dump *regs, uint64_t m= ask, const char *arch, ch unsigned int i =3D 0, r; int printed =3D 0; =20 + if (size <=3D 0) + return; + bf[0] =3D 0; =20 if (!regs || !regs->regs) @@ -764,7 +767,7 @@ static void set_regs_in_dict(PyObject *dict, * 10 chars is for register name. */ int size =3D __sw_hweight64(attr->sample_regs_intr) * 28; - char bf[size]; + char *bf =3D malloc(size); =20 regs_map(&sample->intr_regs, attr->sample_regs_intr, arch, bf, sizeof(bf)= ); =20 @@ -775,6 +778,7 @@ static void set_regs_in_dict(PyObject *dict, =20 pydict_set_item_string_decref(dict, "uregs", _PyUnicode_FromString(bf)); + free(bf); } =20 static void set_sym_in_dict(PyObject *dict, struct addr_location *al, --=20 2.41.0.rc0.172.g3f132b7071-goog