public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions
@ 2022-08-12 13:06 Stefan Binding
  2022-08-12 19:42 ` Sakari Ailus
  2022-08-25  7:25 ` Ard Biesheuvel
  0 siblings, 2 replies; 8+ messages in thread
From: Stefan Binding @ 2022-08-12 13:06 UTC (permalink / raw)
  To: Rafael J . Wysocki, Sakari Ailus, Andy Shevchenko
  Cc: linux-acpi, linux-kernel, patches, 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")

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
---
 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


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

* Re: [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions
  2022-08-12 13:06 [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions Stefan Binding
@ 2022-08-12 19:42 ` Sakari Ailus
  2022-08-12 19:43   ` Sakari Ailus
  2022-08-25  7:25 ` Ard Biesheuvel
  1 sibling, 1 reply; 8+ messages in thread
From: Sakari Ailus @ 2022-08-12 19:42 UTC (permalink / raw)
  To: Stefan Binding
  Cc: Rafael J . Wysocki, Andy Shevchenko, linux-acpi, linux-kernel,
	patches

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 <sbinding@opensource.cirrus.com>
> ---
>  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 <sakari.ailus@linux.intel.com>

-- 
Kind regards,

Sakari Ailus

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

* Re: [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions
  2022-08-12 19:42 ` Sakari Ailus
@ 2022-08-12 19:43   ` Sakari Ailus
  2022-08-20 11:32     ` Rafael J. Wysocki
  0 siblings, 1 reply; 8+ messages in thread
From: Sakari Ailus @ 2022-08-12 19:43 UTC (permalink / raw)
  To: Stefan Binding
  Cc: Rafael J . Wysocki, Andy Shevchenko, linux-acpi, linux-kernel,
	patches

On Fri, Aug 12, 2022 at 07:42:26PM +0000, Sakari Ailus wrote:
> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>

Should have been:

Tested-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus

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

* Re: [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions
  2022-08-12 19:43   ` Sakari Ailus
@ 2022-08-20 11:32     ` Rafael J. Wysocki
  0 siblings, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2022-08-20 11:32 UTC (permalink / raw)
  To: Sakari Ailus, Stefan Binding
  Cc: Rafael J . Wysocki, Andy Shevchenko, ACPI Devel Maling List,
	Linux Kernel Mailing List, patches

On Fri, Aug 12, 2022 at 9:43 PM Sakari Ailus
<sakari.ailus@linux.intel.com> wrote:
>
> On Fri, Aug 12, 2022 at 07:42:26PM +0000, Sakari Ailus wrote:
> > Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>

This is still OK if you have reviewed the patch.

> Should have been:
>
> Tested-by: Sakari Ailus <sakari.ailus@linux.intel.com>

Applied as 6.0-rc material, thanks!

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

* Re: [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions
  2022-08-12 13:06 [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions Stefan Binding
  2022-08-12 19:42 ` Sakari Ailus
@ 2022-08-25  7:25 ` Ard Biesheuvel
  2022-08-25  7:40   ` Rafael J. Wysocki
  2022-08-25  7:45   ` Sakari Ailus
  1 sibling, 2 replies; 8+ messages in thread
From: Ard Biesheuvel @ 2022-08-25  7:25 UTC (permalink / raw)
  To: sbinding
  Cc: andriy.shevchenko, linux-acpi, linux-kernel, patches, rafael,
	sakari.ailus, Ard Biesheuvel

> 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 <sbinding@opensource.cirrus.com>

Acked-by: Ard Biesheuvel <ardb@kernel.org>

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.


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

* Re: [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions
  2022-08-25  7:25 ` Ard Biesheuvel
@ 2022-08-25  7:40   ` Rafael J. Wysocki
  2022-08-25  7:45   ` Sakari Ailus
  1 sibling, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2022-08-25  7:40 UTC (permalink / raw)
  To: Ard Biesheuvel, Sakari Ailus
  Cc: Stefan Binding, Shevchenko, Andriy, ACPI Devel Maling List,
	Linux Kernel Mailing List, patches, Rafael J. Wysocki

On Thu, Aug 25, 2022 at 9:25 AM Ard Biesheuvel <ardb@kernel.org> 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 <sbinding@opensource.cirrus.com>
>
> Acked-by: Ard Biesheuvel <ardb@kernel.org>
>
> 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?

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

* Re: [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions
  2022-08-25  7:25 ` Ard Biesheuvel
  2022-08-25  7:40   ` Rafael J. Wysocki
@ 2022-08-25  7:45   ` Sakari Ailus
  2022-08-25  7:47     ` Rafael J. Wysocki
  1 sibling, 1 reply; 8+ messages in thread
From: Sakari Ailus @ 2022-08-25  7:45 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: sbinding, andriy.shevchenko, linux-acpi, linux-kernel, patches,
	rafael

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 <sbinding@opensource.cirrus.com>
> 
> Acked-by: Ard Biesheuvel <ardb@kernel.org>
> 
> 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

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

* Re: [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions
  2022-08-25  7:45   ` Sakari Ailus
@ 2022-08-25  7:47     ` Rafael J. Wysocki
  0 siblings, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2022-08-25  7:47 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Ard Biesheuvel, Stefan Binding, Shevchenko, Andriy,
	ACPI Devel Maling List, Linux Kernel Mailing List, patches,
	Rafael J. Wysocki

On Thu, Aug 25, 2022 at 9:45 AM Sakari Ailus
<sakari.ailus@linux.intel.com> 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 <sbinding@opensource.cirrus.com>
> >
> > Acked-by: Ard Biesheuvel <ardb@kernel.org>
> >
> > 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.

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

end of thread, other threads:[~2022-08-25  7:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-12 13:06 [PATCH v1] ACPI: Property: Fix type detection of unified integer reading functions Stefan Binding
2022-08-12 19:42 ` Sakari Ailus
2022-08-12 19:43   ` Sakari Ailus
2022-08-20 11:32     ` Rafael J. Wysocki
2022-08-25  7:25 ` Ard Biesheuvel
2022-08-25  7:40   ` Rafael J. Wysocki
2022-08-25  7:45   ` Sakari Ailus
2022-08-25  7:47     ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox