Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp462392lqp; Wed, 22 May 2024 09:27:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXpW/D/jdrlijm64zbkXBGOVJ5NU1KdJ4WcvdvBFf5QjVmzcaG1vxm6frhCzguyB3+PupgSD5LlJpjdRVk0tiu2YtEndimFPCI+PUybCA== X-Google-Smtp-Source: AGHT+IHfQqcsWkJHWqo/hUdrzDloxsgPX9Z5kSbhQ+W+fORPjm2Y1Af+U7denLMkURqQB4n8Xpst X-Received: by 2002:adf:e390:0:b0:354:f502:cfe7 with SMTP id ffacd0b85a97d-354f502d60bmr443227f8f.22.1716395237894; Wed, 22 May 2024 09:27:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716395237; cv=pass; d=google.com; s=arc-20160816; b=HQQhgIXyXfddFm6ty8O2qw6lvwtbgOITthd6CoQZpZ0M+kql3rkSYwkSdfYPHZaN6g XTGov0C2PZG7UF1CbMCKIkjA2bM4kwQywDBZNMoBOB+AUCUy5pk0lNwXGQHdcgF3lg9Q okpg02gW5aGZIbkA5FlAlVQjVVtfnunttg+AYisLnVk9so1VBwnrVhRC/2TS6BKwzvlN ghDyJtLehk3WDflLWOngKnmC05vl8O2Mb0F5coITnODBY2zNF3sgUr4xd61TZ2hREZSF WpxV7+Wtyy5PUc7HdKJmNN3ON63SFj2QXQoAkzTMwZWgltETUUoRtJDPI2/4vVLKy6gA 3TAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=71bEdcCFAmtnhRQcl2H8cfdDF/yHlhWYnXTomnqsrKc=; fh=w02mqzAO8q0/x4brDBWBdt2BItGZvyF7Oan7crjFk90=; b=lD7cJps2lz0T+KCUAYqAcaVs+9OrCzp4nycPXUJE43qNqjvZ+tUKHDhVPqcCr02xNy mJZsXDYN4hX6mCd2fjDqaHlLCM1TgA1I9jSv9qdBz9qfLHfaNbEmeOZVbikwKXTk0mie xJkUIzh5hVZ67nvUZAErGzYGbkAZHp+BXL7XhSzZwbK8j85/spdK0wiQdGa8XU5flAEW mZgBrJhqyDecND7v3E4/vRUjVh2MIhpZ3N7xEpfYl1mpS44LZgLBkuGRLkAUALE4LwrP ov063PAynAqXi1Fj8RvDFGRZeK1/1l5ZT3HsExCsg+u6yPvCyKszrFsls83gWRXjSZF+ a9mA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-186492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186492-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5ceb4ccaebsi766133766b.831.2024.05.22.09.27.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 09:27:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-186492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186492-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9D7521F233CA for ; Wed, 22 May 2024 16:27:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C72551411F2; Wed, 22 May 2024 16:27:07 +0000 (UTC) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9F6C13D8AA; Wed, 22 May 2024 16:27:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716395227; cv=none; b=qrdZ1PFQ3M7lO9aoSbMSnIVqFKwQ7mG9CPKtGeZ4tt9OWZzTO9iHdCgAfkiP5VVG8bxgsnn3fdVYTRqfqPCa1rnGKUqgbeR7kmX9mQ1Z0Q01bASYlL+HwU5go5wtsCS0sVqYBIJ+8XjMp9keUssxyB+cpniIAzufV5VfVOYEoNk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716395227; c=relaxed/simple; bh=RxdI4F1CKShHGVqWnvdKwtmWY+Plt0lPfkZWLBQ25so=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=arUfP7RbJFE71uqq6sX8AT3s+UbFdnS7zr+KFU8FgleKr1fPR1JwpwrlBRHaZz+R275z5A2UsGYrpE1i0nxq/tmmLb9Mu/vHic9r8GxdglTY+wAbd4ZtC0sKppFT+KgrgTC+bHa4LzNuOuJrIX6ME6F+alryhkkJDIWdla10APY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2b9dcc745a4so2223307a91.2; Wed, 22 May 2024 09:27:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716395225; x=1717000025; 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=71bEdcCFAmtnhRQcl2H8cfdDF/yHlhWYnXTomnqsrKc=; b=BbuiukBl18V40IhHFesoyvib/8QCFGHOmwgVS9I0I6H0BSbQh2DiRdHKJWGD7+W9JV AQny2iPc+GqMtawPM6uYvlndly4BGLsVN2cja9aIjO4sK9oR7nR5Dr6HegusUNheD3on REK0djE1vNqHGB1/wcPDeY7SQEHhJCi3/+N4qwBzKm5YqlkOaDAGB2D9/cwv8/Uo0P2W voibaTlNtDNQpX/eZguamyWYhV4n+LeYTRo+wvwI08GX3JGYxaD+4x90PDUNzPitEFL6 eSZ+U2a0s4sAfw0zhWFPPs0HYANtyob+7vXDgcPICu/lQhSMoW/YCnUadcHP67ZVQ0SO Jvyg== X-Forwarded-Encrypted: i=1; AJvYcCUqou7TjMHrHb1qX9kClg/F+Xhedvdi4sqA1aqcMiH3UVFOrVOAM4FVUs5sGiNEljc5V3QLG133nQJcZNQtg29jdajATMZnaXKfCVnfFbtvVzi8kph2Zc4jEU44cq/eeuIMn/F0WHraAQ8ookACJs3QgjzGPahQilXAqn+STDt8+X+2aw== X-Gm-Message-State: AOJu0YyQ3qUjvKAqi8Q0sbC/bKfwGrRKHOOuIRZcwnX2lDgcL36Cqfnk lyS8xC2r3LlfVHqPDg75wZx7tGCL9HeMqy34fHKJh3ksVrBzETOlisyhmt2Z8aaNP1MUbmFbnKo dJNX/gloNAJio5xsFTcJ4WOdhisg= X-Received: by 2002:a17:90a:17a5:b0:2ad:c098:ebca with SMTP id 98e67ed59e1d1-2bd9f4895a1mr2492001a91.20.1716395225061; Wed, 22 May 2024 09:27:05 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240515193610.2350456-1-yabinc@google.com> In-Reply-To: <20240515193610.2350456-1-yabinc@google.com> From: Namhyung Kim Date: Wed, 22 May 2024 09:26:52 -0700 Message-ID: Subject: Re: [PATCH v5 0/3] perf/core: Check sample_type in sample data saving helper functions To: Yabin Cui Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, On Wed, May 15, 2024 at 12:36=E2=80=AFPM Yabin Cui wrot= e: > > Hello, > > We use helper functions to save raw data, callchain and branch stack in > perf_sample_data. These functions update perf_sample_data->dyn_size witho= ut > checking event->attr.sample_type, which may result in unused space > allocated in sample records. To prevent this from happening, this patchse= t > enforces checking sample_type of an event in these helper functions. > > Thanks, > Yabin > > > Changes since v1: > - Check event->attr.sample_type & PERF_SAMPLE_RAW before > calling perf_sample_save_raw_data(). > - Subject has been changed to reflect the change of solution. > > Changes since v2: > - Move sample_type check into perf_sample_save_raw_data(). > - (New patch) Move sample_type check into perf_sample_save_callchain(). > - (New patch) Move sample_type check into perf_sample_save_brstack(). > > Changes since v3: > - Fix -Werror=3Dimplicit-function-declaration by moving has_branch_stack= (). > > Changes since v4: > - Give a warning if data->sample_flags is already set when calling the > helper functions. > > Original commit message from v1: > perf/core: Trim dyn_size if raw data is absent > > Original commit message from v2/v3: > perf/core: Save raw sample data conditionally based on sample type > > > Yabin Cui (3): > perf/core: Save raw sample data conditionally based on sample type > perf/core: Check sample_type in perf_sample_save_callchain > perf/core: Check sample_type in perf_sample_save_brstack Acked-by: Namhyung Kim Thanks, Namhyung > > arch/s390/kernel/perf_cpum_cf.c | 2 +- > arch/s390/kernel/perf_pai_crypto.c | 2 +- > arch/s390/kernel/perf_pai_ext.c | 2 +- > arch/x86/events/amd/core.c | 3 +-- > arch/x86/events/amd/ibs.c | 5 ++--- > arch/x86/events/core.c | 3 +-- > arch/x86/events/intel/ds.c | 9 +++----- > include/linux/perf_event.h | 26 +++++++++++++++++----- > kernel/events/core.c | 35 +++++++++++++++--------------- > kernel/trace/bpf_trace.c | 11 +++++----- > 10 files changed, 55 insertions(+), 43 deletions(-) > > -- > 2.45.0.rc1.225.g2a3ae87e7f-goog >