]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
platform/x86: dell-wmi-sysman: Avoid buffer overflow in current_password_store()
authorVladimir Moskovkin <Vladimir.Moskovkin@kaspersky.com>
Wed, 14 May 2025 12:12:55 +0000 (12:12 +0000)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 15 May 2025 11:52:09 +0000 (14:52 +0300)
If the 'buf' array received from the user contains an empty string, the
'length' variable will be zero. Accessing the 'buf' array element with
index 'length - 1' will result in a buffer overflow.

Add a check for an empty string.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: e8a60aa7404b ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems")
Cc: stable@vger.kernel.org
Signed-off-by: Vladimir Moskovkin <Vladimir.Moskovkin@kaspersky.com>
Link: https://lore.kernel.org/r/39973642a4f24295b4a8fad9109c5b08@kaspersky.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c

index 230e6ee966366ad809d16f2f699f1a5fc08635a5..d8f1bf5e58a0f441cfd6c21f299c5426b2e28ce9 100644 (file)
@@ -45,7 +45,7 @@ static ssize_t current_password_store(struct kobject *kobj,
        int length;
 
        length = strlen(buf);
-       if (buf[length-1] == '\n')
+       if (length && buf[length - 1] == '\n')
                length--;
 
        /* firmware does verifiation of min/max password length,