2022-08-12 13:26:39

by Stefan Binding

[permalink] [raw]
Subject: [PATCH v1] 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")

Signed-off-by: Stefan Binding <[email protected]>
---
drivers/acpi/property.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 7b3ad8ed2f4e..b1d4a8db89df 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -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; \
--
2.34.1


2022-08-12 20:11:50

by Sakari Ailus

[permalink] [raw]
Subject: Re: [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions

Hi Stefan,

On Fri, Aug 12, 2022 at 02:06:45PM +0100, Stefan Binding wrote:
> 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")
>
> Signed-off-by: Stefan Binding <[email protected]>
> ---
> drivers/acpi/property.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> index 7b3ad8ed2f4e..b1d4a8db89df 100644
> --- a/drivers/acpi/property.c
> +++ b/drivers/acpi/property.c
> @@ -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; \

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.

Reviewed-by: Sakari Ailus <[email protected]>

--
Kind regards,

Sakari Ailus

2022-08-12 20:43:48

by Sakari Ailus

[permalink] [raw]
Subject: Re: [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions

On Fri, Aug 12, 2022 at 07:42:26PM +0000, Sakari Ailus wrote:
> Reviewed-by: Sakari Ailus <[email protected]>

Should have been:

Tested-by: Sakari Ailus <[email protected]>

--
Sakari Ailus

2022-08-20 11:51:37

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions

On Fri, Aug 12, 2022 at 9:43 PM Sakari Ailus
<[email protected]> wrote:
>
> On Fri, Aug 12, 2022 at 07:42:26PM +0000, Sakari Ailus wrote:
> > Reviewed-by: Sakari Ailus <[email protected]>

This is still OK if you have reviewed the patch.

> Should have been:
>
> Tested-by: Sakari Ailus <[email protected]>

Applied as 6.0-rc material, thanks!

2022-08-25 07:29:34

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: [PATCH v1] 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")
>
> Signed-off-by: Stefan Binding <[email protected]>

Acked-by: Ard Biesheuvel <[email protected]>

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.

> ---
> drivers/acpi/property.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> index 7b3ad8ed2f4e..b1d4a8db89df 100644
> --- a/drivers/acpi/property.c
> +++ b/drivers/acpi/property.c
> @@ -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)) { \

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

> ret = -EOVERFLOW; \
> break; \
>

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

Thanks,
Ard.

2022-08-25 07:57:11

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions

On Thu, Aug 25, 2022 at 9:25 AM Ard Biesheuvel <[email protected]> wrote:
>
> > 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")
> >
> > Signed-off-by: Stefan Binding <[email protected]>
>
> Acked-by: Ard Biesheuvel <[email protected]>
>
> 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.

> Some grumbling about the original patch below.
>
> > ---
> > drivers/acpi/property.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> > index 7b3ad8ed2f4e..b1d4a8db89df 100644
> > --- a/drivers/acpi/property.c
> > +++ b/drivers/acpi/property.c
> > @@ -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)) { \
>
> Why is there a default here? Having one is what hides the fact that the patch was completely broken.

Sakari?

> > ret = -EOVERFLOW; \
> > break; \
> >
>
> Also, I must ask: given how broken the original patch is, I suppose no testing whatsoever was done?

2022-08-25 08:25:11

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions

On Thu, Aug 25, 2022 at 9:45 AM Sakari Ailus
<[email protected]> wrote:
>
> Hi Ard,
>
> On Thu, Aug 25, 2022 at 09:25:05AM +0200, Ard Biesheuvel wrote:
> > > 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")
> > >
> > > Signed-off-by: Stefan Binding <[email protected]>
> >
> > Acked-by: Ard Biesheuvel <[email protected]>
> >
> > 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.
> >
> > > ---
> > > drivers/acpi/property.c | 8 ++++----
> > > 1 file changed, 4 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> > > index 7b3ad8ed2f4e..b1d4a8db89df 100644
> > > --- a/drivers/acpi/property.c
> > > +++ b/drivers/acpi/property.c
> > > @@ -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)) { \
> >
> > 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.

Please do.

2022-08-25 08:25:43

by Sakari Ailus

[permalink] [raw]
Subject: Re: [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions

Hi Ard,

On Thu, Aug 25, 2022 at 09:25:05AM +0200, Ard Biesheuvel wrote:
> > 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")
> >
> > Signed-off-by: Stefan Binding <[email protected]>
>
> Acked-by: Ard Biesheuvel <[email protected]>
>
> 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.
>
> > ---
> > drivers/acpi/property.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> > index 7b3ad8ed2f4e..b1d4a8db89df 100644
> > --- a/drivers/acpi/property.c
> > +++ b/drivers/acpi/property.c
> > @@ -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)) { \
>
> 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.

>
> > 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.

--
Kind regards,

Sakari Ailus