From nobody Fri Sep 25 15:13:51 2026 Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) (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 C7D5B42AF82 for ; Thu, 10 Sep 2026 21:12:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.70 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789074771; cv=none; b=aFFxO4/GYVakLGXtvkUcwgd20OZ+DzFAZo/EaEXwWsmobL+xLpRb4QU6D7Ni6HpNcmA9dYtmz5GKhc9xqeVovnd8MQ8AWfbhIyqn5IdUiX8dEj0kte69IRXsEeMzl70rV721WdF5PMlb7lhWf0CGR0wrVW9Wm/48jyurbpEeqsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789074771; c=relaxed/simple; bh=GFno87KOND++0pTkbVyfXGfOMrlcWDgKnNEmxfOzH3o=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=cUai/svO39Ncxz8nfJs+1OIxWuz2FFnRbM57RaSfvCTjHCpSAgqqZeE5Tychkj3vyvgjfDkr/KsA2vNsycGxHFbHP1+SjUO9NTD9bc420il9W6XMr/pxRSlejOPa+fzMKm2Bdng2lr5bnl+tnxozcpTcYqeA8DPnHoCjQZfMXD0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=H4Te1NjI; arc=none smtp.client-ip=209.85.216.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="H4Te1NjI" Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-39af92138f9so412997a91.0 for ; Thu, 10 Sep 2026 14:12:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1789074757; x=1789679557; darn=vger.kernel.org; h=content-type:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=du1Euo+bpbmMcY488P/S5lzZFDL0wvPLdizijcyISy0=; b=H4Te1NjIL8t6eG7j6ZmD6cdg5yhw32YD40I420G1lkP6QRs/hl45RfYSd5kvAjADpx oXe9aBW/P3ewpbeSLNMQhB52VzaCF5P01G189xZpYez0EnmaYBpJps7660HqeXchrOeW Q7BJiJPybnN1xW65ZFPjF6SvcHASYQznEtZ/WeDjLSBkUCxlVc18qlBP0lAKDpc5beOp vc1SiKQ+zKbE4iY1ZP+HRP5c7f/m66FUSQmkB/OYdgwi3MZeOSlbiXRZM9ffu4WA2Nt7 Xbf9KvHHi3zlJ5R6B6ClPhoPp7GSp2ldwXBOePHsCz6HycJH5xBI6sc0Ou/HwCKQcFhp zddQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789074757; x=1789679557; h=content-type:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=du1Euo+bpbmMcY488P/S5lzZFDL0wvPLdizijcyISy0=; b=itFDyLYtPAIPCUBfxZOthQbZMV4PsA7EgOj0/iTgIsSt2l0hQ2/tqXC87qXoHmq+8D FV0fDuzJig4rAqZ+ehmbbX3Pr+VwL8qbakkUksejly03RJNhgpvI57SlUV16LnADkHfr aC9WeKYT7MYiWuSuM98PABjes1Cgvnl45OIcFFgAMbGuNQyrn9P2CGwDc35g5xgpak4/ rWSsdaZtlMUE48BVce5DcafDtqucVQqC/1cDwZ3wBfG6P20nmg3Rv1qdE3P3n6NFiBUE 7ntqrq402htO5rFpmv95OGFQjEYN+tB/pmyjd2LydgjFYr8R8gKWhmA3OQCdHcUd60p0 QZ4Q== X-Forwarded-Encrypted: i=1; AKwUvBxMU37i4KWCKeCKlpvwACu5NKZ6dQ0pSfKd3GHY1TYeCKGnJEolhgeKCT2oBxQeciENatC6zJAdNyCxp74=@vger.kernel.org X-Gm-Message-State: AFuF++nbiN0leuyLMbgEDyaMWQ1TweVE1DSgF8KyDuUkTk72pDIGbt5V oChmPl4XCw4/kGE1EzqksXrFD/+OLVETU0MprlZOeTOW65NJCp+AOBsL7UWqIf6BxXSNC1UBO6R c3ijhkDxFIA== X-Received: from dlbay9.prod.google.com ([2002:a05:7022:6609:b0:143:5969:748]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4b11:b0:36b:b903:994 with SMTP id 98e67ed59e1d1-39d77916d33mr8158316a91.4.1789074756839; Thu, 10 Sep 2026 14:12:36 -0700 (PDT) Date: Thu, 10 Sep 2026 14:12:18 -0700 In-Reply-To: <20260910211221.3154261-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260910175634.3014018-1-irogers@google.com> <20260910211221.3154261-1-irogers@google.com> X-Mailer: git-send-email 2.55.0.1007.g17ff1f9808-goog Message-ID: <20260910211221.3154261-2-irogers@google.com> Subject: [PATCH v3 1/3] perf header: Fix HEADER_COMPRESSED validation for comp_mmap_len From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Swapnil Sapkal , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This commit updates process_compressed() to ignore comp_mmap_len =3D=3D 0 when validating the compressed header. A zero size is valid and may occur during testing. Sashiko review flagged string.h was missing (preexisting problem) and so I opportunistically fixed this and sorted the header files. Signed-off-by: Ian Rogers Assisted-by: Antigravity:gemini-3.1-pro --- tools/perf/util/header.c | 79 +++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 7db7da090a1e..974ce1c926cd 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -1,65 +1,69 @@ // SPDX-License-Identifier: GPL-2.0 +#include "header.h" + #include #include #include -#include "string2.h" -#include -#include -#include -#include -#include #include #include +#include + +#include +#include +#include +#include #include -#include +#include #include -#include +#include #include #include +#include #include +#include +#include #include +#include #include -#include -#include -#ifdef HAVE_LIBBPF_SUPPORT -#include -#endif +#include + +#include +#include +#include #include #include // reallocarray =20 +#include "../perf.h" +#include "bpf-event.h" +#include "bpf-utils.h" +#include "build-id.h" +#include "cacheline.h" +#include "clockid.h" +#include "cpumap.h" +#include "cputopo.h" +#include "data.h" +#include "debug.h" #include "dso.h" #include "evlist.h" #include "evsel.h" -#include "util/evsel_fprintf.h" -#include "header.h" +#include "evsel_fprintf.h" #include "memswap.h" -#include "trace-event.h" -#include "session.h" -#include "symbol.h" -#include "debug.h" -#include "cpumap.h" #include "pmu.h" #include "pmus.h" -#include "vdso.h" +#include "session.h" #include "strbuf.h" -#include "build-id.h" -#include "data.h" -#include -#include -#include "asm/bug.h" -#include "tool.h" -#include "../perf.h" +#include "string2.h" +#include "symbol.h" #include "time-utils.h" +#include "tool.h" +#include "trace-event.h" #include "units.h" -#include "util/util.h" // perf_exe() -#include "cputopo.h" -#include "bpf-event.h" -#include "bpf-utils.h" -#include "clockid.h" -#include "cacheline.h" +#include "util.h" // perf_exe() +#include "vdso.h" =20 -#include -#include +#ifdef HAVE_LIBBPF_SUPPORT +#include +#endif =20 #ifdef HAVE_LIBTRACEEVENT #include @@ -3903,7 +3907,8 @@ static int process_compressed(struct feat_fd *ff, * checks decomp_len + sizeof(struct decomp) against SIZE_MAX * before allocating, which handles 32-bit safety. */ - if (env->comp_mmap_len < 4096 || env->comp_mmap_len % 4096) { + if (env->comp_mmap_len && + (env->comp_mmap_len < 4096 || env->comp_mmap_len % 4096)) { pr_err("Invalid HEADER_COMPRESSED: comp_mmap_len (%u) must be a 4K-align= ed value >=3D 4096\n", env->comp_mmap_len); return -1; --=20 2.55.0.1007.g17ff1f9808-goog From nobody Fri Sep 25 15:13:51 2026 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (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 300A3496D3E for ; Thu, 10 Sep 2026 21:12:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789074776; cv=none; b=iH+A5AGOeWqUFr/u3lXwsQxrbuCX9q8lBNatZTtvMGNC+b9YaHip286n4VwoEQlQYAGZouoRZb3k8ml3ozhHYHsjnUqu4m1ZJj89dIk9ndRh3ekWqa34zCDB6l7qF1zoSnnRB3/lpj67mRPk/0iZJAKA134Tc+jZsUxqR7H/dvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789074776; c=relaxed/simple; bh=fJ+aO3P5RIRWxVwd58geKjoPWlLgqh9u4SLJ00UGSTc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=N4j0tXYZt0/mWlsA4g8eJ52fsRTY83kAPY5LPMlG7cxDF+M0V4zd8YIEJW6L6FSbD+xv3uFSnFiL7W5iB1ZLAo03mwXgGDUfre20aborPfKgB5D+LCfE+xW1fjkJIs3Q+iy3sg9kmC0sCODJiA5lLGR2RJGDQSH6+0jowd8RnNc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Jtl5+xMO; arc=none smtp.client-ip=209.85.216.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Jtl5+xMO" Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-3968dfff779so286753a91.1 for ; Thu, 10 Sep 2026 14:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1789074759; x=1789679559; darn=vger.kernel.org; h=content-type:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=eu4tcgV+KEQyHj+vflBVWyTo2dzh8uAlVTzpcsVpWHo=; b=Jtl5+xMOAJYUwq+0arPrRc/927pVR5r10tuKmd3e7qVi4awbE0GSuSepw9knweHJwR pi+IHTd6rUdbW0zZfT/bb7oxOwwCNWoQ/Jf//U17oCVCRIRXnXtdA7oO7nzjQGBkxR+n jmrjP7Et5jrkyGJTKC4FRZF6Rhc6IkrNxTMU9PTJxcOr49LJkYUwRK3rhjJNIIeG8HZ/ TcajIpYZShZBplNt690W7jlSBey+/rtlUQ5YXY/DiWJIwKXxUJHxUp1QCFOz4S/dve6E L2kHUZGTbNzC7lfmZU1fOkhhsOozbUHBV10ocOsmugrLeR9Lp0wmTJoTdxNESQUBG5Wg d6VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789074759; x=1789679559; h=content-type:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=eu4tcgV+KEQyHj+vflBVWyTo2dzh8uAlVTzpcsVpWHo=; b=Olez2nQ8axIilT4I6I42f3Wl6zZuTg+c2Ev53Su1mCaG0AVkS1aJR0BDFvw/eKDI4w 5IMXlxtvwOLAlSigw+nBOpaML//r/zswPaSFwfcwdVyXkM1hl1XsVZcrIzFUoQLXhAsg joWEvGssconWZCw/mhr/1mH0rbEzGXo6sggVBDQ/1C0CbXJscOZsjU62VbU7ERNOl7jh m1YOlZ4jhQGHXLhxgf5iJZhjdQJpB4iwVgWMm6mGHFwFNwTrHoEj0Rrznybhl4CyrpcF BZPZh4K0Rm/3GILxxZgaU0NcUthL/C/5TzO2yvUsxI3+YTsvyvk1RMvt+kfwec/68DVn IrCg== X-Forwarded-Encrypted: i=1; AKwUvBxhEqEudxdBtpulJGonm5rOKVuq1SrSCDk4UwyAS2VdqU8Pa4f26lntFHQsFcpRuX3xJPlCnf9KoKg/c2g=@vger.kernel.org X-Gm-Message-State: AFuF++m2Ng08aXsU/IhUPi0+4ed++varXplY+1feT6LJvKFOA+Y3WLqz OBm4xBBXCz7gBHQBVshB4QyVmdsGVmkiyle4ki46YFB6oqyieXKM03f6gd+30Gh4DObfC8wUgaR twBDYhoktuQ== X-Received: from dlbuy19.prod.google.com ([2002:a05:7022:1e13:b0:142:d9a6:93e3]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4d0d:b0:38e:6d55:b1a6 with SMTP id 98e67ed59e1d1-39d97ea0248mr1131117a91.3.1789074759098; Thu, 10 Sep 2026 14:12:39 -0700 (PDT) Date: Thu, 10 Sep 2026 14:12:19 -0700 In-Reply-To: <20260910211221.3154261-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260910175634.3014018-1-irogers@google.com> <20260910211221.3154261-1-irogers@google.com> X-Mailer: git-send-email 2.55.0.1007.g17ff1f9808-goog Message-ID: <20260910211221.3154261-3-irogers@google.com> Subject: [PATCH v3 2/3] perf header: Fix potential memory corruption in cpu_cache_level__read From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Swapnil Sapkal , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" strim may advance the pointer assigned to cache->size which causes later frees to crash. Fix by performing the strim and then memmove-ing the potentially shifted string back over the original string. The bug was introduced by the transition from rtrim to strim, as rtrim wouldn't move on the left. Fixes: 13c230ab6e56 ("perf tools: Ditch rtrim(), use strim() from tools/lib= ") Signed-off-by: Ian Rogers Assisted-by: Antigravity:gemini-3.1-pro --- tools/perf/util/header.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 974ce1c926cd..0a4236fc0293 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -1268,7 +1268,11 @@ static int cpu_cache_level__read(struct cpu_cache_le= vel *cache, u32 cpu, u16 lev return -1; =20 cache->type[len] =3D 0; - cache->type =3D strim(cache->type); + { + char *trimmed =3D strim(cache->type); + + memmove(cache->type, trimmed, strlen(trimmed) + 1); + } =20 scnprintf(file, PATH_MAX, "%s/size", path); if (sysfs__read_str(file, &cache->size, &len)) { @@ -1277,7 +1281,11 @@ static int cpu_cache_level__read(struct cpu_cache_le= vel *cache, u32 cpu, u16 lev } =20 cache->size[len] =3D 0; - cache->size =3D strim(cache->size); + { + char *trimmed =3D strim(cache->size); + + memmove(cache->size, trimmed, strlen(trimmed) + 1); + } =20 scnprintf(file, PATH_MAX, "%s/shared_cpu_list", path); if (sysfs__read_str(file, &cache->map, &len)) { @@ -1287,7 +1295,11 @@ static int cpu_cache_level__read(struct cpu_cache_le= vel *cache, u32 cpu, u16 lev } =20 cache->map[len] =3D 0; - cache->map =3D strim(cache->map); + { + char *trimmed =3D strim(cache->map); + + memmove(cache->map, trimmed, strlen(trimmed) + 1); + } return 0; } =20 --=20 2.55.0.1007.g17ff1f9808-goog From nobody Fri Sep 25 15:13:51 2026 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (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 043FA42E413 for ; Thu, 10 Sep 2026 21:12:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789074778; cv=none; b=XidV3k24A1SEblrvS8vV/IVp++8qmXqwjg/VKI/JWni4XlPgTxKHwH+ZBulCu/Qb0epn/CkXTuTAJeATc7YKMYMNPdq+JROPWfMHdsKok4DCpwDMoLr/LKdqyogz3yNz+7XvntdrCNqQu507rVFnyE6uwA/SFkp1lcyAUrdklfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789074778; c=relaxed/simple; bh=pHmH4FKVoanWCsK6EvzxcfwQB0GYW9gq4JtV5uiHIwM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=BoP/A7mpLtKrwg4f8hju5cgrW1U0LGTMRdiPL8MyOZilw3lGBK68y4BJyvvd+fjPhjre7o0zIQh1JyvXIc3kg83zb3IGnDA8K4010Eg+bdafEioc8imXaAVEOuKHAV5x+xfZ6WIi71nwduOt/aSknTTO6ll57c1+Y3XF30YgW1M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ae1y8A5c; arc=none smtp.client-ip=209.85.215.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ae1y8A5c" Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-cc1eb205d31so385503a12.2 for ; Thu, 10 Sep 2026 14:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1789074762; x=1789679562; darn=vger.kernel.org; h=content-type:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=BmuwdNR4NKfLQOl78IvOzdTNOGEQTEMkPYahKNXJxGY=; b=ae1y8A5cGiboZjuE9w7IHqGVAX3yh+AoiTAJZKHJJudD8gniefqgHkrYyqufYZPg5B CydwIuRRqZlAmOp02dqkzNm2uSDS08AaIqDBGvXSQcA3MHsj79R/lkQb799TdAwDLy9p 8/EhdW1Nt3JIyCEain74Syv+shim9eCv9T/j7z0NDgQIYtddJmt1hG8s73uAnfbgwnor 9slYUSpzEesRkPpNS/p/bRFh7Rc66DHhb7dJC7Oistwozxj7YtZlLaeLBETkmwoEslPg yqki1Ni4/ETj23ZhOkRgs7xAZz3LaNOeBYIhxs36e21zkW7zCCQI7e/6T5oFQIwshMUQ MGTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789074762; x=1789679562; h=content-type:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=BmuwdNR4NKfLQOl78IvOzdTNOGEQTEMkPYahKNXJxGY=; b=idEHi9fg3BHydWST2sCL2CwZ3VyTYefoziHMQomFilR8urKlEwoEtA40vxEXzL58Ug 3gYsH9b3gf5sc1GdC0mfGnXwr7GUnHujqfE1CzMRI8IjNbhNFWnRnxGzSr/TFbHXy+Vc 1UIkReSsteiLzumpInC4fiermn8NpnrR1CzB0cbV0GKObSkecopMBtqf4IGB0qUALKMS zOTT61WqyXaTbx+au1rM01mxEWLqpyLs2NqN0pg0Dz3mJj10qkT+sD7F+Piw9G0ue1ie vXPgcBLSKdV2Vx9S6CfKVeXwPksVYQPGIA7CD/LKcTyNzxAZdihLfj+M0xwtzpibmFba QCiw== X-Forwarded-Encrypted: i=1; AKwUvByhHuZpVdqrMu6yv+pjvatlSKCAS9QiHvuNv7eVdCK8uvNYYl49v3U4+8FC20DAmglGiAdeWNFMPd1j0ZA=@vger.kernel.org X-Gm-Message-State: AFuF++kSyQqssQdX5RI32IAr8Lroj3kUi/4fISTLZQP7igVBrgiY42XL dDE+eI3KOtvwKvidlbGuVAH3Xt4V8heBN9cXpdBx0cc5KNUmI8g2EnOUO2ayk/JlcSsvq8hndbT uBACLyQAQ9g== X-Received: from dlbdt18.prod.google.com ([2002:a05:7022:2592:b0:143:6670:4d89]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6300:618d:b0:3cc:f008:8123 with SMTP id adf61e73a8af0-3daed153d75mr1559765637.8.1789074761613; Thu, 10 Sep 2026 14:12:41 -0700 (PDT) Date: Thu, 10 Sep 2026 14:12:20 -0700 In-Reply-To: <20260910211221.3154261-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260910175634.3014018-1-irogers@google.com> <20260910211221.3154261-1-irogers@google.com> X-Mailer: git-send-email 2.55.0.1007.g17ff1f9808-goog Message-ID: <20260910211221.3154261-4-irogers@google.com> Subject: [PATCH v3 3/3] perf header: Transition WARN macros to debug.h equivalents From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Swapnil Sapkal , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Avoid a checkpatch.pl warning on the use of asm/bug.h by switching the use of WARN macros to explicit tests and then using pr_warning from debug.h. Signed-off-by: Ian Rogers --- tools/perf/util/header.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 0a4236fc0293..c7f2c29f02b0 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -8,7 +8,6 @@ #include #include =20 -#include #include #include #include @@ -385,8 +384,10 @@ static int do_read_bitmap(struct feat_fd *ff, unsigned= long **pset, u64 *psize) static int write_tracing_data(struct feat_fd *ff, struct evlist *evlist __maybe_unused) { - if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__)) + if (ff->buf) { + pr_warning("Error: calling %s in pipe-mode.\n", __func__); return -1; + } =20 #ifdef HAVE_LIBTRACEEVENT return read_tracing_data(ff->fd, &evlist__core(evlist)->entries); @@ -407,8 +408,10 @@ static int write_build_id(struct feat_fd *ff, if (!perf_session__read_build_ids(session, true)) return -1; =20 - if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__)) + if (ff->buf) { + pr_warning("Error: calling %s in pipe-mode.\n", __func__); return -1; + } =20 err =3D perf_session__write_buildid_table(session, ff); if (err < 0) { @@ -1014,8 +1017,10 @@ static int write_auxtrace(struct feat_fd *ff, struct perf_session *session; int err; =20 - if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__)) + if (ff->buf) { + pr_warning("Error: calling %s in pipe-mode.\n", __func__); return -1; + } =20 session =3D container_of(ff->ph, struct perf_session, header); =20 @@ -1109,9 +1114,10 @@ static int write_dir_format(struct feat_fd *ff, session =3D container_of(ff->ph, struct perf_session, header); data =3D session->data; =20 - if (WARN_ON(!perf_data__is_dir(data))) + if (!perf_data__is_dir(data)) { + pr_warning("Expected data to be a directory\n"); return -1; - + } return do_write(ff, &data->dir.version, sizeof(data->dir.version)); } =20 @@ -3715,9 +3721,10 @@ static int process_dir_format(struct feat_fd *ff, session =3D container_of(ff->ph, struct perf_session, header); data =3D session->data; =20 - if (WARN_ON(!perf_data__is_dir(data))) + if (!perf_data__is_dir(data)) { + pr_warning("Expected data to be a directory\n"); return -1; - + } return do_read_u64(ff, &data->dir.version); } =20 @@ -4395,8 +4402,10 @@ static int do_write_feat(struct feat_fd *ff, int typ= e, if (!feat_ops[type].write) return -1; =20 - if (WARN(ff->buf, "Error: calling %s in pipe-mode.\n", __func__)) + if (ff->buf) { + pr_warning("Error: calling %s in pipe-mode.\n", __func__); return -1; + } =20 (*p)->offset =3D lseek(ff->fd, 0, SEEK_CUR); =20 --=20 2.55.0.1007.g17ff1f9808-goog