All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Carstens <hca@linux.ibm.com>
To: Thomas Richter <tmricht@linux.ibm.com>
Cc: sashiko-reviews@lists.linux.dev,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	linux-s390@vger.kernel.org, Vasily Gorbik <gor@linux.ibm.com>,
	Sumanth Korikkar <sumanthk@linux.ibm.com>,
	Jan Polensky <japo@linux.ibm.com>
Subject: Re: [PATCH] s390/pai: Handle multiple PMU stop callback invocations
Date: Fri, 14 Aug 2026 15:05:49 +0200	[thread overview]
Message-ID: <20260814130549.15373B35-hca@linux.ibm.com> (raw)
In-Reply-To: <e13682db-e68a-4196-807b-8c67bea68a2a@linux.ibm.com>

On Thu, Aug 13, 2026 at 11:33:59AM +0200, Thomas Richter wrote:
> On 8/13/26 09:21, sashiko-bot@kernel.org wrote:
> > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> > 
> > Pre-existing issues:
> > - [High] Unsafe iteration over `cpump->syswide_list` in `pai_have_samples()` leads to a kernel crash (LIST_POISON dereference) if an event overflows and is synchronously throttled during the loop.
> > --
> 
> This can not happen. The syswide_list is anchored by per-CPU pai_map::syswide_list and tracks
> all events which are bound to that particular CPU. The event was installed only on that particular
> CPU and does not move with the process/task. Each CPU has its own list anchored by
>  pai_map::syswide_list.
> 
> The call chains are either
> 
>  paicrypt_sched_task() or paiext_sched_task
>  +--> pai_have_samples() iterates over syswide_list and calls
>       +--> pai_have_sample
...
>  I think this is safe or am I mistaken?

Looks like this is not safe. The following can happen:

-> pai_have_sample()
 -> pai_push_sample()
  -> perf_event_overflow()
   -> event->pmu->stop()
    -> pai_stop()
     -> list_del() modifies the list being traversed
      -> potential crash when list traversal continues

As sashiko proposed: using list_for_each_entry_safe() instead of
list_for_each_entry() would avoid that potential scenario.

  reply	other threads:[~2026-08-14 13:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13  7:08 [PATCH] s390/pai: Handle multiple PMU stop callback invocations Thomas Richter
2026-08-13  7:21 ` sashiko-bot
2026-08-13  9:09   ` Thomas Richter
2026-08-13  9:33   ` Thomas Richter
2026-08-14 13:05     ` Heiko Carstens [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-08-14 12:19 Thomas Richter
2026-08-14 12:39 ` sashiko-bot

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=20260814130549.15373B35-hca@linux.ibm.com \
    --to=hca@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=japo@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sumanthk@linux.ibm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.