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 4521516A956; Tue, 30 Jun 2026 09:48:14 +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=1782812895; cv=none; b=ZOijAGQHW+WKT7JAtw33a4TXPLWrDAFMkZj8FE2Hj/b+I/Z3XE+QDap4s7FOxDuumjgJQXyx4kwtd6oTvwlleEtm5wCIXRL9vnP5JQzpiRqLmnfIJSo8sUCt3G8oUuC+o6324LzuHX1LPBvlNLLYE4f3Lxhlb+4h6nYMbBedIbA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782812895; c=relaxed/simple; bh=TyGeL5sB8lihZHWxeCxr67jTqUqZh3DriW7gjDTBDVg=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=ISqEWS3nlqRvl0losBDpQlu/BOXUMq5cBcmQPxFZRbiaANKWe5EyDVjg7+5wjgOutsTcQikccEQLyA7GSkC2n7kgKdN5i8AGss6zv6mZJWtEbMO6ziPgCvCxjOvpBT1rn3k4svHr52gp6HiENVma7K023PP/2IRrl+G6GeJzksI= 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=gdYTJc9E; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=X7EIYyX/; 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="gdYTJc9E"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="X7EIYyX/" Date: Tue, 30 Jun 2026 09:48:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782812892; 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=KQolElGh/5tfqN6Y9fux5Rg7KyAALcNsfNSvukoYUQw=; b=gdYTJc9ERuCc8ILM/RsLpWeijeTkejQkgM/S51mjRsAbU/+bKtMBNkbdTFnAwI+5u5/F2L cQe5kLWe7yift/7KdQTgEWDGxZrYa2Uzom0F2KJ6pSthQFoHNJCk1q6PkaGa0RZV/QCOFx 4n/PsRlI3GnbvxOAmjYZi4lxsdyLROPJIgHaJIzXBbayJvmNv8UyzgTzVxpQfoXj4P5/z2 2BTFGdWpS0eC30XCuvo+JaiMK1GOAXJInfcmG+VRzsAQl9QuPuRR4+V1Aex7/5sQcBwqwj By74/wNTJK9QOvgg6+gtXsWW4c+nHUfOg9EGaccnS4YtzVAcbwJkZfVo6KpztA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782812892; 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=KQolElGh/5tfqN6Y9fux5Rg7KyAALcNsfNSvukoYUQw=; b=X7EIYyX/5fFJOHxpkEJJ5bD+OmqTvhDerjEnO6FbOqs49w0YEPZsvOTYSqxBz3YxHGBU1L ZpXK0Rk31pZmYZAg== 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: <20260616044654.3468742-9-dapeng1.mi@linux.intel.com> References: <20260616044654.3468742-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: <178281289064.3843924.16801965129525302354.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: a4573a3838ae4fc73b70019cfa1dac9aaea7cc2f Gitweb: https://git.kernel.org/tip/a4573a3838ae4fc73b70019cfa1dac9aaea= 7cc2f Author: Dapeng Mi AuthorDate: Tue, 16 Jun 2026 12:46:54 +08:00 Committer: Peter Zijlstra CommitterDate: Tue, 30 Jun 2026 11:46:08 +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/20260616044654.3468742-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;