* FAILED: patch "[PATCH] platform/x86: think-lmi: Fix current password length check" failed to apply to 5.15-stable tree
@ 2026-09-03 14:49 gregkh
2026-09-09 17:12 ` [PATCH 5.15.y 1/2] platform/x86: think-lmi: mutex protection around multiple WMI calls Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2026-09-03 14:49 UTC (permalink / raw)
To: thorsten.blum, ilpo.jarvinen, mpearson-lenovo; +Cc: stable
The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 54745d563114b74f6fecebce68cd020d06c1772b
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026090343-sarcastic-pound-fa39@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 54745d563114b74f6fecebce68cd020d06c1772b Mon Sep 17 00:00:00 2001
From: Thorsten Blum <thorsten.blum@linux.dev>
Date: Tue, 18 Aug 2026 17:16:35 +0200
Subject: [PATCH] platform/x86: think-lmi: Fix current password length check
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
current_password_store() checks the password length before removing the
trailing newline, which can reject valid passwords that are exactly
->maxlen bytes long.
It also passes ->maxlen to strscpy(), which truncates passwords without
a newline.
Use strchrnul() to measure the password length up to the newline, then
copy that many bytes and add a trailing NUL terminator using strscpy().
Fixes: a40cd7ef22fb ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms")
Cc: stable@vger.kernel.org
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20260818151635.37094-2-thorsten.blum@linux.dev
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
diff --git a/drivers/platform/x86/lenovo/think-lmi.c b/drivers/platform/x86/lenovo/think-lmi.c
index ca266657e16c..a0e3fa766e37 100644
--- a/drivers/platform/x86/lenovo/think-lmi.c
+++ b/drivers/platform/x86/lenovo/think-lmi.c
@@ -438,14 +438,13 @@ static ssize_t current_password_store(struct kobject *kobj,
struct tlmi_pwd_setting *setting = to_tlmi_pwd_setting(kobj);
size_t pwdlen;
- pwdlen = strlen(buf);
+ /* Strip newline; setting password won't work if one is present. */
+ pwdlen = strchrnul(buf, '\n') - buf;
/* pwdlen == 0 is allowed to clear the password */
if (pwdlen && ((pwdlen < setting->minlen) || (pwdlen > setting->maxlen)))
return -EINVAL;
- strscpy(setting->password, buf, setting->maxlen);
- /* Strip out CR if one is present, setting password won't work if it is present */
- strreplace(setting->password, '\n', '\0');
+ strscpy(setting->password, buf, pwdlen + 1);
return count;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 5.15.y 1/2] platform/x86: think-lmi: mutex protection around multiple WMI calls
2026-09-03 14:49 FAILED: patch "[PATCH] platform/x86: think-lmi: Fix current password length check" failed to apply to 5.15-stable tree gregkh
@ 2026-09-09 17:12 ` Sasha Levin
2026-09-09 17:12 ` [PATCH 5.15.y 2/2] platform/x86: think-lmi: Fix current password length check Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2026-09-09 17:12 UTC (permalink / raw)
To: stable; +Cc: Mark Pearson, Ilpo Järvinen, Hans de Goede, Sasha Levin
From: Mark Pearson <mpearson-lenovo@squebb.ca>
[ Upstream commit c41e0121a1221894a1a9c4666156db9e1def4d6c ]
When an attribute is being changed if the Admin account is enabled, or if
a password is being updated then multiple WMI calls are needed.
Add mutex protection to ensure no race conditions are introduced.
Fixes: b49f72e7f96d ("platform/x86: think-lmi: Certificate authentication support")
Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230601200552.4396-1-mpearson-lenovo@squebb.ca
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Backport notes for 5.15:
Keep the mutex around the existing password update and BIOS setting/save
paths. This tree has no certificate or opcode authentication, so retain
the legacy password authentication code at the conflicting lock site.
All error exits after locking still release the mutex.
Use the existing strreplace() helper in current_password_store() and drop
its unused temporary pointer. This preserves the visible password string
and prepares the exact context needed by 54745d563114 ("platform/x86:
think-lmi: Fix current password length check"), without adding functions
or importing the newer authentication interfaces.
Move only think-lmi.c and think-lmi.h into the upstream lenovo/ directory,
with the corresponding Kbuild, include and MAINTAINERS adjustments. Git
cannot detect the rename against the much newer target's parent; matching
the target path allows an ordinary cherry-pick without rename overrides.
The existing CONFIG_THINKPAD_LMI option and think-lmi module name are kept.
[ sashal: Reduced backport -- upstream c41e0121a1221 touches 1 file(s), this
backport carries 5. Not backported here:
drivers/platform/x86/think-lmi.c
This note is generated from the file lists only; see the resolution record
for the reasoning. ]
Stable-dep-of: 54745d563114 ("platform/x86: think-lmi: Fix current password length check")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
MAINTAINERS | 2 +-
drivers/platform/x86/Makefile | 2 +-
drivers/platform/x86/lenovo/Makefile | 3 +++
drivers/platform/x86/{ => lenovo}/think-lmi.c | 16 ++++++++++++----
drivers/platform/x86/{ => lenovo}/think-lmi.h | 0
5 files changed, 17 insertions(+), 6 deletions(-)
create mode 100644 drivers/platform/x86/lenovo/Makefile
rename drivers/platform/x86/{ => lenovo}/think-lmi.c (98%)
rename drivers/platform/x86/{ => lenovo}/think-lmi.h (100%)
diff --git a/MAINTAINERS b/MAINTAINERS
index 6635c3ba64036..47ba4501ce67e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -18629,7 +18629,7 @@ M: Mark Pearson <markpearson@lenovo.com>
L: platform-driver-x86@vger.kernel.org
S: Maintained
F: Documentation/ABI/testing/sysfs-class-firmware-attributes
-F: drivers/platform/x86/think-lmi.?
+F: drivers/platform/x86/lenovo/think-lmi.?
THUNDERBOLT DMA TRAFFIC TEST DRIVER
M: Isaac Hazan <isaac.hazan@intel.com>
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 5dba9fe23fb15..4d70f29622d63 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -62,7 +62,7 @@ obj-$(CONFIG_IBM_RTL) += ibm_rtl.o
obj-$(CONFIG_IDEAPAD_LAPTOP) += ideapad-laptop.o
obj-$(CONFIG_SENSORS_HDAPS) += hdaps.o
obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o
-obj-$(CONFIG_THINKPAD_LMI) += think-lmi.o
+obj-y += lenovo/
# Intel
obj-y += intel/
diff --git a/drivers/platform/x86/lenovo/Makefile b/drivers/platform/x86/lenovo/Makefile
new file mode 100644
index 0000000000000..cdeb55cef7ce6
--- /dev/null
+++ b/drivers/platform/x86/lenovo/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_THINKPAD_LMI) += think-lmi.o
diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/lenovo/think-lmi.c
similarity index 98%
rename from drivers/platform/x86/think-lmi.c
rename to drivers/platform/x86/lenovo/think-lmi.c
index dde7bb7e28226..9548f96c6dad8 100644
--- a/drivers/platform/x86/think-lmi.c
+++ b/drivers/platform/x86/lenovo/think-lmi.c
@@ -14,10 +14,11 @@
#include <linux/acpi.h>
#include <linux/errno.h>
#include <linux/fs.h>
+#include <linux/mutex.h>
#include <linux/string.h>
#include <linux/types.h>
#include <linux/wmi.h>
-#include "firmware_attributes_class.h"
+#include "../firmware_attributes_class.h"
#include "think-lmi.h"
static bool debug_support;
@@ -147,6 +148,7 @@ static const char * const encoding_options[] = {
};
static struct think_lmi tlmi_priv;
static struct class *fw_attr_class;
+static DEFINE_MUTEX(tlmi_mutex);
/* ------ Utility functions ------------*/
/* Convert BIOS WMI error string to suitable error code */
@@ -324,7 +326,6 @@ static ssize_t current_password_store(struct kobject *kobj,
{
struct tlmi_pwd_setting *setting = to_tlmi_pwd_setting(kobj);
size_t pwdlen;
- char *p;
pwdlen = strlen(buf);
/* pwdlen == 0 is allowed to clear the password */
@@ -333,8 +334,7 @@ static ssize_t current_password_store(struct kobject *kobj,
strscpy(setting->password, buf, setting->maxlen);
/* Strip out CR if one is present, setting password won't work if it is present */
- p = strchrnul(setting->password, '\n');
- *p = '\0';
+ strreplace(setting->password, '\n', '\0');
return count;
}
@@ -363,6 +363,9 @@ static ssize_t new_password_store(struct kobject *kobj,
p = strchrnul(new_pwd, '\n');
*p = '\0';
+ /* Use lock in case multiple WMI operations needed */
+ mutex_lock(&tlmi_mutex);
+
pwdlen = strlen(new_pwd);
/* pwdlen == 0 is allowed to clear the password */
if (pwdlen && ((pwdlen < setting->minlen) || (pwdlen > setting->maxlen))) {
@@ -381,6 +384,7 @@ static ssize_t new_password_store(struct kobject *kobj,
ret = tlmi_simple_call(LENOVO_SET_BIOS_PASSWORD_GUID, auth_str);
kfree(auth_str);
out:
+ mutex_unlock(&tlmi_mutex);
kfree(new_pwd);
return ret ?: count;
}
@@ -568,6 +572,9 @@ static ssize_t current_value_store(struct kobject *kobj,
p = strchrnul(new_setting, '\n');
*p = '\0';
+ /* Use lock in case multiple WMI operations needed */
+ mutex_lock(&tlmi_mutex);
+
if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0]) {
auth_str = kasprintf(GFP_KERNEL, "%s,%s,%s;",
tlmi_priv.pwd_admin->password,
@@ -605,6 +612,7 @@ static ssize_t current_value_store(struct kobject *kobj,
kobject_uevent(&tlmi_priv.class_dev->kobj, KOBJ_CHANGE);
}
out:
+ mutex_unlock(&tlmi_mutex);
kfree(auth_str);
kfree(set_str);
kfree(new_setting);
diff --git a/drivers/platform/x86/think-lmi.h b/drivers/platform/x86/lenovo/think-lmi.h
similarity index 100%
rename from drivers/platform/x86/think-lmi.h
rename to drivers/platform/x86/lenovo/think-lmi.h
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 5.15.y 2/2] platform/x86: think-lmi: Fix current password length check
2026-09-09 17:12 ` [PATCH 5.15.y 1/2] platform/x86: think-lmi: mutex protection around multiple WMI calls Sasha Levin
@ 2026-09-09 17:12 ` Sasha Levin
0 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2026-09-09 17:12 UTC (permalink / raw)
To: stable; +Cc: Thorsten Blum, Mark Pearson, Ilpo Järvinen, Sasha Levin
From: Thorsten Blum <thorsten.blum@linux.dev>
[ Upstream commit 54745d563114b74f6fecebce68cd020d06c1772b ]
current_password_store() checks the password length before removing the
trailing newline, which can reject valid passwords that are exactly
->maxlen bytes long.
It also passes ->maxlen to strscpy(), which truncates passwords without
a newline.
Use strchrnul() to measure the password length up to the newline, then
copy that many bytes and add a trailing NUL terminator using strscpy().
Fixes: a40cd7ef22fb ("platform/x86: think-lmi: Add WMI interface support on Lenovo platforms")
Cc: stable@vger.kernel.org
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20260818151635.37094-2-thorsten.blum@linux.dev
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/platform/x86/lenovo/think-lmi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/x86/lenovo/think-lmi.c b/drivers/platform/x86/lenovo/think-lmi.c
index 9548f96c6dad8..c0f1818a5a5e0 100644
--- a/drivers/platform/x86/lenovo/think-lmi.c
+++ b/drivers/platform/x86/lenovo/think-lmi.c
@@ -327,14 +327,13 @@ static ssize_t current_password_store(struct kobject *kobj,
struct tlmi_pwd_setting *setting = to_tlmi_pwd_setting(kobj);
size_t pwdlen;
- pwdlen = strlen(buf);
+ /* Strip newline; setting password won't work if one is present. */
+ pwdlen = strchrnul(buf, '\n') - buf;
/* pwdlen == 0 is allowed to clear the password */
if (pwdlen && ((pwdlen < setting->minlen) || (pwdlen > setting->maxlen)))
return -EINVAL;
- strscpy(setting->password, buf, setting->maxlen);
- /* Strip out CR if one is present, setting password won't work if it is present */
- strreplace(setting->password, '\n', '\0');
+ strscpy(setting->password, buf, pwdlen + 1);
return count;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-09 17:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-03 14:49 FAILED: patch "[PATCH] platform/x86: think-lmi: Fix current password length check" failed to apply to 5.15-stable tree gregkh
2026-09-09 17:12 ` [PATCH 5.15.y 1/2] platform/x86: think-lmi: mutex protection around multiple WMI calls Sasha Levin
2026-09-09 17:12 ` [PATCH 5.15.y 2/2] platform/x86: think-lmi: Fix current password length check Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox