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 0600141A549 for ; Mon, 5 Oct 2026 22:12:46 +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=1791238368; cv=none; b=fSlM7JzDLkePqGXnhIPkwbjLyv1KW03cc39vJev0DYVNA0gZqIMXFtnyxd3eQ6pxLqUN6PNDlFQzlLbO+nCd3jUFZiMvphaYfU/SgPKSDEfMgrd+ukWNgwaZ65ayzT4mFZn0+HDrRy/G9c/10JgvFOkxTH659tTsTsBSgeY19G4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791238368; c=relaxed/simple; bh=C07NBeRzGEuXKwOxO038QJuwp67YaJiR42vDllsiGfg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hpN32zQIUxwf9OLkCoA5CJpm51tuZmiquXfja9DH7DEbfKprWwdUovVSUKJTmKd96/4aSI1bVKbDdHMTvW16J+NH3cA1BoMcVVbAZfUPTTU53tA6xIDQ0LvFma26ylcBFHAgGWFR+d4I+3irgWxo9Wxj6qgUgGqY32tFA202qSk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WHouq2Yh; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WHouq2Yh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B2FF1F000FF; Mon, 5 Oct 2026 22:12:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791238366; bh=WYpP92992Ddn/hjhQmuRBOkHKwWBA0GoxvprPFEZmjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WHouq2Yhb8+Z78J0y7o8pdS5Bc84ew/lbYKV7VFSpWR5Lm4t6S3LtrTu/xKi7cKXM 8989MP+LD4Bl9St7osTNn/0hIbDyIwOf+GAaUsiiML9V2WHLR0g60x4W3GqRC+iAL2 EKVgJ0fY+FEXf07m7mKPX1U9jGaELBLkdFyj0Xu6qcpEQU6IW4gtHeCH1oDmvNeG/T CdlCMvnSLCP38e30yVG4WZwYcfc7cb8ypx2sy10H15CuWWEmCF4eWoNxQz/mzrs5hh DO3h1JxMndaKSo4qYFAykpYGrreHxUv7f9mWWbhgTk8pFF4RppOEM9Im3LX6XBypRO GitTQ5Y/hD+Hw== From: Sasha Levin To: stable@vger.kernel.org Cc: Zhengchuan Liang , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 6.12.y 3/3] perf: Require kernel access for text poke events Date: Mon, 5 Oct 2026 18:12:39 -0400 Message-ID: <20261005221222.3426405-3-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261005221222.3426405-1-sashal@kernel.org> References: <2026100517-flask-antiviral-2fbf@gregkh> <20261005221222.3426405-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Zhengchuan Liang [ Upstream commit 357e8a77a501d96c9517f01f4a211eed5e9c9184 ] Perf events with exclude_kernel=1 can be opened without kernel perf access. However, exclude_kernel does not suppress text-poke sideband records. Every PERF_RECORD_TEXT_POKE is marked PERF_RECORD_MISC_KERNEL and contains a raw kernel instruction address. An unprivileged task can therefore open and mmap a task-local software event with text_poke=1. Both opening a count-only tracepoint event and configuring UDP GRO for ESP-in-UDP cause updates to inline static calls; the observer receives the relocated addresses of the modified instructions. For a known kernel image, any such address reveals the runtime kernel text base despite KASLR. Call perf_allow_kernel() whenever attr.text_poke is set, regardless of exclude_kernel. Events that neither monitor kernel execution nor request text-poke records retain their existing permissions. Fixes: e17d43b93e54 ("perf: Add perf text poke event") Assisted-by: LLM Signed-off-by: Zhengchuan Liang Signed-off-by: Peter Zijlstra (Intel) Cc: stable@vger.kernel.org Link: https://patch.msgid.link/99131354c41e23188f778b92f90363775b482395.1790573390.git.zcliangcn@gmail.com Signed-off-by: Sasha Levin --- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 3791c84ffe2cf..41f05c932e15b 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -12893,7 +12893,7 @@ SYSCALL_DEFINE5(perf_event_open, if (err) return err; - if (!attr.exclude_kernel || + if (!attr.exclude_kernel || attr.text_poke || ((attr.sample_type & PERF_SAMPLE_CALLCHAIN) && !attr.exclude_callchain_kernel)) { err = perf_allow_kernel(); -- 2.53.0