Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4184017pxk; Tue, 8 Sep 2020 12:54:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb6MXGa7wqz7KRIcftmGfsrrCggbnP+XMOl5g8eXvlKSa+CiwVqJ350qgLeJZKKznb5JRq X-Received: by 2002:aa7:c98d:: with SMTP id c13mr690387edt.199.1599594840566; Tue, 08 Sep 2020 12:54:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599594840; cv=none; d=google.com; s=arc-20160816; b=VHF/0Kd63ko+bDbQYdbIcyO5kfVAGCD95r+laZrgI7gwgdkM2ZYOyo+CnWdPpCR2CP di0ZaGbNdOI+L9qrDrEXQsi9O6UsdrsZ9OqZNwnhP6mUO4b2FEk1obWN/Jsc6Njv9NTj unMPvfTDUnC0KkSaoQfWkjq4+4YUnedS0TDSVwgbLdLBbJ9iW3OVEZXqN8OjOxEVlS9v Iaoka/o1eaKexw5YLDHqme2DBGgDF/82u+nPyyeZdbn4bapT73VOcsVs8jEvywRZ6m7s 3C/myGZWqqBnfJWvM0A0d80c/grJlgEgC6wvnlP3rbQtcmFNQRoBcpRcJRa4Y9QxvOpc M1OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KB6qg14NDN5gldKGtDvfqYDdXDxRs0yvNDGky/mEIH4=; b=aZ6M4pZEafq+5kOJKSE7jldEzzgrj9myyTtkA89TWrWmkGNVgEYUxQeXFLSQQBsA7+ m1Qm8yCdIeWykqjdRrdDORn1JNJvmDrqFMtwLmEWzlI3mLCZ1EjUWeDRzHvjHIdG6anh mbEiWAQT+/kMDLHW3q0Da3cMQvuIXdLVsYy8bUiDQOmmEsgsosisrkaOnbbbYlLu6Tig UnLp2tVZWdXBcYuRvfX1k8XlU3wsSOmtxAKDYPNGeJtYYjZ9cUNpTx/zJZLvZbCuVOVw XeI7fRPz7xctGluTXug0PfvcHIUAkhP+j1PDEGjXT00mlzEP+RecGhCgp5w5bu7a3/BN MdrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=F6pgKb6y; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j14si61578edy.412.2020.09.08.12.53.37; Tue, 08 Sep 2020 12:54:00 -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; dkim=pass header.i=@kernel.org header.s=default header.b=F6pgKb6y; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731380AbgIHTwx (ORCPT + 99 others); Tue, 8 Sep 2020 15:52:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:40018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730694AbgIHPsF (ORCPT ); Tue, 8 Sep 2020 11:48:05 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D741E24828; Tue, 8 Sep 2020 15:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579865; bh=T/kkUQEE7+ok0kqx2oPASSM9vF53iFJ2MbQnnJfEleM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F6pgKb6yLsPGxv3A7zW4WlE0OjSwnGYdDn0Atr1uLzyUOa7d8Cw+RL1YCUVfjvltl Plbx69nKAo136+A50dXFP1lLzP+YPOHXgvWehpskw2JL9yrKz0foAzvwuSD65Yb1z2 Zd3tz+JbOmRK1+WHFq7Q6EFXCuqPowpJcCeXXZjk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Namhyung Kim , Ian Rogers , Alexander Shishkin , Andi Kleen , Jiri Olsa , John Garry , Kajol Jain , Mark Rutland , Peter Zijlstra , Stephane Eranian , William Cohen , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.4 064/129] perf jevents: Fix suspicious code in fixregex() Date: Tue, 8 Sep 2020 17:25:05 +0200 Message-Id: <20200908152232.892355478@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152229.689878733@linuxfoundation.org> References: <20200908152229.689878733@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Namhyung Kim [ Upstream commit e62458e3940eb3dfb009481850e140fbee183b04 ] The new string should have enough space for the original string and the back slashes IMHO. Fixes: fbc2844e84038ce3 ("perf vendor events: Use more flexible pattern matching for CPU identification for mapfile.csv") Signed-off-by: Namhyung Kim Reviewed-by: Ian Rogers Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: John Garry Cc: Kajol Jain Cc: Mark Rutland Cc: Peter Zijlstra Cc: Stephane Eranian Cc: William Cohen Link: http://lore.kernel.org/lkml/20200903152510.489233-1-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/pmu-events/jevents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index 99e3fd04a5cb3..d36ae65ae3330 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -137,7 +137,7 @@ static char *fixregex(char *s) return s; /* allocate space for a new string */ - fixed = (char *) malloc(len + 1); + fixed = (char *) malloc(len + esc_count + 1); if (!fixed) return NULL; -- 2.25.1