linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] hwmon: (asus_wmi_ec_sensors) fix array overflow
@ 2021-11-30 10:50 Dan Carpenter
  2021-11-30 10:51 ` [PATCH 2/2] hwmon: (asus_wmi_sensors) fix an " Dan Carpenter
  2021-11-30 14:43 ` [PATCH 1/2] hwmon: (asus_wmi_ec_sensors) fix " Guenter Roeck
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2021-11-30 10:50 UTC (permalink / raw)
  To: Eugene Shalygin
  Cc: Denis Pauk, Jean Delvare, Guenter Roeck, Andy Shevchenko,
	linux-hwmon, linux-kernel, kernel-janitors

Smatch detected an array out of bounds error:

    drivers/hwmon/asus_wmi_ec_sensors.c:562 asus_wmi_ec_configure_sensor_setup()
    error: buffer overflow 'hwmon_attributes' 8 <= 9

The hwmon_attributes[] array needs to be declared with "hwmon_max"
elements.

Fixes: c04c7f7bfcbe ("hwmon: (asus_wmi_ec_sensors) Support B550 Asus WMI.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/hwmon/asus_wmi_ec_sensors.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/asus_wmi_ec_sensors.c b/drivers/hwmon/asus_wmi_ec_sensors.c
index f612abc66c89..22a1459305a7 100644
--- a/drivers/hwmon/asus_wmi_ec_sensors.c
+++ b/drivers/hwmon/asus_wmi_ec_sensors.c
@@ -41,7 +41,7 @@
 #define ASUSWMI_MAX_BUF_LEN		128
 #define SENSOR_LABEL_LEN		16
 
-static u32 hwmon_attributes[] = {
+static u32 hwmon_attributes[hwmon_max] = {
 	[hwmon_chip]	= HWMON_C_REGISTER_TZ,
 	[hwmon_temp]	= HWMON_T_INPUT | HWMON_T_LABEL,
 	[hwmon_in]	= HWMON_I_INPUT | HWMON_I_LABEL,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] hwmon: (asus_wmi_sensors) fix an array overflow
  2021-11-30 10:50 [PATCH 1/2] hwmon: (asus_wmi_ec_sensors) fix array overflow Dan Carpenter
@ 2021-11-30 10:51 ` Dan Carpenter
  2021-11-30 14:43   ` Guenter Roeck
  2021-11-30 14:43 ` [PATCH 1/2] hwmon: (asus_wmi_ec_sensors) fix " Guenter Roeck
  1 sibling, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2021-11-30 10:51 UTC (permalink / raw)
  To: Ed Brindley
  Cc: Denis Pauk, Jean Delvare, Guenter Roeck, linux-hwmon,
	linux-kernel, kernel-janitors

Smatch detects this array overflow:

    drivers/hwmon/asus_wmi_sensors.c:569 asus_wmi_configure_sensor_setup()
    error: buffer overflow 'hwmon_attributes' 8 <= 9

The hwmon_attributes[] array should have "hwmon_max" so that it gets
larger when more attributes are added.

Fixes: 9d07e54a25b8 ("hwmon: (asus_wmi_sensors) Support X370 Asus WMI.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/hwmon/asus_wmi_sensors.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/asus_wmi_sensors.c b/drivers/hwmon/asus_wmi_sensors.c
index 67af15d99396..c80eee874b6c 100644
--- a/drivers/hwmon/asus_wmi_sensors.c
+++ b/drivers/hwmon/asus_wmi_sensors.c
@@ -125,7 +125,7 @@ static enum hwmon_sensor_types asus_data_types[] = {
 	[WATER_FLOW]	= hwmon_fan,
 };
 
-static u32 hwmon_attributes[] = {
+static u32 hwmon_attributes[hwmon_max] = {
 	[hwmon_chip]	= HWMON_C_REGISTER_TZ,
 	[hwmon_temp]	= HWMON_T_INPUT | HWMON_T_LABEL,
 	[hwmon_in]	= HWMON_I_INPUT | HWMON_I_LABEL,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] hwmon: (asus_wmi_ec_sensors) fix array overflow
  2021-11-30 10:50 [PATCH 1/2] hwmon: (asus_wmi_ec_sensors) fix array overflow Dan Carpenter
  2021-11-30 10:51 ` [PATCH 2/2] hwmon: (asus_wmi_sensors) fix an " Dan Carpenter
@ 2021-11-30 14:43 ` Guenter Roeck
  1 sibling, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2021-11-30 14:43 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Eugene Shalygin, Denis Pauk, Jean Delvare, Andy Shevchenko,
	linux-hwmon, linux-kernel, kernel-janitors

On Tue, Nov 30, 2021 at 01:50:34PM +0300, Dan Carpenter wrote:
> Smatch detected an array out of bounds error:
> 
>     drivers/hwmon/asus_wmi_ec_sensors.c:562 asus_wmi_ec_configure_sensor_setup()
>     error: buffer overflow 'hwmon_attributes' 8 <= 9
> 
> The hwmon_attributes[] array needs to be declared with "hwmon_max"
> elements.
> 
> Fixes: c04c7f7bfcbe ("hwmon: (asus_wmi_ec_sensors) Support B550 Asus WMI.")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/asus_wmi_ec_sensors.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/asus_wmi_ec_sensors.c b/drivers/hwmon/asus_wmi_ec_sensors.c
> index f612abc66c89..22a1459305a7 100644
> --- a/drivers/hwmon/asus_wmi_ec_sensors.c
> +++ b/drivers/hwmon/asus_wmi_ec_sensors.c
> @@ -41,7 +41,7 @@
>  #define ASUSWMI_MAX_BUF_LEN		128
>  #define SENSOR_LABEL_LEN		16
>  
> -static u32 hwmon_attributes[] = {
> +static u32 hwmon_attributes[hwmon_max] = {
>  	[hwmon_chip]	= HWMON_C_REGISTER_TZ,
>  	[hwmon_temp]	= HWMON_T_INPUT | HWMON_T_LABEL,
>  	[hwmon_in]	= HWMON_I_INPUT | HWMON_I_LABEL,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] hwmon: (asus_wmi_sensors) fix an array overflow
  2021-11-30 10:51 ` [PATCH 2/2] hwmon: (asus_wmi_sensors) fix an " Dan Carpenter
@ 2021-11-30 14:43   ` Guenter Roeck
  0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2021-11-30 14:43 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Ed Brindley, Denis Pauk, Jean Delvare, linux-hwmon, linux-kernel,
	kernel-janitors

On Tue, Nov 30, 2021 at 01:51:17PM +0300, Dan Carpenter wrote:
> Smatch detects this array overflow:
> 
>     drivers/hwmon/asus_wmi_sensors.c:569 asus_wmi_configure_sensor_setup()
>     error: buffer overflow 'hwmon_attributes' 8 <= 9
> 
> The hwmon_attributes[] array should have "hwmon_max" so that it gets
> larger when more attributes are added.
> 
> Fixes: 9d07e54a25b8 ("hwmon: (asus_wmi_sensors) Support X370 Asus WMI.")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/asus_wmi_sensors.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/asus_wmi_sensors.c b/drivers/hwmon/asus_wmi_sensors.c
> index 67af15d99396..c80eee874b6c 100644
> --- a/drivers/hwmon/asus_wmi_sensors.c
> +++ b/drivers/hwmon/asus_wmi_sensors.c
> @@ -125,7 +125,7 @@ static enum hwmon_sensor_types asus_data_types[] = {
>  	[WATER_FLOW]	= hwmon_fan,
>  };
>  
> -static u32 hwmon_attributes[] = {
> +static u32 hwmon_attributes[hwmon_max] = {
>  	[hwmon_chip]	= HWMON_C_REGISTER_TZ,
>  	[hwmon_temp]	= HWMON_T_INPUT | HWMON_T_LABEL,
>  	[hwmon_in]	= HWMON_I_INPUT | HWMON_I_LABEL,

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-30 14:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-30 10:50 [PATCH 1/2] hwmon: (asus_wmi_ec_sensors) fix array overflow Dan Carpenter
2021-11-30 10:51 ` [PATCH 2/2] hwmon: (asus_wmi_sensors) fix an " Dan Carpenter
2021-11-30 14:43   ` Guenter Roeck
2021-11-30 14:43 ` [PATCH 1/2] hwmon: (asus_wmi_ec_sensors) fix " Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).