public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	Len Brown <lenb@kernel.org>,
	Robert Moore <robert.moore@intel.com>,
	linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
	devel@acpica.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2] ACPICA: Replace fake flexible arrays with flexible array members
Date: Fri, 27 Jan 2023 11:47:39 -0800	[thread overview]
Message-ID: <202301271146.7DC8CAE113@keescook> (raw)
In-Reply-To: <CAJZ5v0iV5wK4gsoadmWOyof_vzaAOx8oX0DJu+1-bCQNdNJtBQ@mail.gmail.com>

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

  reply	other threads:[~2023-01-27 19:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202301271146.7DC8CAE113@keescook \
    --to=keescook@chromium.org \
    --cc=devel@acpica.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=robert.moore@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox