FAILED: patch "[PATCH] platform/x86: think-lmi: Fix current password length check" failed to apply to 5.15-stable tree
Subsystems (4)
[email protected]
maintainerThe 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 <[email protected]>.
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 '<[email protected]>' --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 <[email protected]>
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().
drivers/platform/x86/lenovo/think-lmi.c +3 -4
@@ -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; }
Sasha Levin
maintainerPATCH 1/2 platform/x86: think-lmi: mutex protection around multiple WMI calls
From: Mark Pearson <[email protected]>
[ 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.
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")
---
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%)MAINTAINERS +1 -1
@@ -18629,7 +18629,7 @@ M: Mark Pearson <[email protected]> L: [email protected] 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 <[email protected]>
drivers/platform/x86/Makefile +1 -1
@@ -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/
drivers/platform/x86/lenovo/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_THINKPAD_LMI) += think-lmi.o
drivers/platform/x86/lenovo/think-lmi.c renamed from drivers/platform/x86/think-lmi.c +12 -4
@@ -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);
drivers/platform/x86/lenovo/think-lmi.h renamed from drivers/platform/x86/think-lmi.h +0 -0
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 platform/x86: think-lmi: Fix current password length check
From: Thorsten Blum <[email protected]>
[ 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().
--- drivers/platform/x86/lenovo/think-lmi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/platform/x86/lenovo/think-lmi.c +3 -4
@@ -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; }
Signature · 1 line
2.53.0