* [PATCH] kbuild: disable Android-specific compiler features
@ 2016-02-06 0:44 Kees Cook
2016-02-17 23:03 ` Kees Cook
0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2016-02-06 0:44 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kernel, linux-kbuild
The Android compilers enable some non-standard features by default. While
most Android build systems inject the needed "-mno-android" option via
KCFLAGS, it happens too late (at least on x86_64), since KBUILD_CFLAGS
gains KCFLAGS after running (and failing) many cc-option tests. (For
example, the stack-protector tests happen after arch-specific
KBUILD_CFLAGS are added but before the external KCFLAGS are added.) As
such, we should notice this option and immediately turn it on as the
first cc-option test we run.
Signed-off-by: Kees Cook <keescook@chromium.org>
---
Makefile | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Makefile b/Makefile
index 6c1a3c247988..126c98b582bb 100644
--- a/Makefile
+++ b/Makefile
@@ -393,6 +393,10 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-Wno-format-security \
-std=gnu89
+# We must turn off the Android-specific compiler options as early as possible
+# otherwise cc-option calls below may erroneously fail.
+KBUILD_CFLAGS += $(call cc-option,-mno-android,)
+
KBUILD_AFLAGS_KERNEL :=
KBUILD_CFLAGS_KERNEL :=
KBUILD_AFLAGS := -D__ASSEMBLY__
--
2.6.3
--
Kees Cook
Chrome OS & Brillo Security
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] kbuild: disable Android-specific compiler features
2016-02-06 0:44 [PATCH] kbuild: disable Android-specific compiler features Kees Cook
@ 2016-02-17 23:03 ` Kees Cook
2016-02-18 9:36 ` Michal Marek
0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2016-02-17 23:03 UTC (permalink / raw)
To: Michal Marek, Andrew Morton; +Cc: LKML, linux-kbuild
On Fri, Feb 5, 2016 at 4:44 PM, Kees Cook <keescook@chromium.org> wrote:
> The Android compilers enable some non-standard features by default. While
> most Android build systems inject the needed "-mno-android" option via
> KCFLAGS, it happens too late (at least on x86_64), since KBUILD_CFLAGS
> gains KCFLAGS after running (and failing) many cc-option tests. (For
> example, the stack-protector tests happen after arch-specific
> KBUILD_CFLAGS are added but before the external KCFLAGS are added.) As
> such, we should notice this option and immediately turn it on as the
> first cc-option test we run.
>
> Signed-off-by: Kees Cook <keescook@chromium.org>
Michal, is this okay? I'd like to get it into -next soon if possible.
Thanks!
-Kees
> ---
> Makefile | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 6c1a3c247988..126c98b582bb 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -393,6 +393,10 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
> -Wno-format-security \
> -std=gnu89
>
> +# We must turn off the Android-specific compiler options as early as possible
> +# otherwise cc-option calls below may erroneously fail.
> +KBUILD_CFLAGS += $(call cc-option,-mno-android,)
> +
> KBUILD_AFLAGS_KERNEL :=
> KBUILD_CFLAGS_KERNEL :=
> KBUILD_AFLAGS := -D__ASSEMBLY__
> --
> 2.6.3
>
>
> --
> Kees Cook
> Chrome OS & Brillo Security
--
Kees Cook
Chrome OS & Brillo Security
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] kbuild: disable Android-specific compiler features
2016-02-17 23:03 ` Kees Cook
@ 2016-02-18 9:36 ` Michal Marek
2016-02-18 17:54 ` Kees Cook
0 siblings, 1 reply; 4+ messages in thread
From: Michal Marek @ 2016-02-18 9:36 UTC (permalink / raw)
To: Kees Cook; +Cc: Andrew Morton, LKML, linux-kbuild
Dne 18.2.2016 v 00:03 Kees Cook napsal(a):
> On Fri, Feb 5, 2016 at 4:44 PM, Kees Cook <keescook@chromium.org> wrote:
>> The Android compilers enable some non-standard features by default. While
>> most Android build systems inject the needed "-mno-android" option via
>> KCFLAGS, it happens too late (at least on x86_64), since KBUILD_CFLAGS
>> gains KCFLAGS after running (and failing) many cc-option tests. (For
>> example, the stack-protector tests happen after arch-specific
>> KBUILD_CFLAGS are added but before the external KCFLAGS are added.) As
>> such, we should notice this option and immediately turn it on as the
>> first cc-option test we run.
>>
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>
> Michal, is this okay? I'd like to get it into -next soon if possible.
Is there a way to detect these compilers and are there some canonical
versions of these? I do not think it's a good idea to add workaround for
each random gcc fork.
Michal
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] kbuild: disable Android-specific compiler features
2016-02-18 9:36 ` Michal Marek
@ 2016-02-18 17:54 ` Kees Cook
0 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2016-02-18 17:54 UTC (permalink / raw)
To: Michal Marek; +Cc: Andrew Morton, LKML, linux-kbuild
On Thu, Feb 18, 2016 at 1:36 AM, Michal Marek <mmarek@suse.com> wrote:
> Dne 18.2.2016 v 00:03 Kees Cook napsal(a):
>> On Fri, Feb 5, 2016 at 4:44 PM, Kees Cook <keescook@chromium.org> wrote:
>>> The Android compilers enable some non-standard features by default. While
>>> most Android build systems inject the needed "-mno-android" option via
>>> KCFLAGS, it happens too late (at least on x86_64), since KBUILD_CFLAGS
>>> gains KCFLAGS after running (and failing) many cc-option tests. (For
>>> example, the stack-protector tests happen after arch-specific
>>> KBUILD_CFLAGS are added but before the external KCFLAGS are added.) As
>>> such, we should notice this option and immediately turn it on as the
>>> first cc-option test we run.
>>>
>>> Signed-off-by: Kees Cook <keescook@chromium.org>
>>
>> Michal, is this okay? I'd like to get it into -next soon if possible.
>
> Is there a way to detect these compilers and are there some canonical
> versions of these? I do not think it's a good idea to add workaround for
> each random gcc fork.
It's detectable by -mno-android being a valid option. It's not a
random gcc fork, as it's part of the Android SDK gcc prebuilts that
all Android vendors and hobbiests use to build their kernels.
-Kees
--
Kees Cook
Chrome OS & Brillo Security
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-18 17:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-06 0:44 [PATCH] kbuild: disable Android-specific compiler features Kees Cook
2016-02-17 23:03 ` Kees Cook
2016-02-18 9:36 ` Michal Marek
2016-02-18 17:54 ` Kees Cook
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.