Skip to contentSkip to conversation

ACPI: Property: Fix type detection of unified integer reading functions

PATCH Applied Stefan Binding 4 participants 8 messages Aug 12, 2022 – Aug 25, 2022 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: Property: Fix type detection of unified integer reading functions

The current code expects the type of the value to be an integer type, instead the value passed to the macro is a pointer.
Ensure the size comparison uses the correct pointer type to choose the max value, instead of using the integer type.

Fixes 923044133367 ("ACPI: property: Unify integer value reading functions")
---
 drivers/acpi/property.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/property.c +4 -4
index 7b3ad8ed2f4e..b1d4a8db89df 100644
@@ -1043,10 +1043,10 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data,
 				break;					\
 			}						\
 			if (__items[i].integer.value > _Generic(__val,	\
-								u8: U8_MAX, \
-								u16: U16_MAX, \
-								u32: U32_MAX, \
-								u64: U64_MAX, \
+								u8 *: U8_MAX, \
+								u16 *: U16_MAX, \
+								u32 *: U32_MAX, \
+								u64 *: U64_MAX, \
 								default: 0U)) { \
 				ret = -EOVERFLOW;			\
 				break;					\
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Stefan,

Quoted 21 lines · Stefan Binding

The current code expects the type of the value to be an integer type, instead the value passed to the macro is a pointer.
Ensure the size comparison uses the correct pointer type to choose the max value, instead of using the integer type.

Fixes 923044133367 ("ACPI: property: Unify integer value reading functions")
---
 drivers/acpi/property.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/property.c +0 -1
index 7b3ad8ed2f4e..b1d4a8db89df 100644
@@ -1043,10 +1043,10 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data,
 				break;					\
 			}						\
 			if (__items[i].integer.value > _Generic(__val,	\
-								u8: U8_MAX, \

drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 1052

Quoted 10 lines
drivers/acpi/property.c +4 -3
-								u16: U16_MAX, \
-								u32: U32_MAX, \
-								u64: U64_MAX, \
+								u8 *: U8_MAX, \
+								u16 *: U16_MAX, \
+								u32 *: U32_MAX, \
+								u64 *: U64_MAX, \
 								default: 0U)) { \
 				ret = -EOVERFLOW;			\
 				break;					\

Thanks for the patch.

I prefer this fix over the other as it uses the pointer type (rather than value at a given index). Both have the same effect though.

Signature · 3 lines
Kind regards,

Sakari Ailus
Acked-by on v1 1/1
#4 lore raw
In reply to Stefan Binding
Quoted 8 lines

The current code expects the type of the value to be an integer type, instead the value passed to the macro is a pointer.
Ensure the size comparison uses the correct pointer type to choose the max value, instead of using the integer type.

Fixes 923044133367 ("ACPI: property: Unify integer value reading functions")

Can we get this queued up and sent out please? This is breaking some ACPI arm64 systems, which use device properties for their MAC addresses.

Some grumbling about the original patch below.

Quoted 11 lines
---
 drivers/acpi/property.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/property.c +0 -0
index 7b3ad8ed2f4e..b1d4a8db89df 100644
@@ -1043,10 +1043,10 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data,
 				break;					\
 			}						\

drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 1050

Quoted 10 lines
drivers/acpi/property.c +4 -4
 			if (__items[i].integer.value > _Generic(__val,	\
-								u8: U8_MAX, \
-								u16: U16_MAX, \
-								u32: U32_MAX, \
-								u64: U64_MAX, \
+								u8 *: U8_MAX, \
+								u16 *: U16_MAX, \
+								u32 *: U32_MAX, \
+								u64 *: U64_MAX, \
 								default: 0U)) { \

Why is there a default here? Having one is what hides the fact that the patch was completely broken.

drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 1052

Quoted 3 lines
drivers/acpi/property.c +0 -0
 				ret = -EOVERFLOW;			\
 				break;					\

Also, I must ask: given how broken the original patch is, I suppose no testing whatsoever was done?

Thanks,
Ard.

#5 lore raw
Quoted 6 lines · Ard Biesheuvel
Quoted 6 lines

The current code expects the type of the value to be an integer type, instead the value passed to the macro is a pointer.
Ensure the size comparison uses the correct pointer type to choose the max value, instead of using the integer type.

Quoted 8 lines
Quoted 3 lines
Fixes 923044133367 ("ACPI: property: Unify integer value reading functions")

Can we get this queued up and sent out please? This is breaking some ACPI arm64 systems, which use device properties for their MAC addresses.

It is in my queue for -rc3.

Quoted 17 lines

Some grumbling about the original patch below.

Quoted 15 lines
---
 drivers/acpi/property.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/property.c +0 -3
index 7b3ad8ed2f4e..b1d4a8db89df 100644
@@ -1043,10 +1043,10 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data,
                              break;                                  \
                      }                                               \
                      if (__items[i].integer.value > _Generic(__val,  \
-                                                             u8: U8_MAX, \
-                                                             u16: U16_MAX, \
-                                                             u32: U32_MAX, \
Quoted 8 lines

drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 1050

Quoted 6 lines
drivers/acpi/property.c +4 -1
-                                                             u64: U64_MAX, \
+                                                             u8 *: U8_MAX, \
+                                                             u16 *: U16_MAX, \
+                                                             u32 *: U32_MAX, \
+                                                             u64 *: U64_MAX, \
                                                              default: 0U)) { \

Why is there a default here? Having one is what hides the fact that the patch was completely broken.

Sakari?

Quoted 5 lines

drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 1052

Quoted 3 lines
drivers/acpi/property.c +0 -0
                              ret = -EOVERFLOW;                       \
                              break;                                  \

Also, I must ask: given how broken the original patch is, I suppose no testing whatsoever was done?

#6 lore raw
In reply to Ard Biesheuvel

Hi Ard,

Quoted 31 lines · Ard Biesheuvel
Quoted 8 lines

The current code expects the type of the value to be an integer type, instead the value passed to the macro is a pointer.
Ensure the size comparison uses the correct pointer type to choose the max value, instead of using the integer type.

Fixes 923044133367 ("ACPI: property: Unify integer value reading functions")

Can we get this queued up and sent out please? This is breaking some ACPI arm64 systems, which use device properties for their MAC addresses.

Some grumbling about the original patch below.

Quoted 15 lines
---
 drivers/acpi/property.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/property.c +0 -3
index 7b3ad8ed2f4e..b1d4a8db89df 100644
@@ -1043,10 +1043,10 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data,
 				break;					\
 			}						\
 			if (__items[i].integer.value > _Generic(__val,	\
-								u8: U8_MAX, \
-								u16: U16_MAX, \
-								u32: U32_MAX, \
Quoted 8 lines

drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 1050

Quoted 6 lines
drivers/acpi/property.c +4 -1
-								u64: U64_MAX, \
+								u8 *: U8_MAX, \
+								u16 *: U16_MAX, \
+								u32 *: U32_MAX, \
+								u64 *: U64_MAX, \
 								default: 0U)) { \

Why is there a default here? Having one is what hides the fact that the patch was completely broken.

I think the default can be removed. I can send a patch.

Quoted 6 lines

drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 1052

Quoted 4 lines
drivers/acpi/property.c +0 -0
 				ret = -EOVERFLOW;			\
 				break;					\

Also, I must ask: given how broken the original patch is, I suppose no testing whatsoever was done?

Testing was done but it failed to uncover this. It seems all the properties in the system were of buffer type.

Please wrap your lines before 80. It'll be easier to read that way.

Signature · 3 lines
Kind regards,

Sakari Ailus
#7 lore raw
Quoted 44 lines · Sakari Ailus

Hi Ard,

Quoted 31 lines · Ard Biesheuvel
Quoted 8 lines

The current code expects the type of the value to be an integer type, instead the value passed to the macro is a pointer.
Ensure the size comparison uses the correct pointer type to choose the max value, instead of using the integer type.

Fixes 923044133367 ("ACPI: property: Unify integer value reading functions")

Can we get this queued up and sent out please? This is breaking some ACPI arm64 systems, which use device properties for their MAC addresses.

Some grumbling about the original patch below.

Quoted 15 lines
---
 drivers/acpi/property.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/property.c +0 -3
index 7b3ad8ed2f4e..b1d4a8db89df 100644
@@ -1043,10 +1043,10 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data,
                            break;                                  \
                    }                                               \
                    if (__items[i].integer.value > _Generic(__val,  \
-                                                           u8: U8_MAX, \
-                                                           u16: U16_MAX, \
-                                                           u32: U32_MAX, \
Quoted 8 lines

drivers/acpi/property.c static int acpi_data_prop_read_single(const struct acpi_device_data *data, · line 1050

Quoted 6 lines
drivers/acpi/property.c +4 -1
-                                                           u64: U64_MAX, \
+                                                           u8 *: U8_MAX, \
+                                                           u16 *: U16_MAX, \
+                                                           u32 *: U32_MAX, \
+                                                           u64 *: U64_MAX, \
                                                            default: 0U)) { \

Why is there a default here? Having one is what hides the fact that the patch was completely broken.

Quoted 1 line

I think the default can be removed. I can send a patch.

Please do.