Re: [PATCH] ipmi:ssif: Stop the thread before shutting down the timers

From: Corey Minyard

Date: Thu Nov 19 2026 - 14:50:17 EST


On Thu, Nov 19, 2026 at 06:53:39PM +0000, Deepak Gudiseva wrote:
> shutdown_ssif() deletes retry_timer and watch_timer and only then stops
> the kssif thread. The wait at the start of shutdown_ssif() only waits
> for ssif_state to become SSIF_IDLE, but a normal message is sent in
> SSIF_IDLE with curr_msg set (see IS_SSIF_IDLE()), so the thread may
> still be sending one. If that write fails, msg_written_handler() arms
> retry_timer again after timer_delete_sync() has returned. The caller
> then frees ssif_info with the timer pending, and the timer fires on
> freed memory.

Yeah, I see the problem. Thanks for the detailed description.

This is queued for next release.

-corey

>
> We hit this on a kernel without commit 88f65f903d25 ("ipmi:ssif:
> Improve detecting during probing"), with a BMC that NAKs every SSIF
> request: registration failed and the interface was shut down while a
> request was still being retried. When the freed slot had been reused,
> call_timer_fn() jumped to whatever was then in timer->function:
>
> kernel tried to execute NX-protected page - exploit attempt? (uid: 0)
> BUG: unable to handle page fault for address: ffff888101f30900
> RIP: 0010:0xffff888101f30900
> Call Trace:
> <IRQ>
> call_timer_fn+0x24/0xf0
> __run_timers+0x197/0x200
>
> Since that commit the probe gives up on such a BMC. On current mainline
> this needs a BMC that stops answering after the probe, for example
> while it resets, and an unbind or unload of ipmi_ssif while a request
> to it is being retried.
>
> Checking ->stopping before that mod_timer(), as the other retry_timer
> users do, would not close the window: shutdown_ssif() can set ->stopping
> and delete the timer between the check and the mod_timer(). Stop the
> thread first, then shut the timers down with timer_shutdown_sync(), so
> that nothing can arm them again.
>
> Fixes: 00bb7e763ec9 ("ipmi:ssif: Add a timer between request retries")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Deepak Gudiseva <deepakgudiseva@xxxxxxxxxx>
> ---
> Not reproduced on mainline; the trace is from an older kernel, where
> the fix was tested on hardware. Mainline is build-tested (W=1) only.
>
> If this does not apply to older stable trees, I can send backports.
> ---
> drivers/char/ipmi/ipmi_ssif.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
> index 3a11fc4f35..10393aca05 100644
> --- a/drivers/char/ipmi/ipmi_ssif.c
> +++ b/drivers/char/ipmi/ipmi_ssif.c
> @@ -1285,12 +1285,13 @@ static void shutdown_ssif(void *send_info)
> schedule_timeout(1);
>
> ssif_info->stopping = true;
> - timer_delete_sync(&ssif_info->watch_timer);
> - timer_delete_sync(&ssif_info->retry_timer);
> if (ssif_info->thread) {
> kthread_stop(ssif_info->thread);
> ssif_info->thread = NULL;
> }
> +
> + timer_shutdown_sync(&ssif_info->watch_timer);
> + timer_shutdown_sync(&ssif_info->retry_timer);
> }
>
> static void ssif_remove(struct i2c_client *client)
>
> ---
> base-commit: 63fdb511c27afcebce797e3db580b3534ddfa639
> change-id: 20261118-ipmi-add-smi-races-0b8bce266803
>
> Best regards,
> --
> Deepak Gudiseva <deepakgudiseva@xxxxxxxxxx>
>