From: sashiko-bot@kernel.org
To: "Thomas Richter" <tmricht@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>
Subject: Re: [PATCH] s390/pai: Prevent ioctl(PERF_EVENT_IOC_REFRESH)
Date: Thu, 27 Aug 2026 06:57:09 +0000 [thread overview]
Message-ID: <20260827065709.D6E561F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827064612.3161950-1-tmricht@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unprotected modification of core perf_event state (pending_kill, event_limit) causes data races, dropped signals, and silently breaks the PERF_EVENT_IOC_REFRESH API.
--
commit ae843d6ca679921720078776be6911f36a1931c1
Author: Thomas Richter <tmricht@linux.ibm.com>
s390/pai: Prevent ioctl(PERF_EVENT_IOC_REFRESH)
This commit prevents ioctl(fd, PERF_EVENT_IOC_REFRESH, XXX) from taking effect
on PAI PMU events by clearing event->pending_kill and event->event_limit. The
intention is to prevent counter resets that conflict with the schedule-out
readouts these PMUs are designed for.
> diff --git a/arch/s390/kernel/perf_pai.c b/arch/s390/kernel/perf_pai.c
> index cdb8006220ca0..e43b2f1c94471 100644
> --- a/arch/s390/kernel/perf_pai.c
> +++ b/arch/s390/kernel/perf_pai.c
> @@ -658,6 +658,8 @@ static void pai_have_sample(struct perf_event *event, struct pai_map *cpump)
>
> if (!event) /* No event active */
> return;
> + event->pending_kill = 0; /* prevent ioctl(IOC_REFRESH) */
> + atomic_set(&event->event_limit, 0);
[Severity: High]
Does this unprotected modification of core perf_event state (pending_kill,
event_limit) cause data races, dropped signals, and silently break the
PERF_EVENT_IOC_REFRESH API?
Bypassing core perf locking rules to directly mutate event_limit and
pending_kill causes data races, silently drops pending SIGIO signals, and
breaks the API contract. The ioctl will return success, but userspace will
never receive the requested signal, leading to application hangs.
If a userspace application calls ioctl(fd, PERF_EVENT_IOC_REFRESH, N) on a
PAI event, and concurrently, a context switch calls pai_have_sample(),
writing to event_limit will race with atomic_add() in the core subsystem,
and clearing pending_kill will race with perf_event_wakeup().
PMU drivers should not directly mutate these core fields to implicitly break
an ioctl. This approach creates cross-CPU data races because it lacks the
synchronization (ctx->mutex for limits, irq_work execution order for signals)
used by the core subsystem. Any user with access to the PAI PMU can trigger
this state corruption.
> pp = &pai_pmu[PAI_PMU_IDX(event)];
> rawsize = pai_copy(cpump->save, cpump->area, pp,
> (unsigned long *)PAI_SAVE_AREA(event),
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260827064612.3161950-1-tmricht@linux.ibm.com?part=1
next prev parent reply other threads:[~2026-08-27 6:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 6:46 [PATCH] s390/pai: Prevent ioctl(PERF_EVENT_IOC_REFRESH) Thomas Richter
2026-08-27 6:57 ` sashiko-bot [this message]
2026-08-31 9:45 ` Thomas Richter
2026-08-31 13:49 ` Heiko Carstens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260827065709.D6E561F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tmricht@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox