All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPICA: use designated initializers
@ 2016-12-17  1:04 Kees Cook
  2016-12-17  2:17 ` Rafael J. Wysocki
  2016-12-19  6:06   ` Zheng, Lv
  0 siblings, 2 replies; 17+ messages in thread
From: Kees Cook @ 2016-12-17  1:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Robert Moore, Lv Zheng, Rafael J. Wysocki, Len Brown, linux-acpi,
	devel

Prepare to mark sensitive kernel structures for randomization by making
sure they're using designated initializers. These were identified during
allyesconfig builds of x86, arm, and arm64, with most initializer fixes
extracted from grsecurity.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/acpi/acpica/hwxfsleep.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
index f76e0eab32b8..25cd5c66e102 100644
--- a/drivers/acpi/acpica/hwxfsleep.c
+++ b/drivers/acpi/acpica/hwxfsleep.c
@@ -70,11 +70,12 @@ static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id);
 /* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */
 
 static struct acpi_sleep_functions acpi_sleep_dispatch[] = {
-	{ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
-	 acpi_hw_extended_sleep},
-	{ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
-	 acpi_hw_extended_wake_prep},
-	{ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake), acpi_hw_extended_wake}
+	{ .legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
+	  .extended_function = acpi_hw_extended_sleep },
+	{ .legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
+	  .extended_function = acpi_hw_extended_wake_prep },
+	{ .legacy_function = ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake),
+	  .extended_function = acpi_hw_extended_wake }
 };
 
 /*
-- 
2.7.4


-- 
Kees Cook
Nexus Security

^ permalink raw reply related	[flat|nested] 17+ messages in thread
* Re: [Devel] [PATCH] ACPICA: use designated initializers
  2017-03-30  2:12       ` Zheng, Lv
@ 2017-03-30 14:26 ` Moore, Robert
  -1 siblings, 0 replies; 17+ messages in thread
From: Moore, Robert @ 2017-03-30 14:26 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 4296 bytes --]

Yes, ACPICA must support many compilers, so we keep the code as simple as possible.

Many of the corporate OS vendors use their own compilers.


> -----Original Message-----
> From: Zheng, Lv
> Sent: Wednesday, March 29, 2017 7:12 PM
> To: Kees Cook <keescook(a)chromium.org>
> Cc: linux-kernel(a)vger.kernel.org; Moore, Robert
> <robert.moore(a)intel.com>; Wysocki, Rafael J
> <rafael.j.wysocki(a)intel.com>; Len Brown <lenb(a)kernel.org>; linux-
> acpi(a)vger.kernel.org; devel(a)acpica.org
> Subject: RE: [PATCH] ACPICA: use designated initializers
> 
> Hi,
> 
> > From: keescook(a)google.com [mailto:keescook(a)google.com] On Behalf Of
> > Kees Cook
> > Subject: Re: [PATCH] ACPICA: use designated initializers
> >
> > On Sun, Dec 18, 2016 at 10:06 PM, Zheng, Lv <lv.zheng(a)intel.com>
> wrote:
> > > Hi,
> > >
> > >> From: Kees Cook [mailto:keescook(a)chromium.org]
> > >> Subject: [PATCH] ACPICA: use designated initializers
> > >>
> > >> Prepare to mark sensitive kernel structures for randomization by
> > >> making sure they're using designated initializers. These were
> > >> identified during allyesconfig builds of x86, arm, and arm64, with
> > >> most initializer fixes extracted from grsecurity.
> > >
> > > This commit is not suitable for ACPICA upstream.
> > > It's not portable. Please drop.
> >
> > What compilers are building this that do not support designated
> > initializers? Also, couldn't this be made into a macro so it could be
> > supported in either case?
> 
> It's MSVC.
> In ACPICA upstream, it supports Intel compiler, GCC and MSVC.
> 
> >
> > #ifdef __GNUC__
> > # define ACPI_SLEEP_FUNCTIONS(legacy, extended) { \
> >     .legacy_function = legacy, \
> >     .extended_function = extended, \
> > }
> > #else
> > # define ACPI_SLEEP_FUNCTIONS(legacy, extended) { legacy, extended }
> > #endif
> >
> > ...
> >
> >  static struct acpi_sleep_functions acpi_sleep_dispatch[] = {
> >         ACPI_SLEEP_FUNCTIONS(
> >                ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
> >                acpi_hw_extended_sleep), ...
> 
> There are many such cases in ACPICA, and I couldn't see the benefit to
> introduce such mechanism to such a software whose purposes contain
> portability.
> Unless you can invent a mechanism that can be utilized by all such
> cases.
> Then you should put it into acgcc.h and implement a replaceable in
> acmsvc.h.
> After that, you surely need to do a cleanup in the entire ACPICA code
> base using this new mechanism.
> 
> Thanks
> Lv
> 
> >
> >
> > -Kees
> >
> > >
> > > Thanks
> > > Lv
> > >
> > >>
> > >> Signed-off-by: Kees Cook <keescook(a)chromium.org>
> > >> ---
> > >>  drivers/acpi/acpica/hwxfsleep.c | 11 ++++++-----
> > >>  1 file changed, 6 insertions(+), 5 deletions(-)
> > >>
> > >> diff --git a/drivers/acpi/acpica/hwxfsleep.c
> > >> b/drivers/acpi/acpica/hwxfsleep.c index f76e0eab32b8..25cd5c66e102
> > >> 100644
> > >> --- a/drivers/acpi/acpica/hwxfsleep.c
> > >> +++ b/drivers/acpi/acpica/hwxfsleep.c
> > >> @@ -70,11 +70,12 @@ static acpi_status acpi_hw_sleep_dispatch(u8
> > >> sleep_state, u32 function_id);
> > >>  /* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE
> > >> */
> > >>
> > >>  static struct acpi_sleep_functions acpi_sleep_dispatch[] = {
> > >> -     {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
> > >> -      acpi_hw_extended_sleep},
> > >> -     {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
> > >> -      acpi_hw_extended_wake_prep},
> > >> -     {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake),
> acpi_hw_extended_wake}
> > >> +     { .legacy_function =
> ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
> > >> +       .extended_function = acpi_hw_extended_sleep },
> > >> +     { .legacy_function =
> ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
> > >> +       .extended_function = acpi_hw_extended_wake_prep },
> > >> +     { .legacy_function =
> ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake),
> > >> +       .extended_function = acpi_hw_extended_wake }
> > >>  };
> > >>
> > >>  /*
> > >> --
> > >> 2.7.4
> > >>
> > >>
> > >> --
> > >> Kees Cook
> > >> Nexus Security
> >
> >
> >
> > --
> > Kees Cook
> > Pixel Security

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

end of thread, other threads:[~2017-05-08 20:05 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-17  1:04 [PATCH] ACPICA: use designated initializers Kees Cook
2016-12-17  2:17 ` Rafael J. Wysocki
2016-12-19  6:06 ` [Devel] " Zheng, Lv
2016-12-19  6:06   ` Zheng, Lv
2017-03-29 21:16   ` Kees Cook
2017-03-30  2:12     ` [Devel] " Zheng, Lv
2017-03-30  2:12       ` Zheng, Lv
2017-04-01  0:26       ` Kees Cook
2017-04-01  0:45         ` [Devel] " Moore, Robert
2017-04-01  0:45           ` Moore, Robert
2017-04-03 17:29           ` Kees Cook
2017-04-04 15:02             ` [Devel] " Moore, Robert
2017-04-04 15:02               ` Moore, Robert
2017-04-04 15:55               ` Kees Cook
2017-05-08 20:05                 ` Kees Cook
  -- strict thread matches above, loose matches on Subject: below --
2017-03-30 14:26 [Devel] " Moore, Robert
2017-03-30 14:26 ` Moore, Robert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.