From: sashiko-bot@kernel.org
To: "Nagamani PV" <nagamani@linux.ibm.com>
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
linux-s390@vger.kernel.org,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>
Subject: Re: [PATCH net v3 2/2] s390/ctcm: Fix use-after-free in channel_remove()
Date: Wed, 23 Sep 2026 10:19:36 +0000 [thread overview]
Message-ID: <20260923101937.24C941F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260922101913.239103-3-nagamani@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] s390/ctcm: timer_delete_sync() placed after tasklet_kill() causes UAF
--
commit 93e7e140a56ccbd4e4b9fe414316e60f45884b2b
Author: Nagamani PV <nagamani@linux.ibm.com>
s390/ctcm: Fix use-after-free in channel_remove()
This commit modifies the teardown sequence in channel_remove() to fix a
use-after-free. It calls timer_delete_sync() directly instead of through
fsm_deltimer(), and kills MPC tasklets and stops the sweep timer before
deleting the main channel timer and freeing memory.
Link: https://sashiko.dev/#/patchset/20260803182736.2356374-1-nagamani@linux.ibm.com?part=1
> diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c
> --- a/drivers/s390/net/ctcm_main.c
> +++ b/drivers/s390/net/ctcm_main.c
> @@ -211,9 +211,13 @@ static void channel_remove(struct channel *ch)
> while (*c) {
> if (*c == ch) {
> *c = ch->next;
> - fsm_deltimer(&ch->timer);
> - if (IS_MPC(ch))
> - fsm_deltimer(&ch->sweep_timer);
> + if (IS_MPC(ch)) {
> + tasklet_kill(&ch->ch_tasklet);
> + tasklet_kill(&ch->ch_disc_tasklet);
> + timer_shutdown_sync(&ch->sweep_timer.tl);
> + kfree(ch->discontact_th);
> + }
> + timer_delete_sync(&ch->timer.tl);
[Severity: High]
Does placing timer_delete_sync() after tasklet_kill() and kfree() leave a race
window that could lead to a use-after-free?
If the timer callback (fsm_expire_timer) is executing concurrently on another
CPU, could it dispatch an event (e.g., via ctcm_chx_txretry()) that invokes
mpc_action_go_inop() and schedules the tasklet again?
tasklet_hi_schedule(&wch->ch_disc_tasklet);
Since tasklet_kill() has already completed, would this newly scheduled tasklet
execute later and call mpc_action_send_discontact(), initiating a DMA
operation that reads from the already freed ch->discontact_th using the freed
ch and ch->ccw structures?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260922101913.239103-1-nagamani@linux.ibm.com?part=2
next prev parent reply other threads:[~2026-09-23 10:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 10:19 [PATCH net v3 0/2] s390/ctcm: Fix timer corruption and use-after-free Nagamani PV
2026-09-22 10:19 ` [PATCH net v3 1/2] s390/ctcm: Fix timer corruption in fsm_addtimer() Nagamani PV
2026-09-23 10:19 ` sashiko-bot
2026-09-22 10:19 ` [PATCH net v3 2/2] s390/ctcm: Fix use-after-free in channel_remove() Nagamani PV
2026-09-23 10:19 ` sashiko-bot [this message]
2026-09-28 23:34 ` Jakub Kicinski
2026-09-30 7:29 ` Nagamani PV
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=20260923101937.24C941F000FF@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=nagamani@linux.ibm.com \
--cc=sashiko-reviews@lists.linux.dev \
/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