From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CA563B95FA; Fri, 4 Sep 2026 05:31:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788499874; cv=none; b=gTbcyDyQWeZSajxxTIgDgS9NaO1CYnuY4fiwCfq0l5PvBozMCzFJw/Nq8eX/m+8RYWm2rEvqPXlV+NI47Us5lBoMqvswN03TlR26Lz2VDcdpjwWbWBw4UbObz6iWpKCswCcx3n/1Ux9emIFQChEkbfZJQEWK47mOPtmq1V/n2pw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788499874; c=relaxed/simple; bh=X3HqeO/RULd8xho56HXMFOyAeU8S+QXiMfd7k7GMhnY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pudBmLxdIYiYrSjrh9/crCt/T5irzA9RHFpaANVzIXclxrfzvESkGphkzzZBORQ5S7P3o1WWPwlTFOpLwyok4qb/Kotb61DZ+ej6FS9xBBViGug1XqySVvhyTK0ConWt0CibsceoVUDFeM/y4KK3aPzErEMBwsgVMsqrEJ63eS8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kXSNJlVJ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kXSNJlVJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4A981F00A3D; Fri, 4 Sep 2026 05:31:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788499873; bh=RID5YeFeab71r3iKSt06sGfaU45humSCI2fvG4qcTFI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kXSNJlVJUNGiEK2dmnppG4ss7sPHZzVId07lJMB0qOeedgnTzpsZomkE6N10b+YTY tRAq2iuf+h5XpSTf6zwScGAQFNlXd6jPJb8aMKRMe2tJWMkJgF2K9fqPjxhjHjrqFY A9C5bGlBOjhTzYp8WEIvKLI/oCfim+/pGzIZUMrs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mark Pearson , Thorsten Blum , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 7.2 570/713] platform/x86: think-lmi: Fix current password length check Date: Fri, 4 Sep 2026 06:58:58 +0200 Message-ID: <20260904045816.597117102@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260904045803.810145556@linuxfoundation.org> References: <20260904045803.810145556@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thorsten Blum commit 54745d563114b74f6fecebce68cd020d06c1772b upstream. 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 Signed-off-by: Thorsten Blum Link: https://patch.msgid.link/20260818151635.37094-2-thorsten.blum@linux.dev Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen Signed-off-by: Greg Kroah-Hartman --- drivers/platform/x86/lenovo/think-lmi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- 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(st 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; }