[SRU][R][PATCH 0/2] complete perf_allow_* trio and use in drm/xe

Kelsey Steele kelseys at nvidia.com
Thu Jul 16 00:09:06 UTC 2026


BugLink: https://bugs.launchpad.net/bugs/2160654

SRU Justification:

[Impact]

perf_allow_cpu() and perf_allow_tracepoint() are static inline in
<linux/perf_event.h> and reference sysctl_perf_event_paranoid and
security_perf_event_open(), neither of which is exported. Modules cannot reuse
the system-wide perf permission model and open-code partial copies instead.

drm/xe does this in its OA and EU-stall observation paths, open-coding a
CPU-event check that ignores kernel.perf_event_paranoid and the
security_perf_event_open() LSM hook.

[Fix]

Move perf_allow_cpu() and perf_allow_tracepoint() out of line and export them
with EXPORT_SYMBOL_GPL (with !CONFIG_PERF_EVENTS stubs), following the
precedent of commit 5e9629d0ae97 for perf_allow_kernel(). Then convert drm/xe
OA and EU-stall paths to call perf_allow_cpu() so Xe observation honors
kernel.perf_event_paranoid and the LSM hook. dev.xe.observation_paranoid
remains as an escape hatch.

Upstream commits in linux-next/drm-next, targeting v7.3:

d32bf877c0c3 ("perf/core: out-of-line and export perf_allow_cpu/tracepoint()")
6680bf0cb726 ("drm/xe: gate observation streams with perf_allow_cpu()")

drm/xe is backported: this kernel lacks commit 41255b2f1e03 ("drm/xe/oa: Use
drm_gem_mmap_obj for OA buffer mmap"), so a duplicate int ret declaration was
dropped. perf/core is a clean cherry-pick.

Link: https://lore.kernel.org/all/20260523013326.129491-1-jhubbard@nvidia.com/

[Test Plan]

- Builds clean with CONFIG_DRM_XE=m and CONFIG_PERF_EVENTS enabled or disabled.
- Boots with no dmesg regressions.
- Module.symvers records perf_allow_cpu() and perf_allow_tracepoint() as
  EXPORT_SYMBOL_GPL; both are present in /proc/kallsyms and absent without
  the patches.
- A perf_event_paranoid sweep confirms unchanged perf_event_open()
  allow/deny behavior.

[Where problems could occur]

Patch 1 preserves existing permission behavior. Patch 2 may allow or deny Xe
observation according to the system perf and LSM policies. Only Intel Xe
systems are affected. Low risk.

John Hubbard (2):
  perf/core: out-of-line and export perf_allow_cpu/tracepoint()
  drm/xe: gate observation streams with perf_allow_cpu()

 drivers/gpu/drm/xe/xe_eu_stall.c    |  5 +++--
 drivers/gpu/drm/xe/xe_oa.c          | 25 +++++++++++++---------
 drivers/gpu/drm/xe/xe_observation.c | 32 ++++++++++++++++++++++++-----
 drivers/gpu/drm/xe/xe_observation.h |  3 +--
 include/linux/perf_event.h          | 31 ++++++++++++++--------------
 kernel/events/core.c                | 18 ++++++++++++++++
 6 files changed, 79 insertions(+), 35 deletions(-)

-- 
2.50.1 (Apple Git-155)




More information about the kernel-team mailing list