From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796221321; b=3VnkJWfOj7+Ebv1p971k/xBphEvKPI2iuMmiLLLa1TmFQpTW8XXd6svNM+ntmFRw5DNC xLvfIaVFHGICom58f0B25I53r/7hl+RqUBGbhOcgmTpExcl92Z42YgoYIzLj9eM4CXIqp O76L6wiGdc8L9aTujJyh0vofTLZWlTPAywn526REIwEv9fbk3KIOss2C4hgSsngz4OXeg U6FVTKeIv0sb71MsCrntEpau1OcNxtMBsmt5ZIHwSGnrKUglnvBNNHi0A1q6udxCk+ddv lCmFoeuSbe+WOiTSezqvXoUUVjK7Ev9DLdxxoDA7VWAxJa7Do7evSgeHyLcdcaBTzfg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796221321; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=DsiE68x6R44coGHLWWQL2msTtjFa1hBElLR2G8okY68=; b=Y9CA4azBRmVtzMMfgtwN1Fjz6b7U0cuT9YLFK+m9VDGtu8kGRafGN4LLUMQVD5YAhfg5 MMYk7NXA97xqoyM1q7cgd7aQdvulrYoXMC55v1iV66Sftk3rfQromtLOCrOSci+gpot/+ kkZETCeEvvNaP/hx75wJsmCcZHMpjDzrdSCeRAPi+RSPga0tJCnOxN3ASjXMKH4kAtRn4 8qyrhhQll/AXKDnW9KeCtzncMkiQERHaxRWxmriR6ZXi+tUs9ymlgQOocNIw+CYFbu0D0 aDjrbU5ll5B3ds6tDvKr9hg0zP461r42/nIpr1ERyZo0xu+TVZ+aBmIeUZWpD8CW0pw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Hw6+zM2V; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1ABCE606A680 for ; Wed, 2 Dec 2026 14:22:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Hw6+zM2V Received: by smtp.kernel.org (Postfix) with ESMTPSA id 949EA1F00897; Wed, 2 Dec 2026 14:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796221321; bh=DsiE68x6R44coGHLWWQL2msTtjFa1hBElLR2G8okY68=; h=Subject:To:Cc:From:Date; b=Hw6+zM2VvPMtVBl+bt+CIxJb1COStbvbYVZLoYNX8Bf8t5XsCFbsf9BryjwEIQq8R rb2dxNb7I0UO6YS7KCcju6jhZqZMcaagzaI3dlajlikPOSjueJ75w8UO4NdcUkLHF9 I9M3MtllZg1T2NV8bgd2efSzr593cPkwPMEKCPxM= Subject: FAILED: patch "[PATCH] perf record: Reject CPU indices equal to the mask size" failed to apply to 6.6-stable tree To: p@1g4.org,acme@redhat.com,adrian.hunter@intel.com,alexander.shishkin@linux.intel.com,atrajeev@linux.vnet.ibm.com,irogers@google.com,james.clark@linaro.org,jolsa@kernel.org,mark.rutland@arm.com,mingo@redhat.com,namhyung@kernel.org,peterz@infradead.org Cc: From: Date: Wed, 02 Dec 2026 14:39:42 +0100 Message-ID: <2026120242-finite-impure-8f05@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.6-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y git checkout FETCH_HEAD git cherry-pick -x 82b4a28e758816365405e01d9ed09027d13ef77a # git commit -s git send-email --to '' --in-reply-to '2026120242-finite-impure-8f05@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 82b4a28e758816365405e01d9ed09027d13ef77a Mon Sep 17 00:00:00 2001 From: Paul Moses Date: Fri, 30 Oct 2026 06:48:50 +0000 Subject: [PATCH] perf record: Reject CPU indices equal to the mask size record__mmap_cpu_mask_init() rejects CPU indices greater than nbits but accepts nbits itself. Valid indices end at nbits - 1. When nbits is a multiple of BITS_PER_LONG, __set_bit() accesses the word immediately past the bitmap allocation. User specified recording thread masks reach this write before they are intersected with the selected CPU mask. For example, an affinity mask containing CPU 64 overruns a bitmap allocated for 64 possible CPUs. ==40343==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7bbab4000018 at pc 0x6195de57af45 bp 0x7ffe25545d20 sp 0x7ffe25545d18 READ of size 8 at 0x7bbab4000018 thread T0 Reject indices greater than or equal to nbits before setting a bit. Fixes: cbd7bfc7fd99acdd ("tools/perf: Fix out of bound access to cpu mask array") Signed-off-by: Paul Moses Acked-by: Namhyung Kim Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Athira Rajeev Cc: Ian Rogers Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: stable@vger.kernel.org Signed-off-by: Arnaldo Carvalho de Melo diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index ad81458989b5..0e98a613c37d 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -3704,8 +3704,8 @@ static int record__mmap_cpu_mask_init(struct mmap_cpu_mask *mask, struct perf_cp return 0; perf_cpu_map__for_each_cpu_skip_any(cpu, idx, cpus) { - /* Return ENODEV is input cpu is greater than max cpu */ - if ((unsigned long)cpu.cpu > mask->nbits) + /* Return ENODEV if the CPU index is outside the mask. */ + if ((unsigned long)cpu.cpu >= mask->nbits) return -ENODEV; __set_bit(cpu.cpu, mask->bits); }