From mboxrd@z Thu Jan 1 00:00:00 1970 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 A7C9037C92E; Tue, 30 Jun 2026 09:09:32 +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=1782810573; cv=none; b=CK4/fzMSfwSfj1ggGbE9wJuDRTCh6nJR83pvW3su3C/27JgAjwVhPy3YbcyjUXjGQvEVj7oR98GelXhShSplG+sDFZal1s4wsPgOfqnHZj2JlflceA0/PGEmwiWOL7TuLpEZ/PbkM53DP7ufgeSaPXQuI4wkUxRRQSKC68QLheE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782810573; c=relaxed/simple; bh=KtD+23gQ5OeUobu6amk322GtpnGqppX10yyLx58spQw=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=JsFnE20jA0Dk4423yr5fRtA2P7wDke5pjlpcWmC2lFBIzihhKYHWR1S+C6K0AqAV9DqHr3r1jT0gdO+7WqaVH0/l8Qpdejt8KP9YcxEtO58Xwhgk6AATLKHkYuRPnkJGMNYK0aE7aywXMrERTv2CEdJTVasYqNbi+2LKyCMhvx4= 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=LJW2HysH; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=tlRkwuHt; 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="LJW2HysH"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tlRkwuHt" Date: Tue, 30 Jun 2026 09:09:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782810571; 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=SfGR5nUSMPmmYkWozyXguxg4m3tZhRmB4SXLlcTKjvo=; b=LJW2HysH/vIQoqMOoHeXKB+XsX6LW2/v3jqetkDhdogW+VYgnDUAZOFaOzavJinogqw/pr Zgu+HE1GVIM5wXJUTw0UzTT7FwPyaT6a9LvNIrGKJlnuOSRNEKCgPSgbX6o6dS6XDhhBuE s7s7Nh6OR8UffV6ZZ9fiLiB2wxBcYpJvGhxp30Ba7+7YXqMSrAQ6da/6nG7+ktfZuZX9Hj 20w1UjeS2oWfvLI1RvgFFXN1Kq7+Xf/Th0TYwoI1mpRejLtQg7IUWXLmsDGZBasfR1a6Ry uZ6RWZtrVJs01TD1PYFNYh/2NK927JtitPcs8MdAHqdIHwnultDdwAFYlrU0AA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782810571; 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=SfGR5nUSMPmmYkWozyXguxg4m3tZhRmB4SXLlcTKjvo=; b=tlRkwuHtey3ND1a2TS4BSaFQBTgfW+CJDA17snnWf9/3EYlXbXZbgXArX/E05XKJbJAQwy W+NU6e+j0CuttKBQ== From: "tip-bot2 for Dapeng Mi" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/core: Check kernel access when kernel callchains are requested Cc: Dapeng Mi , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260612090114.3188886-9-dapeng1.mi@linux.intel.com> References: <20260612090114.3188886-9-dapeng1.mi@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178281056948.3843924.6148225556829232072.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: a4b016d0a29038a5b7c96bf62c054bf7832451d9 Gitweb: https://git.kernel.org/tip/a4b016d0a29038a5b7c96bf62c054bf7832= 451d9 Author: Dapeng Mi AuthorDate: Fri, 12 Jun 2026 17:01:14 +08:00 Committer: Peter Zijlstra CommitterDate: Tue, 30 Jun 2026 10:57:07 +02:00 perf/core: Check kernel access when kernel callchains are requested perf_event_open() currently gates perf_allow_kernel() only on !attr.exclude_kernel. However, users can still request kernel callchain collection with attr.exclude_callchain_kernel =3D=3D 0 even when attr.exclude_kernel =3D=3D 1. That still requires kernel profiling privilege, but the existing check does not enforce it. Update the permission check to call perf_allow_kernel() when either kernel sampling is requested or kernel callchains are requested. This keeps permission checks aligned with requested data and prevents unprivileged use of kernel callchain capture. Signed-off-by: Dapeng Mi Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260612090114.3188886-9-dapeng1.mi@linux.inte= l.com --- kernel/events/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index dd3bd9c..0f29d17 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -13932,7 +13932,9 @@ SYSCALL_DEFINE5(perf_event_open, if (err) return err; =20 - if (!attr.exclude_kernel) { + if (!attr.exclude_kernel || + ((attr.sample_type & PERF_SAMPLE_CALLCHAIN) && + !attr.exclude_callchain_kernel)) { err =3D perf_allow_kernel(); if (err) return err;