linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ACPICA: Replace fake flexible arrays with flexible array members
@ 2023-01-27 19:16 Kees Cook
  2023-01-27 19:43 ` Rafael J. Wysocki
  2023-02-13  0:35 ` Guenter Roeck
  0 siblings, 2 replies; 8+ messages in thread
From: Kees Cook @ 2023-01-27 19:16 UTC (permalink / raw)
  To: Rafael J . Wysocki
  Cc: Kees Cook, Rafael J. Wysocki, Len Brown, Robert Moore,
	linux-kernel, linux-acpi, devel, linux-hardening

One-element arrays (and multi-element arrays being treated as
dynamically sized) are deprecated[1] and are being replaced with
flexible array members in support of the ongoing efforts to tighten the
FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing
with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.

Replace one-element array with flexible-array member in struct
acpi_resource_extended_irq. Replace 4-byte fixed-size array with 4-byte
padding in a union with a flexible-array member in struct
acpi_pci_routing_table.

This results in no differences in binary output.

Link: https://github.com/acpica/acpica/pull/813
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
v2: include stddef.h and switch to __DECLARE_FLEX_ARRAY()
v1: https://lore.kernel.org/lkml/20221118181538.never.225-kees@kernel.org/
---
 include/acpi/acrestyp.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h
index a7fb8ddb3dc6..250046a7c870 100644
--- a/include/acpi/acrestyp.h
+++ b/include/acpi/acrestyp.h
@@ -10,6 +10,8 @@
 #ifndef __ACRESTYP_H__
 #define __ACRESTYP_H__
 
+#include <linux/stddef.h>
+
 /*
  * Definitions for Resource Attributes
  */
@@ -332,7 +334,7 @@ struct acpi_resource_extended_irq {
 	u8 wake_capable;
 	u8 interrupt_count;
 	struct acpi_resource_source resource_source;
-	u32 interrupts[1];
+	u32 interrupts[];
 };
 
 struct acpi_resource_generic_register {
@@ -679,7 +681,10 @@ struct acpi_pci_routing_table {
 	u32 pin;
 	u64 address;		/* here for 64-bit alignment */
 	u32 source_index;
-	char source[4];		/* pad to 64 bits so sizeof() works in all cases */
+	union {
+		char pad[4];	/* pad to 64 bits so sizeof() works in all cases */
+		__DECLARE_FLEX_ARRAY(char, source);
+	};
 };
 
 #endif				/* __ACRESTYP_H__ */
-- 
2.34.1


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

* Re: [PATCH v2] ACPICA: Replace fake flexible arrays with flexible array members
  2023-01-27 19:16 [PATCH v2] ACPICA: Replace fake flexible arrays with flexible array members Kees Cook
@ 2023-01-27 19:43 ` Rafael J. Wysocki
  2023-01-27 19:47   ` Kees Cook
  2023-02-13  0:35 ` Guenter Roeck
  1 sibling, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2023-01-27 19:43 UTC (permalink / raw)
  To: Kees Cook
  Cc: Rafael J . Wysocki, Rafael J. Wysocki, Len Brown, Robert Moore,
	linux-kernel, linux-acpi, devel, linux-hardening

On Fri, Jan 27, 2023 at 8:16 PM Kees Cook <keescook@chromium.org> wrote:
>
> One-element arrays (and multi-element arrays being treated as
> dynamically sized) are deprecated[1] and are being replaced with
> flexible array members in support of the ongoing efforts to tighten the
> FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing
> with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.
>
> Replace one-element array with flexible-array member in struct
> acpi_resource_extended_irq. Replace 4-byte fixed-size array with 4-byte
> padding in a union with a flexible-array member in struct
> acpi_pci_routing_table.
>
> This results in no differences in binary output.
>
> Link: https://github.com/acpica/acpica/pull/813
> Signed-off-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> v2: include stddef.h and switch to __DECLARE_FLEX_ARRAY()
> v1: https://lore.kernel.org/lkml/20221118181538.never.225-kees@kernel.org/
> ---
>  include/acpi/acrestyp.h | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h
> index a7fb8ddb3dc6..250046a7c870 100644
> --- a/include/acpi/acrestyp.h
> +++ b/include/acpi/acrestyp.h
> @@ -10,6 +10,8 @@
>  #ifndef __ACRESTYP_H__
>  #define __ACRESTYP_H__
>
> +#include <linux/stddef.h>
> +
>  /*
>   * Definitions for Resource Attributes
>   */
> @@ -332,7 +334,7 @@ struct acpi_resource_extended_irq {
>         u8 wake_capable;
>         u8 interrupt_count;
>         struct acpi_resource_source resource_source;
> -       u32 interrupts[1];
> +       u32 interrupts[];
>  };
>
>  struct acpi_resource_generic_register {
> @@ -679,7 +681,10 @@ struct acpi_pci_routing_table {
>         u32 pin;
>         u64 address;            /* here for 64-bit alignment */
>         u32 source_index;
> -       char source[4];         /* pad to 64 bits so sizeof() works in all cases */
> +       union {
> +               char pad[4];    /* pad to 64 bits so sizeof() works in all cases */
> +               __DECLARE_FLEX_ARRAY(char, source);
> +       };
>  };
>
>  #endif                         /* __ACRESTYP_H__ */
> --

With this applied I get:

rafael@gratch:~/work/linux-pm/tools/power/acpi> make
 DESCEND tools/acpidbg
 MKDIR    include
 CP       include
 CC       tools/acpidbg/acpidbg.o
In file included from
/scratch/rafael/work/linux-pm/tools/power/acpi/include/acpi/acpi.h:27:0,
                from acpidbg.c:9:
/scratch/rafael/work/linux-pm/tools/power/acpi/include/acpi/acrestyp.h:686:3:
error: expected specif
ier-qualifier-list before ‘__DECLARE_FLEX_ARRAY’
  __DECLARE_FLEX_ARRAY(char, source);
  ^~~~~~~~~~~~~~~~~~~~
make[1]: *** [../../Makefile.rules:25:
/scratch/rafael/work/linux-pm/tools/power/acpi/tools/acpidbg/
acpidbg.o] Error 1
make: *** [Makefile:18: acpidbg] Error 2

The tools build successfully without it.

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

* Re: [PATCH v2] ACPICA: Replace fake flexible arrays with flexible array members
  2023-01-27 19:43 ` Rafael J. Wysocki
@ 2023-01-27 19:47   ` Kees Cook
  2023-01-27 19:51     ` Rafael J. Wysocki
  0 siblings, 1 reply; 8+ messages in thread
From: Kees Cook @ 2023-01-27 19:47 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Rafael J . Wysocki, Len Brown, Robert Moore, linux-kernel,
	linux-acpi, devel, linux-hardening

On Fri, Jan 27, 2023 at 08:43:05PM +0100, Rafael J. Wysocki wrote:
> On Fri, Jan 27, 2023 at 8:16 PM Kees Cook <keescook@chromium.org> wrote:
> >
> > One-element arrays (and multi-element arrays being treated as
> > dynamically sized) are deprecated[1] and are being replaced with
> > flexible array members in support of the ongoing efforts to tighten the
> > FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing
> > with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.
> >
> > Replace one-element array with flexible-array member in struct
> > acpi_resource_extended_irq. Replace 4-byte fixed-size array with 4-byte
> > padding in a union with a flexible-array member in struct
> > acpi_pci_routing_table.
> >
> > This results in no differences in binary output.
> >
> > Link: https://github.com/acpica/acpica/pull/813
> > Signed-off-by: Kees Cook <keescook@chromium.org>
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > ---
> > v2: include stddef.h and switch to __DECLARE_FLEX_ARRAY()
> > v1: https://lore.kernel.org/lkml/20221118181538.never.225-kees@kernel.org/
> > ---
> >  include/acpi/acrestyp.h | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h
> > index a7fb8ddb3dc6..250046a7c870 100644
> > --- a/include/acpi/acrestyp.h
> > +++ b/include/acpi/acrestyp.h
> > @@ -10,6 +10,8 @@
> >  #ifndef __ACRESTYP_H__
> >  #define __ACRESTYP_H__
> >
> > +#include <linux/stddef.h>
> > +
> >  /*
> >   * Definitions for Resource Attributes
> >   */
> > @@ -332,7 +334,7 @@ struct acpi_resource_extended_irq {
> >         u8 wake_capable;
> >         u8 interrupt_count;
> >         struct acpi_resource_source resource_source;
> > -       u32 interrupts[1];
> > +       u32 interrupts[];
> >  };
> >
> >  struct acpi_resource_generic_register {
> > @@ -679,7 +681,10 @@ struct acpi_pci_routing_table {
> >         u32 pin;
> >         u64 address;            /* here for 64-bit alignment */
> >         u32 source_index;
> > -       char source[4];         /* pad to 64 bits so sizeof() works in all cases */
> > +       union {
> > +               char pad[4];    /* pad to 64 bits so sizeof() works in all cases */
> > +               __DECLARE_FLEX_ARRAY(char, source);
> > +       };
> >  };
> >
> >  #endif                         /* __ACRESTYP_H__ */
> > --
> 
> With this applied I get:
> 
> rafael@gratch:~/work/linux-pm/tools/power/acpi> make
>  DESCEND tools/acpidbg
>  MKDIR    include
>  CP       include
>  CC       tools/acpidbg/acpidbg.o
> In file included from
> /scratch/rafael/work/linux-pm/tools/power/acpi/include/acpi/acpi.h:27:0,
>                 from acpidbg.c:9:
> /scratch/rafael/work/linux-pm/tools/power/acpi/include/acpi/acrestyp.h:686:3:
> error: expected specif
> ier-qualifier-list before ‘__DECLARE_FLEX_ARRAY’
>   __DECLARE_FLEX_ARRAY(char, source);
>   ^~~~~~~~~~~~~~~~~~~~
> make[1]: *** [../../Makefile.rules:25:
> /scratch/rafael/work/linux-pm/tools/power/acpi/tools/acpidbg/
> acpidbg.o] Error 1
> make: *** [Makefile:18: acpidbg] Error 2
> 
> The tools build successfully without it.

I think a "make clean" is needed first? It builds for me...

-- 
Kees Cook

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

* Re: [PATCH v2] ACPICA: Replace fake flexible arrays with flexible array members
  2023-01-27 19:47   ` Kees Cook
@ 2023-01-27 19:51     ` Rafael J. Wysocki
  0 siblings, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2023-01-27 19:51 UTC (permalink / raw)
  To: Kees Cook
  Cc: Rafael J. Wysocki, Rafael J . Wysocki, Len Brown, Robert Moore,
	linux-kernel, linux-acpi, devel, linux-hardening

On Fri, Jan 27, 2023 at 8:47 PM Kees Cook <keescook@chromium.org> wrote:
>
> On Fri, Jan 27, 2023 at 08:43:05PM +0100, Rafael J. Wysocki wrote:
> > On Fri, Jan 27, 2023 at 8:16 PM Kees Cook <keescook@chromium.org> wrote:
> > >
> > > One-element arrays (and multi-element arrays being treated as
> > > dynamically sized) are deprecated[1] and are being replaced with
> > > flexible array members in support of the ongoing efforts to tighten the
> > > FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing
> > > with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.
> > >
> > > Replace one-element array with flexible-array member in struct
> > > acpi_resource_extended_irq. Replace 4-byte fixed-size array with 4-byte
> > > padding in a union with a flexible-array member in struct
> > > acpi_pci_routing_table.
> > >
> > > This results in no differences in binary output.
> > >
> > > Link: https://github.com/acpica/acpica/pull/813
> > > Signed-off-by: Kees Cook <keescook@chromium.org>
> > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > > ---
> > > v2: include stddef.h and switch to __DECLARE_FLEX_ARRAY()
> > > v1: https://lore.kernel.org/lkml/20221118181538.never.225-kees@kernel.org/
> > > ---
> > >  include/acpi/acrestyp.h | 9 +++++++--
> > >  1 file changed, 7 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h
> > > index a7fb8ddb3dc6..250046a7c870 100644
> > > --- a/include/acpi/acrestyp.h
> > > +++ b/include/acpi/acrestyp.h
> > > @@ -10,6 +10,8 @@
> > >  #ifndef __ACRESTYP_H__
> > >  #define __ACRESTYP_H__
> > >
> > > +#include <linux/stddef.h>
> > > +
> > >  /*
> > >   * Definitions for Resource Attributes
> > >   */
> > > @@ -332,7 +334,7 @@ struct acpi_resource_extended_irq {
> > >         u8 wake_capable;
> > >         u8 interrupt_count;
> > >         struct acpi_resource_source resource_source;
> > > -       u32 interrupts[1];
> > > +       u32 interrupts[];
> > >  };
> > >
> > >  struct acpi_resource_generic_register {
> > > @@ -679,7 +681,10 @@ struct acpi_pci_routing_table {
> > >         u32 pin;
> > >         u64 address;            /* here for 64-bit alignment */
> > >         u32 source_index;
> > > -       char source[4];         /* pad to 64 bits so sizeof() works in all cases */
> > > +       union {
> > > +               char pad[4];    /* pad to 64 bits so sizeof() works in all cases */
> > > +               __DECLARE_FLEX_ARRAY(char, source);
> > > +       };
> > >  };
> > >
> > >  #endif                         /* __ACRESTYP_H__ */
> > > --
> >
> > With this applied I get:
> >
> > rafael@gratch:~/work/linux-pm/tools/power/acpi> make
> >  DESCEND tools/acpidbg
> >  MKDIR    include
> >  CP       include
> >  CC       tools/acpidbg/acpidbg.o
> > In file included from
> > /scratch/rafael/work/linux-pm/tools/power/acpi/include/acpi/acpi.h:27:0,
> >                 from acpidbg.c:9:
> > /scratch/rafael/work/linux-pm/tools/power/acpi/include/acpi/acrestyp.h:686:3:
> > error: expected specif
> > ier-qualifier-list before ‘__DECLARE_FLEX_ARRAY’
> >   __DECLARE_FLEX_ARRAY(char, source);
> >   ^~~~~~~~~~~~~~~~~~~~
> > make[1]: *** [../../Makefile.rules:25:
> > /scratch/rafael/work/linux-pm/tools/power/acpi/tools/acpidbg/
> > acpidbg.o] Error 1
> > make: *** [Makefile:18: acpidbg] Error 2
> >
> > The tools build successfully without it.
>
> I think a "make clean" is needed first? It builds for me...

I think that the default user space header files on this machine may
not be up to date.

I'll apply the v2, thanks!

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

* Re: [PATCH v2] ACPICA: Replace fake flexible arrays with flexible array members
  2023-01-27 19:16 [PATCH v2] ACPICA: Replace fake flexible arrays with flexible array members Kees Cook
  2023-01-27 19:43 ` Rafael J. Wysocki
@ 2023-02-13  0:35 ` Guenter Roeck
  2023-02-13 19:31   ` Wysocki, Rafael J
  2023-02-13 19:51   ` Kees Cook
  1 sibling, 2 replies; 8+ messages in thread
From: Guenter Roeck @ 2023-02-13  0:35 UTC (permalink / raw)
  To: Kees Cook
  Cc: Rafael J . Wysocki, Rafael J. Wysocki, Len Brown, Robert Moore,
	linux-kernel, linux-acpi, devel, linux-hardening

Hi,

On Fri, Jan 27, 2023 at 11:16:25AM -0800, Kees Cook wrote:
> One-element arrays (and multi-element arrays being treated as
> dynamically sized) are deprecated[1] and are being replaced with
> flexible array members in support of the ongoing efforts to tighten the
> FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing
> with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.
> 
> Replace one-element array with flexible-array member in struct
> acpi_resource_extended_irq. Replace 4-byte fixed-size array with 4-byte
> padding in a union with a flexible-array member in struct
> acpi_pci_routing_table.
> 
> This results in no differences in binary output.
> 
> Link: https://github.com/acpica/acpica/pull/813
> Signed-off-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

This patch results in boot failures of 32-bit images.
Reverting it fixes the problem.

On the failing boot tests, I see messages such as

ACPI: \_SB_.GSIA: Enabled at IRQ 117440528
ERROR: Unable to locate IOAPIC for GSI 117440528
ahci 0000:00:1f.2: PCI INT A: failed to register GSI

ACPI: \_SB_.GSIG: Enabled at IRQ 117440534
ERROR: Unable to locate IOAPIC for GSI 117440534
8139cp 0000:00:02.0: PCI INT A: failed to register GSI

Given that 117440534 == 0x7000016, that looks quite suspicious.
Indeed, after reverting this patch, the messages are different.

ACPI: \_SB_.GSIA: Enabled at IRQ 16
ahci 0000:00:1f.2: AHCI 0001.0000 32 slots 6 ports 1.5 Gbps 0x3f impl SATA mode

ACPI: \_SB_.GSIG: Enabled at IRQ 22
8139cp 0000:00:02.0 eth0: RTL-8139C+ at 0xd0804000, 52:54:00:12:34:56, IRQ 22

Guenter

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

* Re: [PATCH v2] ACPICA: Replace fake flexible arrays with flexible array members
  2023-02-13  0:35 ` Guenter Roeck
@ 2023-02-13 19:31   ` Wysocki, Rafael J
  2023-02-13 19:51   ` Kees Cook
  1 sibling, 0 replies; 8+ messages in thread
From: Wysocki, Rafael J @ 2023-02-13 19:31 UTC (permalink / raw)
  To: Guenter Roeck, Kees Cook
  Cc: Rafael J. Wysocki, Len Brown, Robert Moore, linux-kernel,
	linux-acpi, devel, linux-hardening


On 2/13/2023 1:35 AM, Guenter Roeck wrote:
> Hi,
>
> On Fri, Jan 27, 2023 at 11:16:25AM -0800, Kees Cook wrote:
>> One-element arrays (and multi-element arrays being treated as
>> dynamically sized) are deprecated[1] and are being replaced with
>> flexible array members in support of the ongoing efforts to tighten the
>> FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing
>> with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.
>>
>> Replace one-element array with flexible-array member in struct
>> acpi_resource_extended_irq. Replace 4-byte fixed-size array with 4-byte
>> padding in a union with a flexible-array member in struct
>> acpi_pci_routing_table.
>>
>> This results in no differences in binary output.
>>
>> Link: https://github.com/acpica/acpica/pull/813
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> This patch results in boot failures of 32-bit images.
> Reverting it fixes the problem.
>
> On the failing boot tests, I see messages such as
>
> ACPI: \_SB_.GSIA: Enabled at IRQ 117440528
> ERROR: Unable to locate IOAPIC for GSI 117440528
> ahci 0000:00:1f.2: PCI INT A: failed to register GSI
>
> ACPI: \_SB_.GSIG: Enabled at IRQ 117440534
> ERROR: Unable to locate IOAPIC for GSI 117440534
> 8139cp 0000:00:02.0: PCI INT A: failed to register GSI
>
> Given that 117440534 == 0x7000016, that looks quite suspicious.
> Indeed, after reverting this patch, the messages are different.
>
> ACPI: \_SB_.GSIA: Enabled at IRQ 16
> ahci 0000:00:1f.2: AHCI 0001.0000 32 slots 6 ports 1.5 Gbps 0x3f impl SATA mode
>
> ACPI: \_SB_.GSIG: Enabled at IRQ 22
> 8139cp 0000:00:02.0 eth0: RTL-8139C+ at 0xd0804000, 52:54:00:12:34:56, IRQ 22

Thanks for the report, I have reverted this commit from my linux-next 
branch and will not include it into my 6.3-rc1 pull requests at all.

Thanks!



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

* Re: [PATCH v2] ACPICA: Replace fake flexible arrays with flexible array members
  2023-02-13  0:35 ` Guenter Roeck
  2023-02-13 19:31   ` Wysocki, Rafael J
@ 2023-02-13 19:51   ` Kees Cook
  2023-02-13 20:05     ` Guenter Roeck
  1 sibling, 1 reply; 8+ messages in thread
From: Kees Cook @ 2023-02-13 19:51 UTC (permalink / raw)
  To: Guenter Roeck, Kees Cook
  Cc: Rafael J . Wysocki, Rafael J. Wysocki, Len Brown, Robert Moore,
	linux-kernel, linux-acpi, devel, linux-hardening

On February 12, 2023 4:35:46 PM PST, Guenter Roeck <linux@roeck-us.net> wrote:
>Hi,
>
>On Fri, Jan 27, 2023 at 11:16:25AM -0800, Kees Cook wrote:
>> One-element arrays (and multi-element arrays being treated as
>> dynamically sized) are deprecated[1] and are being replaced with
>> flexible array members in support of the ongoing efforts to tighten the
>> FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing
>> with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.
>> 
>> Replace one-element array with flexible-array member in struct
>> acpi_resource_extended_irq. Replace 4-byte fixed-size array with 4-byte
>> padding in a union with a flexible-array member in struct
>> acpi_pci_routing_table.
>> 
>> This results in no differences in binary output.
>> 
>> Link: https://github.com/acpica/acpica/pull/813
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
>This patch results in boot failures of 32-bit images.

Weird -- I didn't see any binary differences. I'll investigate. What compiler and arch?

-Kees

>Reverting it fixes the problem.
>
>On the failing boot tests, I see messages such as
>
>ACPI: \_SB_.GSIA: Enabled at IRQ 117440528
>ERROR: Unable to locate IOAPIC for GSI 117440528
>ahci 0000:00:1f.2: PCI INT A: failed to register GSI
>
>ACPI: \_SB_.GSIG: Enabled at IRQ 117440534
>ERROR: Unable to locate IOAPIC for GSI 117440534
>8139cp 0000:00:02.0: PCI INT A: failed to register GSI
>
>Given that 117440534 == 0x7000016, that looks quite suspicious.
>Indeed, after reverting this patch, the messages are different.

Yeah, seems like a high byte not getting cleared. Hmm.

>
>ACPI: \_SB_.GSIA: Enabled at IRQ 16
>ahci 0000:00:1f.2: AHCI 0001.0000 32 slots 6 ports 1.5 Gbps 0x3f impl SATA mode
>
>ACPI: \_SB_.GSIG: Enabled at IRQ 22
>8139cp 0000:00:02.0 eth0: RTL-8139C+ at 0xd0804000, 52:54:00:12:34:56, IRQ 22
>
>Guenter


-- 
Kees Cook

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

* Re: [PATCH v2] ACPICA: Replace fake flexible arrays with flexible array members
  2023-02-13 19:51   ` Kees Cook
@ 2023-02-13 20:05     ` Guenter Roeck
  0 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2023-02-13 20:05 UTC (permalink / raw)
  To: Kees Cook, Kees Cook
  Cc: Rafael J . Wysocki, Rafael J. Wysocki, Len Brown, Robert Moore,
	linux-kernel, linux-acpi, devel, linux-hardening

On 2/13/23 11:51, Kees Cook wrote:
> On February 12, 2023 4:35:46 PM PST, Guenter Roeck <linux@roeck-us.net> wrote:
>> Hi,
>>
>> On Fri, Jan 27, 2023 at 11:16:25AM -0800, Kees Cook wrote:
>>> One-element arrays (and multi-element arrays being treated as
>>> dynamically sized) are deprecated[1] and are being replaced with
>>> flexible array members in support of the ongoing efforts to tighten the
>>> FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing
>>> with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.
>>>
>>> Replace one-element array with flexible-array member in struct
>>> acpi_resource_extended_irq. Replace 4-byte fixed-size array with 4-byte
>>> padding in a union with a flexible-array member in struct
>>> acpi_pci_routing_table.
>>>
>>> This results in no differences in binary output.
>>>
>>> Link: https://github.com/acpica/acpica/pull/813
>>> Signed-off-by: Kees Cook <keescook@chromium.org>
>>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>
>> This patch results in boot failures of 32-bit images.
> 
> Weird -- I didn't see any binary differences. I'll investigate. What compiler and arch?
> 

gcc 11.3, binutils 2.39, x86 (32-bit build). This is pretty much defconfig
with ARCH=i386 and various debug options enabled.

64-bit builds do not have the problem.

Guenter

> -Kees
> 
>> Reverting it fixes the problem.
>>
>> On the failing boot tests, I see messages such as
>>
>> ACPI: \_SB_.GSIA: Enabled at IRQ 117440528
>> ERROR: Unable to locate IOAPIC for GSI 117440528
>> ahci 0000:00:1f.2: PCI INT A: failed to register GSI
>>
>> ACPI: \_SB_.GSIG: Enabled at IRQ 117440534
>> ERROR: Unable to locate IOAPIC for GSI 117440534
>> 8139cp 0000:00:02.0: PCI INT A: failed to register GSI
>>
>> Given that 117440534 == 0x7000016, that looks quite suspicious.
>> Indeed, after reverting this patch, the messages are different.
> 
> Yeah, seems like a high byte not getting cleared. Hmm.
> 
>>
>> ACPI: \_SB_.GSIA: Enabled at IRQ 16
>> ahci 0000:00:1f.2: AHCI 0001.0000 32 slots 6 ports 1.5 Gbps 0x3f impl SATA mode
>>
>> ACPI: \_SB_.GSIG: Enabled at IRQ 22
>> 8139cp 0000:00:02.0 eth0: RTL-8139C+ at 0xd0804000, 52:54:00:12:34:56, IRQ 22
>>
>> Guenter
> 
> 


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

end of thread, other threads:[~2023-02-13 20:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27 19:16 [PATCH v2] ACPICA: Replace fake flexible arrays with flexible array members Kees Cook
2023-01-27 19:43 ` Rafael J. Wysocki
2023-01-27 19:47   ` Kees Cook
2023-01-27 19:51     ` Rafael J. Wysocki
2023-02-13  0:35 ` Guenter Roeck
2023-02-13 19:31   ` Wysocki, Rafael J
2023-02-13 19:51   ` Kees Cook
2023-02-13 20:05     ` 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).