From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 2CF6943B6E0; Tue, 21 Jul 2026 22:11:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784671863; cv=none; b=IssB4S8QjX1GLjrfjNmbeeTepPIXTSNA+xbwkThnPNbSh2y7Nt9qOgkHaB2nN3WjoN1ehWEtabK3vOnWd7nw61ZMAU3eY5eBCEb7Gnz1ojlPxzlvcgS7kBH00kd5JP/jneKGiaS63mW+oUeClxEI0e8KXRbDYy/c5+tA12D3zBA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784671863; c=relaxed/simple; bh=092PPKXMrTN27H7Oh/O9VG4VlvPHH3xbbkAzJ/FRWng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gjLJ8Ej4/Rk2m9vcLjfo70efy88popcUOQmvKI0cca5P7YFeWUBjV55UcWW+X8MjExeYq900zTYqqxMIUplCWWZMUKDDP8qDGS3x11jS+15sWbqa6YzGG4b12Pr4S4NQVjQoo0BrYPWhfu5sqXDQx17neJnqLSgMfkT6eljxKtU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Y5s3HHRi; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Y5s3HHRi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA60A1F000E9; Tue, 21 Jul 2026 22:11:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784671862; bh=XmASr7OdJ2WJfCxY4XYXvrzEapcriyM4aObyK6u97uc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Y5s3HHRiPwt/d6v7aTuutM80V6REM1rIjUCs+M6cYsAMxnxwG5ckuYg4k0ZswYvO/ vIwZzPF/K/GPAbGuMR/Idm8Ktm8pFyX+yuEIptdeX5AcfSE/yh5nVKPLWjp86ROp1w 4rlr2yVaQSVhp9XyoAPzkqR/gyuf/C3S+85hb16k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shrikanth Hegde , Aboorva Devarajan , Madhavan Srinivasan , Sasha Levin Subject: [PATCH 5.15 364/843] powerpc/perf: fix preempt count underflow in fsl_emb_pmu_del Date: Tue, 21 Jul 2026 17:19:59 +0200 Message-ID: <20260721152414.216356082@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Aboorva Devarajan [ Upstream commit 81e3a86030462824a67d697739cf3f387f4ba350 ] fsl_emb_pmu_del() unconditionally calls put_cpu_var(cpu_hw_events) at the 'out:' label, but only calls the matching get_cpu_var() after the 'i < 0' early-return check. When event->hw.idx is negative the function jumps to 'out:' without having taken get_cpu_var(), and the trailing put_cpu_var() then issues an unmatched preempt_enable(), underflowing preempt_count. On a CONFIG_PREEMPT=y kernel preempt_count would underflow and eventually present as a 'scheduling while atomic' BUG. Move put_cpu_var() to pair with get_cpu_var() so the percpu access is correctly bracketed and the 'out:' label only handles perf_pmu_enable. Fixes: a11106544f33 ("powerpc/perf: e500 support") Reviewed-by: Shrikanth Hegde Signed-off-by: Aboorva Devarajan Signed-off-by: Madhavan Srinivasan Link: https://patch.msgid.link/20260605082912.305100-2-aboorvad@linux.ibm.com Signed-off-by: Sasha Levin --- arch/powerpc/perf/core-fsl-emb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/perf/core-fsl-emb.c b/arch/powerpc/perf/core-fsl-emb.c index 1a53ab08447cbe..31037df4178ca2 100644 --- a/arch/powerpc/perf/core-fsl-emb.c +++ b/arch/powerpc/perf/core-fsl-emb.c @@ -366,9 +366,10 @@ static void fsl_emb_pmu_del(struct perf_event *event, int flags) cpuhw->n_events--; + put_cpu_var(cpu_hw_events); + out: perf_pmu_enable(event->pmu); - put_cpu_var(cpu_hw_events); } static void fsl_emb_pmu_start(struct perf_event *event, int ef_flags) -- 2.53.0