Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1403728lql; Tue, 12 Mar 2024 16:58:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXFcWtlpMvBOIXC0IgZAogkNXpvHAHVOM76ost0oGeUGlBWuzFzS8UZOK3y0P3UXY+uV3Ej27AcjrJrvgMLe/qunMh9LG7Px6ByTHJ6zg== X-Google-Smtp-Source: AGHT+IFEgzTV73i537Uh7/AbDiak1ME0a12RNMAbaNQwQwu9m2dW3aV4FWZ3Gx8KVTx2jJx9Nhxc X-Received: by 2002:a05:6870:700c:b0:221:dcec:fb7b with SMTP id u12-20020a056870700c00b00221dcecfb7bmr9267498oae.6.1710287919157; Tue, 12 Mar 2024 16:58:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710287919; cv=pass; d=google.com; s=arc-20160816; b=UUjdDI+o+ELaLJw762jSqR6m8l0H5iVpjQ4/VeO2DU8qEXKH7a1dMk6JNKBuW9/EGe OGly4MPuoV6SsY8c+x5W1diiPzDZ7YkTEi1of22/d0MchPcd3zBt4SVT/MUROc+ZS2pz KmLRW5m+w0iO3I2EikmMaDeXenF/PDv4sTGNfNkZrwI8Qoerxru75rhJWEHClC+kXn/N K4gtj08Ds+pZn7dLIWA1VIhZOJFxKr62YX/L5BAQc2JPedUzXEhNGXWgJJBTqyPmoBch enN50AJ/Zb5grEZwUnAKSO/6V5vL2WXxdf7INHA2dzxd5o4nq4Z2j7VcLDvDCkLk8n/U 5mLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=izx7Nr87c1gp5zOeo5N85ZJ5zDh6VBFpD9hItY7jBW8=; fh=kpCWYU++zinp+um2uRC9/18d15F1gVi8n8S9vqeKrgY=; b=s9V/51x5I9gc+cqPNIxVdas2I76s+Z7sujZv3g/bFQAtmN6/iBMTSCm7t9bIgsHpLb Wt2y6ZR77PxJyRGNW2DOu1CwwkEHkVcpWrUXW2XdzjGeDRDxQKUH8+cvwJv76DYyFWUY apxYNaOyqtkYPymmMnV7b2UdOKPRd4AQxMwu+/CC6QTCbb/ntVSVWzySx21BqXk7w+2+ 9FXGe5AU+dExfEL8KUTWjcyX7PQx55X8qfkyXnLaMYeJqJsRrBY7IXxMa0qWaJmG9nph t0r8DA5qSL5uSaIfoFlbhOIYi1/s3stC8oG5wlJh5p2ewEI4NxqZoPZ4yF3XQsrdL4Pj /tyA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aWJXU5lY; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-100950-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100950-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bw3-20020a056a02048300b005cecbe69c23si8770765pgb.43.2024.03.12.16.58.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 16:58:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100950-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aWJXU5lY; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-100950-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100950-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B237B28369F for ; Tue, 12 Mar 2024 23:58:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 496505026B; Tue, 12 Mar 2024 23:58:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="aWJXU5lY" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA7DB50261; Tue, 12 Mar 2024 23:58:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710287906; cv=none; b=iq3AQbQNI5RtUNJmDoRF6t7S/ecjfsKrAzJx7kT0jAk2Or2m3/2YKldY+z3YYB5fa6lBEE8zCGRmAQbFKSFjRGnEKW5lHZ7jygN0K15PSt78FARFIxf/+cFxRXwkVJ8ZxkWUhdanh+s1CmTmvAlb8BiXo9G68s/aBO/x5OrtogA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710287906; c=relaxed/simple; bh=qjWayyyQhCi250zU2Opae+utKD9GihjjAv/L830N2jU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=dYdB6MrT3ohyD1dBlz0II5OtyRjiNqt/xTni5BqljeNxqkF/yMjZmhX18nvGEWZNYHR0vwUeehMtLrTcIIWCcB1C0Q7pRPF/v0uBA8gpVBzm7TVZmWiVTRZ8C3G5ciszUE9SfmB/i+G6cT6hqCSN7HPHvpxiYHHGW5SlUHAzVoQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=aWJXU5lY; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710287905; x=1741823905; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=qjWayyyQhCi250zU2Opae+utKD9GihjjAv/L830N2jU=; b=aWJXU5lYanpvQ71dv+cqLCA67RXnr5PPDLDVuEPrm0W+HaX+9jebbaDz CPRQxtuViBbO9U6VF15BajtARYGX8tLVkYCnNxlBi54DipMI5ss+Wjjxc SZqbNghZOJsEyUem3SxeRgXqj3UdnDuCt8A0MV0ub5uWhPApCJr3OtTDG jmMl6U9GDBska5zBdjRBCcUp80GMFLLXVfp44Hhmubw10CGGUXE54Rkji NyaqjJ1v/wIEr1x8S8GGvgfT90G4mEk6rjCISHB/rpubhPy/T8H3Hd3rl WDe5QIy13ts+a0WWWvwV6a61663qD2ybB/3XV7zfqbyTZvH+4NF29yfus A==; X-IronPort-AV: E=McAfee;i="6600,9927,11011"; a="8848662" X-IronPort-AV: E=Sophos;i="6.07,119,1708416000"; d="scan'208";a="8848662" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2024 16:58:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,119,1708416000"; d="scan'208";a="42717198" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.54.38.190]) by fmviesa001.fm.intel.com with ESMTP; 12 Mar 2024 16:58:23 -0700 Received: by tassilo.localdomain (Postfix, from userid 1000) id D6244301066; Tue, 12 Mar 2024 16:58:22 -0700 (PDT) From: Andi Kleen To: weilin.wang@intel.com Cc: Namhyung Kim , Ian Rogers , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Perry Taylor , Samantha Alt , Caleb Biggers Subject: Re: [RFC PATCH v4 1/6] perf stat: Parse and find tpebs events when parsing metrics to prepare for perf record sampling In-Reply-To: <20240312234921.812685-2-weilin.wang@intel.com> (weilin wang's message of "Tue, 12 Mar 2024 19:49:16 -0400") References: <20240312234921.812685-1-weilin.wang@intel.com> <20240312234921.812685-2-weilin.wang@intel.com> Date: Tue, 12 Mar 2024 16:58:22 -0700 Message-ID: <87plvzm28x.fsf@linux.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain weilin.wang@intel.com writes: > + > + new_event->tpebs_name = strdup(id); > + *p = '\0'; > + name = malloc(strlen(id) + 2); > + if (!name) > + return -ENOMEM; > + > + at = strchr(id, '@'); > + if (at != NULL) { > + *at = '/'; > + at = strchr(id, '@'); > + *at = '/'; > + strcpy(name, id); > + strcat(name, "p"); > + } else { > + strcpy(name, id); > + strcat(name, ":p"); This seems like a buffer overflow because :p is 3 bytes including 0, but you only allocate + 2. You should really use safe string primitives, then you would have noticed the truncation. -Andi