From: Sasha Levin Date: Wed, 6 Nov 2019 16:41:08 +0000 (-0500) Subject: fixes for 4.9 X-Git-Tag: v4.4.200~20^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ad9278699fea136bc9fd67cf1c887439f1600629;p=thirdparty%2Fkernel%2Fstable-queue.git fixes for 4.9 Signed-off-by: Sasha Levin --- diff --git a/queue-4.9/kbuild-add-fcf-protection-none-when-using-retpoline-.patch b/queue-4.9/kbuild-add-fcf-protection-none-when-using-retpoline-.patch new file mode 100644 index 00000000000..cd47f7e774e --- /dev/null +++ b/queue-4.9/kbuild-add-fcf-protection-none-when-using-retpoline-.patch @@ -0,0 +1,43 @@ +From e4185ff1c9c26db2e1704ade5d5d43ee1e9aef79 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 17 Jul 2019 11:06:26 -0500 +Subject: kbuild: add -fcf-protection=none when using retpoline flags + +From: Seth Forshee + +[ Upstream commit 29be86d7f9cb18df4123f309ac7857570513e8bc ] + +The gcc -fcf-protection=branch option is not compatible with +-mindirect-branch=thunk-extern. The latter is used when +CONFIG_RETPOLINE is selected, and this will fail to build with +a gcc which has -fcf-protection=branch enabled by default. Adding +-fcf-protection=none when building with retpoline enabled +prevents such build failures. + +Signed-off-by: Seth Forshee +Signed-off-by: Masahiro Yamada +Signed-off-by: Sasha Levin +--- + Makefile | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/Makefile b/Makefile +index 62ce3766032c9..1d50905aaf425 100644 +--- a/Makefile ++++ b/Makefile +@@ -840,6 +840,12 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) + # change __FILE__ to the relative path from the srctree + KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) + ++# ensure -fcf-protection is disabled when using retpoline as it is ++# incompatible with -mindirect-branch=thunk-extern ++ifdef CONFIG_RETPOLINE ++KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) ++endif ++ + # use the deterministic mode of AR if available + KBUILD_ARFLAGS := $(call ar-option,D) + +-- +2.20.1 + diff --git a/queue-4.9/kbuild-make-designated_init-attribute-fatal.patch b/queue-4.9/kbuild-make-designated_init-attribute-fatal.patch new file mode 100644 index 00000000000..b3500cdc57a --- /dev/null +++ b/queue-4.9/kbuild-make-designated_init-attribute-fatal.patch @@ -0,0 +1,39 @@ +From 0aa40f1d4d2faad27a3644c431067b599dbbc9f7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 20 Mar 2017 17:14:11 -0700 +Subject: Kbuild: make designated_init attribute fatal + +From: Kees Cook + +[ Upstream commit c834f0e8a8bb3025aac38e802fca2e686720f544 ] + +If a structure is marked with __attribute__((designated_init)) from +GCC or Sparse, it needs to have all static initializers using designated +initialization. Fail the build for any missing cases. This attribute will +be used by the randstruct plugin to make sure randomized structures are +being correctly initialized. + +Signed-off-by: Kees Cook +Signed-off-by: Masahiro Yamada +Signed-off-by: Sasha Levin +--- + Makefile | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/Makefile b/Makefile +index b7f6639f4e7a2..19c7e30684077 100644 +--- a/Makefile ++++ b/Makefile +@@ -834,6 +834,9 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) + # enforce correct pointer usage + KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) + ++# Require designated initializers for all marked structures ++KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) ++ + # use the deterministic mode of AR if available + KBUILD_ARFLAGS := $(call ar-option,D) + +-- +2.20.1 + diff --git a/queue-4.9/kbuild-use-fmacro-prefix-map-to-make-__file__-a-rela.patch b/queue-4.9/kbuild-use-fmacro-prefix-map-to-make-__file__-a-rela.patch new file mode 100644 index 00000000000..687dde700f6 --- /dev/null +++ b/queue-4.9/kbuild-use-fmacro-prefix-map-to-make-__file__-a-rela.patch @@ -0,0 +1,55 @@ +From a7f41b04dc3cb8f16d48c59575d0fb2fbcf74f8d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 30 Mar 2018 13:15:26 +0900 +Subject: kbuild: use -fmacro-prefix-map to make __FILE__ a relative path + +From: Masahiro Yamada + +[ Upstream commit a73619a845d5625079cc1b3b820f44c899618388 ] + +The __FILE__ macro is used everywhere in the kernel to locate the file +printing the log message, such as WARN_ON(), etc. If the kernel is +built out of tree, this can be a long absolute path, like this: + + WARNING: CPU: 1 PID: 1 at /path/to/build/directory/arch/arm64/kernel/foo.c:... + +This is because Kbuild runs in the objtree instead of the srctree, +then __FILE__ is expanded to a file path prefixed with $(srctree)/. + +Commit 9da0763bdd82 ("kbuild: Use relative path when building in a +subdir of the source tree") improved this to some extent; $(srctree) +becomes ".." if the objtree is a child of the srctree. + +For other cases of out-of-tree build, __FILE__ is still the absolute +path. It also means the kernel image depends on where it was built. + +A brand-new option from GCC, -fmacro-prefix-map, solves this problem. +If your compiler supports it, __FILE__ is the relative path from the +srctree regardless of O= option. This provides more readable log and +more reproducible builds. + +Please note __FILE__ is always an absolute path for external modules. + +Signed-off-by: Masahiro Yamada +Signed-off-by: Sasha Levin +--- + Makefile | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/Makefile b/Makefile +index 19c7e30684077..62ce3766032c9 100644 +--- a/Makefile ++++ b/Makefile +@@ -837,6 +837,9 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) + # Require designated initializers for all marked structures + KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) + ++# change __FILE__ to the relative path from the srctree ++KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) ++ + # use the deterministic mode of AR if available + KBUILD_ARFLAGS := $(call ar-option,D) + +-- +2.20.1 + diff --git a/queue-4.9/series b/queue-4.9/series index f5a33de8fd8..267d204dc33 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -15,3 +15,6 @@ scsi-target-core-do-not-overwrite-cdb-byte-1.patch of-unittest-fix-memory-leak-in-unittest_data_add.patch mips-bmips-mark-exception-vectors-as-char-arrays.patch cifs-fix-cifsinodeinfo-lock_sem-deadlock-when-reconn.patch +kbuild-make-designated_init-attribute-fatal.patch +kbuild-use-fmacro-prefix-map-to-make-__file__-a-rela.patch +kbuild-add-fcf-protection-none-when-using-retpoline-.patch