mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Corey Minyard <corey@minyard.net>
To: Deepak Gudiseva <deepakgudiseva@nexthop.ai>
Cc: openipmi-developer@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] ipmi:ssif: Stop the thread before shutting down the timers
Date: Thu, 19 Nov 2026 13:49:34 -0600	[thread overview]
Message-ID: <av9SzjAnkoPaqYea@mail.minyard.net> (raw)
In-Reply-To: <20261119-ipmi-add-smi-races-v1-1-3b8b3648c512@nexthop.ai>

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@vger.kernel.org
> Signed-off-by: Deepak Gudiseva <deepakgudiseva@nexthop.ai>
> ---
> 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@nexthop.ai>
> 

      reply	other threads:[~2026-11-19 19:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 18:53 Deepak Gudiseva
2026-11-19 19:49 ` Corey Minyard [this message]

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=av9SzjAnkoPaqYea@mail.minyard.net \
    --to=corey@minyard.net \
    --cc=deepakgudiseva@nexthop.ai \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openipmi-developer@lists.sourceforge.net \
    --cc=stable@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®