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=1796221323; b=O3Fske0/hMinRkycMwRt3QpmHEC2hLlgQK7rjl7L+cqHs4IWr2VtT9GP0BMoRRWEP8DB rVvsda7vbji8emeOTiQGnozPLxZy7AmKkBkUvOhIqvHydKGIBiOnXZ0PKaxIExzrm5s6M 1eUrxmT4V2YoUNzRtxPfTR0VlNEnreeVPBe62z1T98J6DuMQtRafcCms/eeMleUyDYQfb SjrdBCko5eVimdsmznj9JgysQiqYK302OEQGj1OBXfgTi6kQA8bx1I1WyKJRshZlFsbIa PSIy+fcIzWMb+CjslY3uk9MTWY6WuBX7iqnkqttrpfySwcFb/MJu+YQU2vrlr41eSWw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796221323; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=xQj3YWe/NpF2IrnQYOUPWtBKNjy+bCzFQgl/Nwk3xlA=; b=V6XTavwxXtf332lm5W9Eku35BhJ8Td2VEgssNm0galx1A8JOGygNVPpiYAuqbVaDqkwA VyOiZ1l9RnLTVDmXue9wW/kIifZhdcPtXAFAX3BtfX3LWdnLPhBKSGE7ivMoLwLKbKcf1 EbnBFhTvHrrVsCa5jxUb/RAkUvDpE1FPfE5ASwBSyOZlbgfFLuKKVZR76u8+aLjIZBmIT L0I1uLXbExd+vcg76K9LM6ALW4uyb1trb6Ic2l2xeMlYP1jUyfv8W8ZQtxNyNaJmyTtTB /JicNJbZqFDZB4PjvVH80jmXO413LVLfe2TLwUn7ct8JnhQ6mEg2wJNhYcTljPQEmgQ== 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=iJCydvos; 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 DDF33606A32A for ; Wed, 2 Dec 2026 14:22:03 +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=iJCydvos Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B1921F00897; Wed, 2 Dec 2026 14:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796221323; bh=xQj3YWe/NpF2IrnQYOUPWtBKNjy+bCzFQgl/Nwk3xlA=; h=Subject:To:Cc:From:Date; b=iJCydvos6hZflwDCVwzwPrhssVkxHHwxUGMc75XnzwupfocKuoEKBJOa5eB1vBxp8 U51tlTqhxXgF2i4i43dcmmnQa+eqZvR6h1jLIdz649sEok5unNoqgwx9l6E4wqIPGL 74jEpyc8zIVZT19sxoZxFziqbcGJwg0jLwPL6S8k= Subject: FAILED: patch "[PATCH] perf record: Reject CPU indices equal to the mask size" failed to apply to 6.1-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:43 +0100 Message-ID: <2026120243-tricking-diabetes-c833@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.1-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.1.y git checkout FETCH_HEAD git cherry-pick -x 82b4a28e758816365405e01d9ed09027d13ef77a # git commit -s git send-email --to '' --in-reply-to '2026120243-tricking-diabetes-c833@gregkh' --subject-prefix 'PATCH 6.1.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); }