From: Corey Minyard <corey@minyard.net>
To: Sasha Levin <sashal@kernel.org>, stable@vger.kernel.org
Cc: Li Xiao <252270051@hdu.edu.cn>, Corey Minyard <corey@minyard.net>,
Corey Minyard <cminyard@mvista.com>
Subject: [PATCH 5.15.y v3 1/4] ipmi:ssif: Fix a shutdown race
Date: Mon, 11 May 2026 08:09:23 -0500 [thread overview]
Message-ID: <20260511131100.1772190-2-corey@minyard.net> (raw)
In-Reply-To: <20260511131100.1772190-1-corey@minyard.net>
It was possible for the SSIF thread to stop and quit before the
kthread_stop() call because ssif->stopping was set before the
stop. So only exit the SSIF thread is kthread_should_stop()
returns true.
In the mainstream kernel this was fixed in 6bd0eb6d759b ("ipmi:ssif:
Fix a shutdown race"). However, that requires a fix in kernel
version 6.1 has a fix to kthread stop to cause interruptible waits
to return -ERESTARTSYS on a stop. This has not been backported to
older kernels, and that would probably be a bad idea. But it means
that the mainstrem kernel fix for this will not work.
Instead, wait for kthread_should_stop() to return true before exiting
the thread.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
drivers/char/ipmi/ipmi_ssif.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index 30f757249c5c..430302d2da6e 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -513,6 +513,16 @@ static int ipmi_ssif_thread(void *data)
}
}
+ /*
+ * The thread can break out of the loop if stopping is set,
+ * and this can be before kthread_stop() gets called and thus
+ * kthread_should_stop() will not be set. This can cause
+ * spinning calling this function and other bad things. So
+ * wait for kthread_should_stop() to be set.
+ */
+ while (!kthread_should_stop())
+ msleep_interruptible(1);
+
return 0;
}
--
2.43.0
next prev parent reply other threads:[~2026-05-11 13:11 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 5.15-stable tree gregkh
2026-05-01 14:27 ` [PATCH 5.15.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
2026-05-01 14:27 ` [PATCH 5.15.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
2026-05-01 16:11 ` [PATCH 5.15.y] ipmi:ssif: Fix a thread shutdown issue Corey Minyard
2026-05-06 2:18 ` [PATCH 5.15.y] ipmi:ssif: Clean up kthread on errors Corey Minyard
2026-05-09 12:46 ` Sasha Levin
2026-05-11 13:09 ` [PATCH 5.15.y v3 0/4] Fix error in IPMI SSIF shutdown Corey Minyard
2026-05-11 13:09 ` Corey Minyard [this message]
2026-05-11 13:09 ` [PATCH 5.15.y v3 2/4] ipmi:ssif: Clean up kthread on errors Corey Minyard
2026-05-11 13:09 ` [PATCH 5.15.y v3 3/4] ipmi:ssif: Remove unnecessary indention Corey Minyard
2026-05-11 13:09 ` [PATCH 5.15.y v3 4/4] ipmi:ssif: NULL thread on error Corey Minyard
2026-05-12 0:17 ` [PATCH 5.15.y v3 0/4] Fix error in IPMI SSIF shutdown Sasha Levin
2026-05-11 13:19 ` [PATCH 5.10.y v3 1/4] " Corey Minyard
2026-05-11 13:19 ` [PATCH 5.10.y v3 1/4] ipmi:ssif: Fix a shutdown race Corey Minyard
2026-05-11 13:19 ` [PATCH 5.10.y v3 2/4] ipmi:ssif: Clean up kthread on errors Corey Minyard
2026-05-11 13:19 ` [PATCH 5.10.y v3 3/4] ipmi:ssif: Remove unnecessary indention Corey Minyard
2026-05-11 13:19 ` [PATCH 5.10.y v3 4/4] ipmi:ssif: NULL thread on error Corey Minyard
2026-05-12 0:17 ` [PATCH 5.10.y v3 1/4] Fix error in IPMI SSIF shutdown Sasha Levin
2026-05-12 2:06 ` Corey Minyard
-- strict thread matches above, loose matches on Subject: below --
2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 5.10-stable tree gregkh
2026-05-01 14:54 ` [PATCH 5.10.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
2026-05-01 14:54 ` [PATCH 5.10.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
2026-05-01 16:20 ` [PATCH 5.10.y] ipmi:ssif: Fix a thread shutdown issue Corey Minyard
2026-05-06 2:20 ` [PATCH 5.10.y] ipmi:ssif: Clean up kthread on errors Corey Minyard
2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 6.1-stable tree gregkh
2026-05-01 14:19 ` [PATCH 6.1.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
2026-05-01 14:19 ` [PATCH 6.1.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 6.12-stable tree gregkh
2026-05-01 13:56 ` [PATCH 6.12.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
2026-05-01 13:56 ` [PATCH 6.12.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
2026-05-03 18:19 ` [PATCH 6.12.y/6.6.y/6.1.y/5.15.y/5.10.y 1-2/2] ipmi:ssif: shutdown race + kthread cleanup Sasha Levin
2026-05-04 11:04 ` Corey Minyard
2026-05-01 10:58 FAILED: patch "[PATCH] ipmi:ssif: Clean up kthread on errors" failed to apply to 6.6-stable tree gregkh
2026-05-01 14:06 ` [PATCH 6.6.y 1/2] ipmi:ssif: Fix a shutdown race Corey Minyard
2026-05-01 14:06 ` [PATCH 6.6.y 2/2] ipmi:ssif: Clean up kthread on errors Corey Minyard
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=20260511131100.1772190-2-corey@minyard.net \
--to=corey@minyard.net \
--cc=252270051@hdu.edu.cn \
--cc=cminyard@mvista.com \
--cc=sashal@kernel.org \
--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