From: Heiko Carstens <hca@linux.ibm.com>
To: Thomas Richter <tmricht@linux.ibm.com>
Cc: sashiko-reviews@lists.linux.dev,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
linux-s390@vger.kernel.org
Subject: Re: [PATCH] s390/cpum_cf: Handle CPU hotplug add and delete
Date: Sun, 9 Aug 2026 20:18:49 +0200 [thread overview]
Message-ID: <20260809181849.21067A92-hca@linux.ibm.com> (raw)
In-Reply-To: <3c6b0cc3-18db-404b-9419-fdc1d3249bd5@linux.ibm.com>
> > [Severity: High]
> > This is a pre-existing issue, but is it possible for an interrupt to
> > dereference this pointer after it is freed?
> >
> > Since cpum_cf_free_cpu() executes with interrupts enabled, if a CPUMF
> > measurement alert interrupt triggers right after kfree(cpuhw) but before
> > p->cpucf is set to NULL:
> >
> > cpum_cf_free_cpu()
> > kfree(cpuhw);
> >
> > --- interrupt occurs ---
> > cpumf_measurement_alert()
> > this_cpu_cfhw() -> returns p->cpucf
> > ... accesses freed memory ...
> >
> > Would it be safer to clear the pointer before calling kfree?
>
> The interrupt handler is shared an protects against a NULL ptr:
> /*
> * Measurement alerts are shared and might happen when the PMU
> * is not reserved. Ignore these alerts in this case.
> */
> cpuhw = this_cpu_cfhw();
> if (!cpuhw)
> return;
This is not the problem outlined above. In the described scenario
kfree(cpuhw) is done, then an interrupt happens, and the interrupt
handler sees and potentially uses the already freed memory, since
this_cpu_cfhw() does _not_ return NULL.
Problem is that data is freed before the pointer is set to NULL.
next prev parent reply other threads:[~2026-08-09 18:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 13:11 [PATCH] s390/cpum_cf: Handle CPU hotplug add and delete Thomas Richter
2026-08-06 13:29 ` sashiko-bot
2026-08-07 11:46 ` Thomas Richter
2026-08-09 18:18 ` Heiko Carstens [this message]
2026-08-09 18:25 ` Heiko Carstens
-- strict thread matches above, loose matches on Subject: below --
2026-07-31 9:51 Thomas Richter
2026-07-31 10:06 ` 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=20260809181849.21067A92-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=gor@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