From nobody Thu Apr 16 10:46:49 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 3D3D7436372; Sat, 28 Feb 2026 10:56:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772276206; cv=none; b=YM/fWFl2kWt8WVX6r3kyT7XrbBzl6Gqbt/1ujfBQ8VscBjWSFAFPrfhehyS2QD0f/85Kb7ni+hHCfAEuD/O7K/3huMn8K5BVnZmJZvaHGM91agi3IguxaKz1GuH9zdQm9D2uVKVhj4jLGhzEJwngMF2vhLjRPg01cYILFwoHTog= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772276206; c=relaxed/simple; bh=MW1e+FiAW8UMS/m9rnJ5t3TMoyT858bSUSQY0RNxvuo=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=YVnfwYYToqp6If0jKaQoABCd0YOrLC5hS5DVDnBM7fIutmqt+RyIvZuwrfqCWTAsK82SPveJgedV2s1ruGdhR9s2svowL/FgNy5HawYNBDL6ewmEMUxXSvvZb9z0h3Z6oFOsqVusPITy+MOgNJG7dptKGfZeXekO0CARjkEhEwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=FFIY0d92; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cD7SKZHI; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FFIY0d92"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cD7SKZHI" Date: Sat, 28 Feb 2026 10:56:42 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1772276203; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=puzbsafhGn7qLTMBnz2gwq27dj5xNNJkHYIywX5kfd8=; b=FFIY0d92mVtt0wYGA70i/bRdrhd3DWYL/s/mZWpQO5E4BZLNepkuxoPUsjBncjXT2d1n0g /czDXAxhBZTze4sDxDcsWvjih+Fyk/VqDeyu6w7M/skshxw6eFsgtJk4i/4jpoNQ38kzz0 XrKYD///c4MEofuRQl0xMPnYVtNcnVNZ5/KmnjPD0axD4YixshQ+/021i0RthYD1gXsKmy V9LtIIG9fDloARoU6jIveBSkVXuxliUs0XyqX3/7a9LFWHFOUNN70qTSi+ldGa9YzbCBS1 MYet8Lbwlt9NP6S5UPrdytzb2+hPet+yWuF0yHgDVdkEnrDnE3ZztOttIwAXtw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1772276203; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=puzbsafhGn7qLTMBnz2gwq27dj5xNNJkHYIywX5kfd8=; b=cD7SKZHIPaWYQJhbjsLwXHt+Mxj2f1udh9R2VxjV4Old/bfy69qSbJSP4ae1K2msaslTJt /BUuCBvoRveBRzCw== From: "tip-bot2 for Ravi Bangoria" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/amd/ibs: Avoid calling perf_allow_kernel() from the IBS NMI handler Cc: Sadasivan Shaiju , Ravi Bangoria , "Peter Zijlstra (Intel)" , Namhyung Kim , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260216042216.1440-5-ravi.bangoria@amd.com> References: <20260216042216.1440-5-ravi.bangoria@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177227620247.1647592.14977762441472774078.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the perf/core branch of tip: Commit-ID: b0a09142622a994c4f4088c3f61db5da87cfc711 Gitweb: https://git.kernel.org/tip/b0a09142622a994c4f4088c3f61db5da8= 7cfc711 Author: Ravi Bangoria AuthorDate: Mon, 16 Feb 2026 04:22:15=20 Committer: Peter Zijlstra CommitterDate: Fri, 27 Feb 2026 16:40:23 +01:00 perf/amd/ibs: Avoid calling perf_allow_kernel() from the IBS NMI handler Calling perf_allow_kernel() from the NMI context is unsafe and could be fatal. Capture the permission at event-initialization time by storing it in event->hw.flags, and have the NMI handler rely on that cached flag instead of making the call directly. Fixes: 50a53b60e141d ("perf/amd/ibs: Prevent leaking sensitive data to user= space") Reported-by: Sadasivan Shaiju Signed-off-by: Ravi Bangoria Signed-off-by: Peter Zijlstra (Intel) Acked-by: Namhyung Kim Link: https://patch.msgid.link/20260216042216.1440-5-ravi.bangoria@amd.com --- arch/x86/events/amd/ibs.c | 5 ++++- arch/x86/events/perf_event_flags.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c index 05b7c9f..004226b 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -313,6 +313,9 @@ static int perf_ibs_init(struct perf_event *event) if (ret) return ret; =20 + if (perf_allow_kernel()) + hwc->flags |=3D PERF_X86_EVENT_UNPRIVILEGED; + if (hwc->sample_period) { if (config & perf_ibs->cnt_mask) /* raw max_cnt may not be set */ @@ -1349,7 +1352,7 @@ fail: * unprivileged users. */ if ((event->attr.sample_type & PERF_SAMPLE_RAW) && - perf_allow_kernel()) { + (hwc->flags & PERF_X86_EVENT_UNPRIVILEGED)) { perf_ibs_phyaddr_clear(perf_ibs, &ibs_data); } =20 diff --git a/arch/x86/events/perf_event_flags.h b/arch/x86/events/perf_even= t_flags.h index 7007833..47f84ee 100644 --- a/arch/x86/events/perf_event_flags.h +++ b/arch/x86/events/perf_event_flags.h @@ -23,3 +23,4 @@ PERF_ARCH(PEBS_LAT_HYBRID, 0x0020000) /* ld and st lat fo= r hybrid */ PERF_ARCH(NEEDS_BRANCH_STACK, 0x0040000) /* require branch stack setup */ PERF_ARCH(BRANCH_COUNTERS, 0x0080000) /* logs the counters in the extra sp= ace of each branch */ PERF_ARCH(ACR, 0x0100000) /* Auto counter reload */ +PERF_ARCH(UNPRIVILEGED, 0x0200000) /* Unprivileged event (wrt perf_allow_= kernel()) */