diff mbox

[1/6] hwmon: (dell-smm) Fail in ioctl I8K_BIOS_VERSION when bios version is not a number

Message ID 1466204089-17030-2-git-send-email-pali.rohar@gmail.com (mailing list archive)
State Accepted
Headers show

Commit Message

Pali Rohár June 17, 2016, 10:54 p.m. UTC
ABI of I8K_BIOS_VERSION ioctl can return only number. But new BIOS versions
contain also other characters, which does not fit into that ABI. So in case
of non digit values return -EINVAL.

Reported-by: Mario Limonciello <Mario_Limonciello@dell.com>
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
 drivers/hwmon/dell-smm-hwmon.c |    5 +++++
 1 file changed, 5 insertions(+)

Comments

Guenter Roeck June 18, 2016, 8 p.m. UTC | #1
On 06/17/2016 03:54 PM, Pali Rohár wrote:
> ABI of I8K_BIOS_VERSION ioctl can return only number. But new BIOS versions
> contain also other characters, which does not fit into that ABI. So in case
> of non digit values return -EINVAL.
>
> Reported-by: Mario Limonciello <Mario_Limonciello@dell.com>
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>

Applied.

Guenter

> ---
>   drivers/hwmon/dell-smm-hwmon.c |    5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
> index c43318d..480b2fa 100644
> --- a/drivers/hwmon/dell-smm-hwmon.c
> +++ b/drivers/hwmon/dell-smm-hwmon.c
> @@ -35,6 +35,7 @@
>   #include <linux/uaccess.h>
>   #include <linux/io.h>
>   #include <linux/sched.h>
> +#include <linux/ctype.h>
>
>   #include <linux/i8k.h>
>
> @@ -387,6 +388,10 @@ i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg)
>
>   	switch (cmd) {
>   	case I8K_BIOS_VERSION:
> +		if (!isdigit(bios_version[0]) || !isdigit(bios_version[1]) ||
> +		    !isdigit(bios_version[2]))
> +			return -EINVAL;
> +
>   		val = (bios_version[0] << 16) |
>   				(bios_version[1] << 8) | bios_version[2];
>   		break;
>

--
To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
index c43318d..480b2fa 100644
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -35,6 +35,7 @@ 
 #include <linux/uaccess.h>
 #include <linux/io.h>
 #include <linux/sched.h>
+#include <linux/ctype.h>
 
 #include <linux/i8k.h>
 
@@ -387,6 +388,10 @@  i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg)
 
 	switch (cmd) {
 	case I8K_BIOS_VERSION:
+		if (!isdigit(bios_version[0]) || !isdigit(bios_version[1]) ||
+		    !isdigit(bios_version[2]))
+			return -EINVAL;
+
 		val = (bios_version[0] << 16) |
 				(bios_version[1] << 8) | bios_version[2];
 		break;