From: Nagamani PV <nagamani@linux.ibm.com>
To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com
Cc: wintera@linux.ibm.com, aswin@linux.ibm.com, hca@linux.ibm.com,
gor@linux.ibm.com, agordeev@linux.ibm.com,
borntraeger@linux.ibm.com, svens@linux.ibm.com, kees@kernel.org,
linux-s390@vger.kernel.org, netdev@vger.kernel.org,
Nagamani PV <nagamani@linux.ibm.com>,
stable@vger.kernel.org, Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH net v4 1/2] s390/ctcm: Fix timer corruption in fsm_addtimer()
Date: Wed, 30 Sep 2026 09:02:33 +0200 [thread overview]
Message-ID: <20260930070234.569500-2-nagamani@linux.ibm.com> (raw)
In-Reply-To: <20260930070234.569500-1-nagamani@linux.ibm.com>
fsm_addtimer() calls timer_setup() unconditionally before add_timer().
If called on an already-pending timer, timer_setup() re-initializes
the timer's list_head fields while the timer is still enqueued in the
wheel, corrupting the timer list.
The timer is already initialized once by fsm_settimer() which calls
timer_setup() correctly. Multiple callsites invoke fsm_addtimer()
without a preceding fsm_deltimer(), including ctcm_main.c
ctcmpc_send_sweep_req() and ctcm_mpc.c mpc_action_side_xid(), making the
redundant timer_setup() in fsm_addtimer() a real corruption risk.
Remove the redundant timer_setup() calls from fsm_addtimer() and
fsm_modtimer(), and replace add_timer() with mod_timer() which safely
handles both pending and non-pending timers atomically without
corrupting the timer wheel.
Fixes: e99e88a9d2b0 ("treewide: setup_timer() -> timer_setup()")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20260803182736.2356374-1-nagamani@linux.ibm.com?part=1
Reviewed-by: Aswin Karuvally <aswin@linux.ibm.com>
Tested-by: Aswin Karuvally <aswin@linux.ibm.com>
Signed-off-by: Nagamani PV <nagamani@linux.ibm.com>
---
Changes in v4:
- No changes to this patch.
Changes in v3:
- No changes to this patch.
Changes in v2:
- Fix function name ctcm_send_sweep() -> ctcmpc_send_sweep_req()
in the commit message.
- Call mod_timer() then return 0 explicitly, preserving the
"Always returns 0" contract documented in fsm.h.
---
drivers/s390/net/fsm.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/s390/net/fsm.c b/drivers/s390/net/fsm.c
index 9b8622aef807..936ed0bc8401 100644
--- a/drivers/s390/net/fsm.c
+++ b/drivers/s390/net/fsm.c
@@ -171,11 +171,9 @@ fsm_addtimer(fsm_timer *this, int millisec, int event, void *arg)
this->fi->name, this, millisec);
#endif
- timer_setup(&this->tl, fsm_expire_timer, 0);
this->expire_event = event;
this->event_arg = arg;
- this->tl.expires = jiffies + (millisec * HZ) / 1000;
- add_timer(&this->tl);
+ mod_timer(&this->tl, jiffies + msecs_to_jiffies(millisec));
return 0;
}
@@ -189,12 +187,9 @@ fsm_modtimer(fsm_timer *this, int millisec, int event, void *arg)
this->fi->name, this, millisec);
#endif
- timer_delete(&this->tl);
- timer_setup(&this->tl, fsm_expire_timer, 0);
this->expire_event = event;
this->event_arg = arg;
- this->tl.expires = jiffies + (millisec * HZ) / 1000;
- add_timer(&this->tl);
+ mod_timer(&this->tl, jiffies + msecs_to_jiffies(millisec));
}
EXPORT_SYMBOL(init_fsm);
--
2.53.0
next prev parent reply other threads:[~2026-09-30 7:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 7:02 [PATCH net v4 0/2] s390/ctcm: Fix timer corruption and use-after-free Nagamani PV
2026-09-30 7:02 ` Nagamani PV [this message]
2026-09-30 7:14 ` [PATCH net v4 1/2] s390/ctcm: Fix timer corruption in fsm_addtimer() sashiko-bot
2026-10-05 17:16 ` Simon Horman
2026-09-30 7:02 ` [PATCH net v4 2/2] s390/ctcm: Fix use-after-free in channel_remove() Nagamani PV
2026-09-30 7:14 ` sashiko-bot
2026-10-01 11:35 ` Aswin Karuvally
2026-10-04 7:17 ` netdev-bot+sashiko
2026-10-05 8:48 ` Nagamani PV
2026-10-05 17:16 ` Simon Horman
2026-09-30 7:09 ` [PATCH net v4 0/2] s390/ctcm: Fix timer corruption and use-after-free netdev-bot+sinfo
2026-10-01 8:06 ` Nagamani PV
2026-10-06 0:34 ` Jakub Kicinski
2026-10-06 0:40 ` patchwork-bot+netdevbpf
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=20260930070234.569500-2-nagamani@linux.ibm.com \
--to=nagamani@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=andrew+netdev@lunn.ch \
--cc=aswin@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sashiko-bot@kernel.org \
--cc=stable@vger.kernel.org \
--cc=svens@linux.ibm.com \
--cc=wintera@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