mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mark Pearson" <mpearson-lenovo@squebb.ca>
To: "Thorsten Blum" <blum@kernel.org>,
	"Derek J . Clark" <derekjohn.clark@gmail.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: "platform-driver-x86@vger.kernel.org"
	<platform-driver-x86@vger.kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86: think-lmi: Use snprintf() in new_password_store()
Date: Tue, 22 Sep 2026 13:35:59 -0400	[thread overview]
Message-ID: <b699ec3f-9708-48fa-a7cf-2f6e0d08be61@app.fastmail.com> (raw)
In-Reply-To: <20260920103035.281573-2-blum@kernel.org>

On Sun, Sep 20, 2026, at 6:30 AM, Thorsten Blum wrote:
> While the current code works correctly, replace unbounded sprintf()
> calls with the safer snprintf() in new_password_store() to follow secure
> coding best practices.
>
> Signed-off-by: Thorsten Blum <blum@kernel.org>
> ---
>  drivers/platform/x86/lenovo/think-lmi.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/platform/x86/lenovo/think-lmi.c 
> b/drivers/platform/x86/lenovo/think-lmi.c
> index a0e3fa766e37..3ddc1f5cec19 100644
> --- a/drivers/platform/x86/lenovo/think-lmi.c
> +++ b/drivers/platform/x86/lenovo/think-lmi.c
> @@ -487,16 +487,16 @@ static ssize_t new_password_store(struct kobject 
> *kobj,
>  		/* Special handling required for HDD and NVMe passwords */
>  		if (setting == tlmi_priv.pwd_hdd) {
>  			if (setting->level == TLMI_LEVEL_USER)
> -				sprintf(pwd_type, "uhdp%d", setting->index);
> +				snprintf(pwd_type, sizeof(pwd_type), "uhdp%d", setting->index);
>  			else
> -				sprintf(pwd_type, "mhdp%d", setting->index);
> +				snprintf(pwd_type, sizeof(pwd_type), "mhdp%d", setting->index);
>  		} else if (setting == tlmi_priv.pwd_nvme) {
>  			if (setting->level == TLMI_LEVEL_USER)
> -				sprintf(pwd_type, "udrp%d", setting->index);
> +				snprintf(pwd_type, sizeof(pwd_type), "udrp%d", setting->index);
>  			else
> -				sprintf(pwd_type, "adrp%d", setting->index);
> +				snprintf(pwd_type, sizeof(pwd_type), "adrp%d", setting->index);
>  		} else {
> -			sprintf(pwd_type, "%s", setting->pwd_type);
> +			snprintf(pwd_type, sizeof(pwd_type), "%s", setting->pwd_type);
>  		}
> 
>  		ret = tlmi_opcode_setting("WmiOpcodePasswordType", pwd_type);

Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Mark

      reply	other threads:[~2026-09-22 17:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-20 10:30 Thorsten Blum
2026-09-22 17:35 ` Mark Pearson [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=b699ec3f-9708-48fa-a7cf-2f6e0d08be61@app.fastmail.com \
    --to=mpearson-lenovo@squebb.ca \
    --cc=blum@kernel.org \
    --cc=derekjohn.clark@gmail.com \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@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®