* [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; 12+ 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] 12+ messages in thread
* Re: [PATCH] ACPICA: use designated initializers 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 ` Zheng, Lv 1 sibling, 0 replies; 12+ messages in thread From: Rafael J. Wysocki @ 2016-12-17 2:17 UTC (permalink / raw) To: Kees Cook Cc: Linux Kernel Mailing List, Robert Moore, Lv Zheng, Rafael J. Wysocki, Len Brown, ACPI Devel Maling List, devel@acpica.org On Sat, Dec 17, 2016 at 2:04 AM, Kees Cook <keescook@chromium.org> wrote: > 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 } > }; > > /* > -- The problem here is like in the other patch sent earlier today. If we change that here, it will diverge from the upstream file it has been generated from. Thanks, Rafael ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH] ACPICA: use designated initializers 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 ` Zheng, Lv 2017-03-29 21:16 ` Kees Cook 1 sibling, 1 reply; 12+ messages in thread From: Zheng, Lv @ 2016-12-19 6:06 UTC (permalink / raw) To: Kees Cook, linux-kernel@vger.kernel.org Cc: Moore, Robert, Wysocki, Rafael J, Len Brown, linux-acpi@vger.kernel.org, devel@acpica.org Hi, > From: Kees Cook [mailto:keescook@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. Thanks Lv > > 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 [flat|nested] 12+ messages in thread
* Re: [PATCH] ACPICA: use designated initializers 2016-12-19 6:06 ` Zheng, Lv @ 2017-03-29 21:16 ` Kees Cook 2017-03-30 2:12 ` Zheng, Lv 0 siblings, 1 reply; 12+ messages in thread From: Kees Cook @ 2017-03-29 21:16 UTC (permalink / raw) To: Zheng, Lv Cc: linux-kernel@vger.kernel.org, Moore, Robert, Wysocki, Rafael J, Len Brown, linux-acpi@vger.kernel.org, devel@acpica.org On Sun, Dec 18, 2016 at 10:06 PM, Zheng, Lv <lv.zheng@intel.com> wrote: > Hi, > >> From: Kees Cook [mailto:keescook@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? #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), ... -Kees > > Thanks > Lv > >> >> 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 -- Kees Cook Pixel Security ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH] ACPICA: use designated initializers 2017-03-29 21:16 ` Kees Cook @ 2017-03-30 2:12 ` Zheng, Lv 2017-03-30 14:26 ` Moore, Robert 2017-04-01 0:26 ` Kees Cook 0 siblings, 2 replies; 12+ messages in thread From: Zheng, Lv @ 2017-03-30 2:12 UTC (permalink / raw) To: Kees Cook Cc: linux-kernel@vger.kernel.org, Moore, Robert, Wysocki, Rafael J, Len Brown, linux-acpi@vger.kernel.org, devel@acpica.org Hi, > From: keescook@google.com [mailto:keescook@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@intel.com> wrote: > > Hi, > > > >> From: Kees Cook [mailto:keescook@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@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] 12+ messages in thread
* RE: [PATCH] ACPICA: use designated initializers 2017-03-30 2:12 ` Zheng, Lv @ 2017-03-30 14:26 ` Moore, Robert 2017-04-01 0:26 ` Kees Cook 1 sibling, 0 replies; 12+ messages in thread From: Moore, Robert @ 2017-03-30 14:26 UTC (permalink / raw) To: Zheng, Lv, Kees Cook Cc: linux-kernel@vger.kernel.org, Wysocki, Rafael J, Len Brown, linux-acpi@vger.kernel.org, devel@acpica.org 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@chromium.org> > Cc: linux-kernel@vger.kernel.org; Moore, Robert > <robert.moore@intel.com>; Wysocki, Rafael J > <rafael.j.wysocki@intel.com>; Len Brown <lenb@kernel.org>; linux- > acpi@vger.kernel.org; devel@acpica.org > Subject: RE: [PATCH] ACPICA: use designated initializers > > Hi, > > > From: keescook@google.com [mailto:keescook@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@intel.com> > wrote: > > > Hi, > > > > > >> From: Kees Cook [mailto:keescook@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@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] 12+ messages in thread
* Re: [PATCH] ACPICA: use designated initializers 2017-03-30 2:12 ` Zheng, Lv 2017-03-30 14:26 ` Moore, Robert @ 2017-04-01 0:26 ` Kees Cook 2017-04-01 0:45 ` Moore, Robert 1 sibling, 1 reply; 12+ messages in thread From: Kees Cook @ 2017-04-01 0:26 UTC (permalink / raw) To: Zheng, Lv Cc: linux-kernel@vger.kernel.org, Moore, Robert, Wysocki, Rafael J, Len Brown, linux-acpi@vger.kernel.org, devel@acpica.org On Wed, Mar 29, 2017 at 7:12 PM, Zheng, Lv <lv.zheng@intel.com> wrote: > Hi, > >> From: keescook@google.com [mailto:keescook@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@intel.com> wrote: >> > Hi, >> > >> >> From: Kees Cook [mailto:keescook@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. This is only needed in a few cases, so I think general solution would be overkill. That said, it looks like MSVC supports designated initializers. Are people building this with especially old compilers? -Kees > > Thanks > Lv > >> >> >> -Kees >> >> > >> > Thanks >> > Lv >> > >> >> >> >> 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 >> >> >> >> -- >> Kees Cook >> Pixel Security -- Kees Cook Pixel Security ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH] ACPICA: use designated initializers 2017-04-01 0:26 ` Kees Cook @ 2017-04-01 0:45 ` Moore, Robert 2017-04-03 17:29 ` Kees Cook 0 siblings, 1 reply; 12+ messages in thread From: Moore, Robert @ 2017-04-01 0:45 UTC (permalink / raw) To: Kees Cook, Zheng, Lv Cc: linux-kernel@vger.kernel.org, Wysocki, Rafael J, Len Brown, linux-acpi@vger.kernel.org, devel@acpica.org Acpica is built with many compilers, even very old ones. It runs on at least 12 known operating systems, and very probably more. I'm sorry, but no, we are not going to start adding compiler-specific ifdefs/code in the base ACPICA code. I don't care what you do in the Linux-specific or gcc-specific headers, however. If this breaks a customer build, we (you) will hear about it rather quickly. Bob ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] ACPICA: use designated initializers 2017-04-01 0:45 ` Moore, Robert @ 2017-04-03 17:29 ` Kees Cook 2017-04-04 15:02 ` Moore, Robert 0 siblings, 1 reply; 12+ messages in thread From: Kees Cook @ 2017-04-03 17:29 UTC (permalink / raw) To: Moore, Robert Cc: Zheng, Lv, linux-kernel@vger.kernel.org, Wysocki, Rafael J, Len Brown, linux-acpi@vger.kernel.org, devel@acpica.org On Fri, Mar 31, 2017 at 5:45 PM, Moore, Robert <robert.moore@intel.com> wrote: > Acpica is built with many compilers, even very old ones. It runs on at least 12 known operating systems, and very probably more. > > I'm sorry, but no, we are not going to start adding compiler-specific ifdefs/code in the base ACPICA code. > > I don't care what you do in the Linux-specific or gcc-specific headers, however. If this breaks a customer build, we (you) will hear about it rather quickly. Since the change is specific to the one place ACPICA uses an all-function-pointer structure, I made the change local: https://github.com/acpica/acpica/pull/248 would you rather this is in the .h files instead? -Kees -- Kees Cook Pixel Security ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH] ACPICA: use designated initializers 2017-04-03 17:29 ` Kees Cook @ 2017-04-04 15:02 ` Moore, Robert 2017-04-04 15:55 ` Kees Cook 0 siblings, 1 reply; 12+ messages in thread From: Moore, Robert @ 2017-04-04 15:02 UTC (permalink / raw) To: Kees Cook Cc: Zheng, Lv, linux-kernel@vger.kernel.org, Wysocki, Rafael J, Len Brown, linux-acpi@vger.kernel.org, devel@acpica.org, Box, David E, Schmauss, Erik > -----Original Message----- > From: keescook@google.com [mailto:keescook@google.com] On Behalf Of Kees > Cook > Sent: Monday, April 3, 2017 10:29 AM > To: Moore, Robert <robert.moore@intel.com> > Cc: Zheng, Lv <lv.zheng@intel.com>; linux-kernel@vger.kernel.org; > Wysocki, Rafael J <rafael.j.wysocki@intel.com>; Len Brown > <lenb@kernel.org>; linux-acpi@vger.kernel.org; devel@acpica.org > Subject: Re: [PATCH] ACPICA: use designated initializers > > On Fri, Mar 31, 2017 at 5:45 PM, Moore, Robert <robert.moore@intel.com> > wrote: > > Acpica is built with many compilers, even very old ones. It runs on at > least 12 known operating systems, and very probably more. > > > > I'm sorry, but no, we are not going to start adding compiler-specific > ifdefs/code in the base ACPICA code. > > > > I don't care what you do in the Linux-specific or gcc-specific > headers, however. If this breaks a customer build, we (you) will hear > about it rather quickly. > > Since the change is specific to the one place ACPICA uses an all- > function-pointer structure, I made the change local: > > https://github.com/acpica/acpica/pull/248 > > would you rather this is in the .h files instead? > > -Kees > > -- > Kees Cook > Pixel Security [Moore, Robert] I have some questions about this entire issue: + * Some compilers can handle designated initializers, which is needed + * under Linux kernel builds for structures that are entirely function * pointers. I don't understand why this is coming up now, since ACPICA has been integrated with Linux for something like the last 15 years. It's the "which is needed under Linux kernel builds" wording that concerns me the most. Are you saying that the ACPICA build for Linux is broken and does not work? Further, there are quite a few similar dispatch tables in ACPICA, why are these not a problem? Bob ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] ACPICA: use designated initializers 2017-04-04 15:02 ` Moore, Robert @ 2017-04-04 15:55 ` Kees Cook 2017-05-08 20:05 ` Kees Cook 0 siblings, 1 reply; 12+ messages in thread From: Kees Cook @ 2017-04-04 15:55 UTC (permalink / raw) To: Moore, Robert Cc: Zheng, Lv, linux-kernel@vger.kernel.org, Wysocki, Rafael J, Len Brown, linux-acpi@vger.kernel.org, devel@acpica.org, Box, David E, Schmauss, Erik On Tue, Apr 4, 2017 at 8:02 AM, Moore, Robert <robert.moore@intel.com> wrote: >> -----Original Message----- >> From: keescook@google.com [mailto:keescook@google.com] On Behalf Of Kees >> Cook >> Sent: Monday, April 3, 2017 10:29 AM >> To: Moore, Robert <robert.moore@intel.com> >> Cc: Zheng, Lv <lv.zheng@intel.com>; linux-kernel@vger.kernel.org; >> Wysocki, Rafael J <rafael.j.wysocki@intel.com>; Len Brown >> <lenb@kernel.org>; linux-acpi@vger.kernel.org; devel@acpica.org >> Subject: Re: [PATCH] ACPICA: use designated initializers >> >> On Fri, Mar 31, 2017 at 5:45 PM, Moore, Robert <robert.moore@intel.com> >> wrote: >> > Acpica is built with many compilers, even very old ones. It runs on at >> least 12 known operating systems, and very probably more. >> > >> > I'm sorry, but no, we are not going to start adding compiler-specific >> ifdefs/code in the base ACPICA code. >> > >> > I don't care what you do in the Linux-specific or gcc-specific >> headers, however. If this breaks a customer build, we (you) will hear >> about it rather quickly. >> >> Since the change is specific to the one place ACPICA uses an all- >> function-pointer structure, I made the change local: >> >> https://github.com/acpica/acpica/pull/248 >> >> would you rather this is in the .h files instead? >> >> -Kees >> >> -- >> Kees Cook >> Pixel Security > > > > > [Moore, Robert] > > I have some questions about this entire issue: > > + * Some compilers can handle designated initializers, which is needed > + * under Linux kernel builds for structures that are entirely function > * pointers. > > I don't understand why this is coming up now, since ACPICA has been integrated with Linux for something like the last 15 years. It's the "which is needed under Linux kernel builds" wording that concerns me the most. Are you saying that the ACPICA build for Linux is broken and does not work? I was trying to avoid being overly Linux-specific in the ACPICA commit message. More accurately, this is "for future Linux builds using the structure layout randomization plugin." That plugin will randomize the layout of manually marked structures and automatically for structures that are entirely function pointers. (And this acpica structure is one noticed by the plugin.) > Further, there are quite a few similar dispatch tables in ACPICA, why are these not a problem? I can double-check, but I think this was the only one that showed up in an x86 allyesconfig with the plugin enabled. FWIW, I've been making these changes in lots of places, not just ACPICA. ACPICA just has external requirements. :P $ git log --oneline v4.9..next-20170404 | grep -i "designated initializers" b3c829193253 reiserfs: use designated initializers 8291798dcf05 TOMOYO: Use designated initializers f231aebfc4ca rbtree: use designated initializers c4d27f4b4dc9 [media] solo6x10: use designated initializers 6351db2b4df3 [media] mtk-vcodec: use designated initializers 613e61a0252c drm/amdgpu: use designated initializers 8486adf0d755 apparmor: use designated initializers 7f6856b789ff RDMA/i40iw: use designated initializers 6554c9f7f749 RDMA/nes: use designated initializers a641261e9998 video: fbdev: matroxfb: use designated initializers 6895aff47170 video: fbdev: sh_mobile_lcdcfb: use designated initializers 54e22bbf11ca staging: comedi: daqboard2000: use designated initializers 5f5fca6db3d3 scsi: cciss: use designated initializers 93380123fbb5 scsi: hpsa: use designated initializers 2fd2434c3f47 staging: lustre: ldlm: use designated initializers f93a1c9e5e6a ALSA: synth: use designated initializers 2fa70bb9b564 drm/nouveau: use designated initializers 5ca16d8efa66 drm/vmwgfx: use designated initializers 4e98c378a137 drm/ttm: use designated initializers c92f72370571 drm/ttm: use designated initializers ffc7dc8d838c x86/floppy: Use designated initializers e999cb43d51f net/x25: use designated initializers ebf12f1320c7 isdn: use designated initializers 9751362a4fe7 bna: use designated initializers aabd7ad94924 WAN: use designated initializers 9d1c0ca5e1d6 net: use designated initializers 99a5e178bde4 ATM: use designated initializers 4794195058b9 isdn/gigaset: use designated initializers -Kees -- Kees Cook Pixel Security ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] ACPICA: use designated initializers 2017-04-04 15:55 ` Kees Cook @ 2017-05-08 20:05 ` Kees Cook 0 siblings, 0 replies; 12+ messages in thread From: Kees Cook @ 2017-05-08 20:05 UTC (permalink / raw) To: Moore, Robert Cc: Zheng, Lv, linux-kernel@vger.kernel.org, Wysocki, Rafael J, Len Brown, linux-acpi@vger.kernel.org, devel@acpica.org, Box, David E, Schmauss, Erik On Tue, Apr 4, 2017 at 8:55 AM, Kees Cook <keescook@chromium.org> wrote: > On Tue, Apr 4, 2017 at 8:02 AM, Moore, Robert <robert.moore@intel.com> wrote: >>> -----Original Message----- >>> From: keescook@google.com [mailto:keescook@google.com] On Behalf Of Kees >>> Cook >>> Sent: Monday, April 3, 2017 10:29 AM >>> To: Moore, Robert <robert.moore@intel.com> >>> Cc: Zheng, Lv <lv.zheng@intel.com>; linux-kernel@vger.kernel.org; >>> Wysocki, Rafael J <rafael.j.wysocki@intel.com>; Len Brown >>> <lenb@kernel.org>; linux-acpi@vger.kernel.org; devel@acpica.org >>> Subject: Re: [PATCH] ACPICA: use designated initializers >>> >>> On Fri, Mar 31, 2017 at 5:45 PM, Moore, Robert <robert.moore@intel.com> >>> wrote: >>> > Acpica is built with many compilers, even very old ones. It runs on at >>> least 12 known operating systems, and very probably more. >>> > >>> > I'm sorry, but no, we are not going to start adding compiler-specific >>> ifdefs/code in the base ACPICA code. >>> > >>> > I don't care what you do in the Linux-specific or gcc-specific >>> headers, however. If this breaks a customer build, we (you) will hear >>> about it rather quickly. >>> >>> Since the change is specific to the one place ACPICA uses an all- >>> function-pointer structure, I made the change local: >>> >>> https://github.com/acpica/acpica/pull/248 >>> >>> would you rather this is in the .h files instead? >>> >>> -Kees >>> >>> -- >>> Kees Cook >>> Pixel Security >> >> >> >> >> [Moore, Robert] >> >> I have some questions about this entire issue: >> >> + * Some compilers can handle designated initializers, which is needed >> + * under Linux kernel builds for structures that are entirely function >> * pointers. >> >> I don't understand why this is coming up now, since ACPICA has been integrated with Linux for something like the last 15 years. It's the "which is needed under Linux kernel builds" wording that concerns me the most. Are you saying that the ACPICA build for Linux is broken and does not work? > > I was trying to avoid being overly Linux-specific in the ACPICA commit > message. More accurately, this is "for future Linux builds using the > structure layout randomization plugin." That plugin will randomize the > layout of manually marked structures and automatically for structures > that are entirely function pointers. (And this acpica structure is one > noticed by the plugin.) Here is the merge request in upstream ACPICA. Can anyone re-review it? https://github.com/acpica/acpica/pull/248/ Thanks! -Kees -- Kees Cook Pixel Security ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2017-05-08 20:05 UTC | newest] Thread overview: 12+ 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 ` Zheng, Lv 2017-03-29 21:16 ` Kees Cook 2017-03-30 2:12 ` Zheng, Lv 2017-03-30 14:26 ` Moore, Robert 2017-04-01 0:26 ` Kees Cook 2017-04-01 0:45 ` Moore, Robert 2017-04-03 17:29 ` Kees Cook 2017-04-04 15:02 ` Moore, Robert 2017-04-04 15:55 ` Kees Cook 2017-05-08 20:05 ` Kees Cook
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox