* [PATCH] ACPICA: Replace fake flexible arrays with flexible array members @ 2022-11-18 18:15 Kees Cook 2023-01-15 18:38 ` Kees Cook 0 siblings, 1 reply; 7+ messages in thread From: Kees Cook @ 2022-11-18 18:15 UTC (permalink / raw) To: Rafael J. Wysocki Cc: Kees Cook, Len Brown, Robert Moore, Gustavo A. R. Silva, linux-acpi, devel, linux-kernel, linux-hardening Functionally identical to ACPICA upstream pull request 813: https://github.com/acpica/acpica/pull/813 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. Cc: "Rafael J. Wysocki" <rafael@kernel.org> Cc: Len Brown <lenb@kernel.org> Cc: Robert Moore <robert.moore@intel.com> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> Cc: linux-acpi@vger.kernel.org Cc: devel@acpica.org Signed-off-by: Kees Cook <keescook@chromium.org> --- include/acpi/acrestyp.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h index a7fb8ddb3dc6..ee945084d46e 100644 --- a/include/acpi/acrestyp.h +++ b/include/acpi/acrestyp.h @@ -332,7 +332,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 +679,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] 7+ messages in thread
* Re: [PATCH] ACPICA: Replace fake flexible arrays with flexible array members 2022-11-18 18:15 [PATCH] ACPICA: Replace fake flexible arrays with flexible array members Kees Cook @ 2023-01-15 18:38 ` Kees Cook 2023-01-20 18:10 ` Rafael J. Wysocki 0 siblings, 1 reply; 7+ messages in thread From: Kees Cook @ 2023-01-15 18:38 UTC (permalink / raw) To: Rafael J. Wysocki Cc: Len Brown, Robert Moore, Gustavo A. R. Silva, linux-acpi, devel, linux-kernel, linux-hardening On Fri, Nov 18, 2022 at 10:15:51AM -0800, Kees Cook wrote: > Functionally identical to ACPICA upstream pull request 813: > https://github.com/acpica/acpica/pull/813 Any update on this? Upstream is currently unbuildable since October. > 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. In the meantime, can you take this patch for Linux, and we can wait for ACPICA to catch up? Thanks! -Kees > > Cc: "Rafael J. Wysocki" <rafael@kernel.org> > Cc: Len Brown <lenb@kernel.org> > Cc: Robert Moore <robert.moore@intel.com> > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > Cc: linux-acpi@vger.kernel.org > Cc: devel@acpica.org > Signed-off-by: Kees Cook <keescook@chromium.org> > --- > include/acpi/acrestyp.h | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h > index a7fb8ddb3dc6..ee945084d46e 100644 > --- a/include/acpi/acrestyp.h > +++ b/include/acpi/acrestyp.h > @@ -332,7 +332,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 +679,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 > -- Kees Cook ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ACPICA: Replace fake flexible arrays with flexible array members 2023-01-15 18:38 ` Kees Cook @ 2023-01-20 18:10 ` Rafael J. Wysocki 2023-01-20 19:16 ` Kees Cook 0 siblings, 1 reply; 7+ messages in thread From: Rafael J. Wysocki @ 2023-01-20 18:10 UTC (permalink / raw) To: Kees Cook Cc: Rafael J. Wysocki, Len Brown, Robert Moore, Gustavo A. R. Silva, linux-acpi, linux-kernel, linux-hardening, acpica-devel On Sun, Jan 15, 2023 at 7:38 PM Kees Cook <keescook@chromium.org> wrote: > > On Fri, Nov 18, 2022 at 10:15:51AM -0800, Kees Cook wrote: > > Functionally identical to ACPICA upstream pull request 813: > > https://github.com/acpica/acpica/pull/813 > > Any update on this? Upstream is currently unbuildable since October. > > > 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. > > In the meantime, can you take this patch for Linux, and we can wait for > ACPICA to catch up? Applied now (as 6.3 material), sorry for the delay. Thanks! > > > > Cc: "Rafael J. Wysocki" <rafael@kernel.org> > > Cc: Len Brown <lenb@kernel.org> > > Cc: Robert Moore <robert.moore@intel.com> > > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > > Cc: linux-acpi@vger.kernel.org > > Cc: devel@acpica.org > > Signed-off-by: Kees Cook <keescook@chromium.org> > > --- > > include/acpi/acrestyp.h | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h > > index a7fb8ddb3dc6..ee945084d46e 100644 > > --- a/include/acpi/acrestyp.h > > +++ b/include/acpi/acrestyp.h > > @@ -332,7 +332,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 +679,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 > > > > -- > Kees Cook ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ACPICA: Replace fake flexible arrays with flexible array members 2023-01-20 18:10 ` Rafael J. Wysocki @ 2023-01-20 19:16 ` Kees Cook 2023-01-27 18:08 ` Rafael J. Wysocki 0 siblings, 1 reply; 7+ messages in thread From: Kees Cook @ 2023-01-20 19:16 UTC (permalink / raw) To: Rafael J. Wysocki Cc: Len Brown, Robert Moore, Gustavo A. R. Silva, linux-acpi, linux-kernel, linux-hardening, acpica-devel On Fri, Jan 20, 2023 at 07:10:52PM +0100, Rafael J. Wysocki wrote: > On Sun, Jan 15, 2023 at 7:38 PM Kees Cook <keescook@chromium.org> wrote: > > > > On Fri, Nov 18, 2022 at 10:15:51AM -0800, Kees Cook wrote: > > > Functionally identical to ACPICA upstream pull request 813: > > > https://github.com/acpica/acpica/pull/813 > > > > Any update on this? Upstream is currently unbuildable since October. > > > > > 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. > > > > In the meantime, can you take this patch for Linux, and we can wait for > > ACPICA to catch up? > > Applied now (as 6.3 material), sorry for the delay. Thanks! -- Kees Cook ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ACPICA: Replace fake flexible arrays with flexible array members 2023-01-20 19:16 ` Kees Cook @ 2023-01-27 18:08 ` Rafael J. Wysocki 2023-01-27 18:33 ` Kees Cook 0 siblings, 1 reply; 7+ messages in thread From: Rafael J. Wysocki @ 2023-01-27 18:08 UTC (permalink / raw) To: Kees Cook Cc: Rafael J. Wysocki, Len Brown, Robert Moore, Gustavo A. R. Silva, linux-acpi, linux-kernel, linux-hardening, acpica-devel On Fri, Jan 20, 2023 at 8:16 PM Kees Cook <keescook@chromium.org> wrote: > > On Fri, Jan 20, 2023 at 07:10:52PM +0100, Rafael J. Wysocki wrote: > > On Sun, Jan 15, 2023 at 7:38 PM Kees Cook <keescook@chromium.org> wrote: > > > > > > On Fri, Nov 18, 2022 at 10:15:51AM -0800, Kees Cook wrote: > > > > Functionally identical to ACPICA upstream pull request 813: > > > > https://github.com/acpica/acpica/pull/813 > > > > > > Any update on this? Upstream is currently unbuildable since October. > > > > > > > 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. > > > > > > In the meantime, can you take this patch for Linux, and we can wait for > > > ACPICA to catch up? > > > > Applied now (as 6.3 material), sorry for the delay. > > Thanks! Unfortunately, this breaks compilation for the ACPI tools in tools/power/acpi/. Apparently, the problem is that DECLARE_FLEX_ARRAY() is not defined when the tools are built, because kernel headers are not used then. I guess the changes from your upstream PR need to be backported literally for this to work, so I'll drop this one for the time being. Or please let me know if you have a better idea. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ACPICA: Replace fake flexible arrays with flexible array members 2023-01-27 18:08 ` Rafael J. Wysocki @ 2023-01-27 18:33 ` Kees Cook 2023-01-27 18:52 ` Rafael J. Wysocki 0 siblings, 1 reply; 7+ messages in thread From: Kees Cook @ 2023-01-27 18:33 UTC (permalink / raw) To: Rafael J. Wysocki Cc: Len Brown, Robert Moore, Gustavo A. R. Silva, linux-acpi, linux-kernel, linux-hardening, acpica-devel On Fri, Jan 27, 2023 at 07:08:39PM +0100, Rafael J. Wysocki wrote: > On Fri, Jan 20, 2023 at 8:16 PM Kees Cook <keescook@chromium.org> wrote: > > > > On Fri, Jan 20, 2023 at 07:10:52PM +0100, Rafael J. Wysocki wrote: > > > On Sun, Jan 15, 2023 at 7:38 PM Kees Cook <keescook@chromium.org> wrote: > > > > > > > > On Fri, Nov 18, 2022 at 10:15:51AM -0800, Kees Cook wrote: > > > > > Functionally identical to ACPICA upstream pull request 813: > > > > > https://github.com/acpica/acpica/pull/813 > > > > > > > > Any update on this? Upstream is currently unbuildable since October. > > > > > > > > > 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. > > > > > > > > In the meantime, can you take this patch for Linux, and we can wait for > > > > ACPICA to catch up? > > > > > > Applied now (as 6.3 material), sorry for the delay. > > > > Thanks! > > Unfortunately, this breaks compilation for the ACPI tools in tools/power/acpi/. What's the make target to test this? > Apparently, the problem is that DECLARE_FLEX_ARRAY() is not defined > when the tools are built, because kernel headers are not used then. This should exist in the stddef.h tools headers, but perhaps it isn't included already? > I guess the changes from your upstream PR need to be backported > literally for this to work, so I'll drop this one for the time being. > Or please let me know if you have a better idea. I can send a new version if I can reproduce the build failure you see... -- Kees Cook ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ACPICA: Replace fake flexible arrays with flexible array members 2023-01-27 18:33 ` Kees Cook @ 2023-01-27 18:52 ` Rafael J. Wysocki 0 siblings, 0 replies; 7+ messages in thread From: Rafael J. Wysocki @ 2023-01-27 18:52 UTC (permalink / raw) To: Kees Cook Cc: Rafael J. Wysocki, Len Brown, Robert Moore, Gustavo A. R. Silva, linux-acpi, linux-kernel, linux-hardening, acpica-devel On Fri, Jan 27, 2023 at 7:33 PM Kees Cook <keescook@chromium.org> wrote: > > On Fri, Jan 27, 2023 at 07:08:39PM +0100, Rafael J. Wysocki wrote: > > On Fri, Jan 20, 2023 at 8:16 PM Kees Cook <keescook@chromium.org> wrote: > > > > > > On Fri, Jan 20, 2023 at 07:10:52PM +0100, Rafael J. Wysocki wrote: > > > > On Sun, Jan 15, 2023 at 7:38 PM Kees Cook <keescook@chromium.org> wrote: > > > > > > > > > > On Fri, Nov 18, 2022 at 10:15:51AM -0800, Kees Cook wrote: > > > > > > Functionally identical to ACPICA upstream pull request 813: > > > > > > https://github.com/acpica/acpica/pull/813 > > > > > > > > > > Any update on this? Upstream is currently unbuildable since October. > > > > > > > > > > > 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. > > > > > > > > > > In the meantime, can you take this patch for Linux, and we can wait for > > > > > ACPICA to catch up? > > > > > > > > Applied now (as 6.3 material), sorry for the delay. > > > > > > Thanks! > > > > Unfortunately, this breaks compilation for the ACPI tools in tools/power/acpi/. > > What's the make target to test this? Just cd to tools/power/acpi in the kernel tree and run make. > > Apparently, the problem is that DECLARE_FLEX_ARRAY() is not defined > > when the tools are built, because kernel headers are not used then. > > This should exist in the stddef.h tools headers, but perhaps it isn't > included already? No, it isn't AFAICS. > > I guess the changes from your upstream PR need to be backported > > literally for this to work, so I'll drop this one for the time being. > > Or please let me know if you have a better idea. > > I can send a new version if I can reproduce the build failure you see... Sure, thanks! ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-01-27 18:52 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-11-18 18:15 [PATCH] ACPICA: Replace fake flexible arrays with flexible array members Kees Cook 2023-01-15 18:38 ` Kees Cook 2023-01-20 18:10 ` Rafael J. Wysocki 2023-01-20 19:16 ` Kees Cook 2023-01-27 18:08 ` Rafael J. Wysocki 2023-01-27 18:33 ` Kees Cook 2023-01-27 18:52 ` 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; as well as URLs for NNTP newsgroup(s).