From 4d869167fff82fe29ab410e08ecfa78e16cb71a0 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Sun, 11 Nov 2018 17:14:57 -0800 Subject: [PATCH] travis: test x86 LTS #35 commit 81b45683487a ("compiler.h: give up __compiletime_assert_fallback()") is needed because travis kills the job otherwise due to log spew. See build 271. > The job exceeded the maximum log length, and has been terminated. The proper fix is to send the backport, TODO. --- .travis.yml | 10 +++ ...x86-Avoid-warnings-errors-due-to-lac.patch | 1 + ...ive-up-__compiletime_assert_fallback.patch | 83 +++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 120000 patches/4.19/x86_64/0001-DO-NOT-UPSTREAM-x86-Avoid-warnings-errors-due-to-lac.patch create mode 100644 patches/4.19/x86_64/0002-compiler.h-give-up-__compiletime_assert_fallback.patch diff --git a/.travis.yml b/.travis.yml index 583c8d2..c5a5e31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,15 +35,25 @@ matrix: #- name: "ARCH=arm64 REPO=4.19" #env: ARCH=arm64 REPO=4.19 #if: type = cron + - name: "ARCH=x86_64 REPO=4.19" + env: ARCH=x86_64 REPO=4.19 + if: type = cron - name: "ARCH=arm64 REPO=4.14" env: ARCH=arm64 REPO=4.14 if: type = cron + #- name: "ARCH=x86_64 REPO=4.14" + #env: ARCH=x86_64 REPO=4.14 + #if: type = cron #- name: "ARCH=arm64 REPO=4.9" #env: ARCH=arm64 REPO=4.9 #if: type = cron + #- name: "ARCH=x86_64 REPO=4.9" + #env: ARCH=x86_64 REPO=4.9 #- name: "ARCH=arm64 REPO=4.4" #env: ARCH=arm64 REPO=4.4 #if: type = cron + #- name: "ARCH=x86_64 REPO=4.4" + #env: ARCH=x86_64 REPO=4.4 compiler: gcc os: linux dist: trusty diff --git a/patches/4.19/x86_64/0001-DO-NOT-UPSTREAM-x86-Avoid-warnings-errors-due-to-lac.patch b/patches/4.19/x86_64/0001-DO-NOT-UPSTREAM-x86-Avoid-warnings-errors-due-to-lac.patch new file mode 120000 index 0000000..7a60ecf --- /dev/null +++ b/patches/4.19/x86_64/0001-DO-NOT-UPSTREAM-x86-Avoid-warnings-errors-due-to-lac.patch @@ -0,0 +1 @@ +../../linux/x86_64/0001-DO-NOT-UPSTREAM-x86-Avoid-warnings-errors-due-to-lac.patch \ No newline at end of file diff --git a/patches/4.19/x86_64/0002-compiler.h-give-up-__compiletime_assert_fallback.patch b/patches/4.19/x86_64/0002-compiler.h-give-up-__compiletime_assert_fallback.patch new file mode 100644 index 0000000..e2362b7 --- /dev/null +++ b/patches/4.19/x86_64/0002-compiler.h-give-up-__compiletime_assert_fallback.patch @@ -0,0 +1,83 @@ +From 81b45683487a51b0f4d3b29d37f20d6d078544e4 Mon Sep 17 00:00:00 2001 +From: Masahiro Yamada +Date: Sun, 26 Aug 2018 03:16:29 +0900 +Subject: [PATCH] compiler.h: give up __compiletime_assert_fallback() + +__compiletime_assert_fallback() is supposed to stop building earlier +by using the negative-array-size method in case the compiler does not +support "error" attribute, but has never worked like that. + +You can simply try: + + BUILD_BUG_ON(1); + +GCC immediately terminates the build, but Clang does not report +anything because Clang does not support the "error" attribute now. +It will later fail at link time, but __compiletime_assert_fallback() +is not working at least. + +The root cause is commit 1d6a0d19c855 ("bug.h: prevent double evaluation +of `condition' in BUILD_BUG_ON"). Prior to that commit, BUILD_BUG_ON() +was checked by the negative-array-size method *and* the link-time trick. +Since that commit, the negative-array-size is not effective because +'__cond' is no longer constant. As the comment in +says, GCC (and Clang as well) only emits the error for obvious cases. + +When '__cond' is a variable, + + ((void)sizeof(char[1 - 2 * __cond])) + +... is not obvious for the compiler to know the array size is negative. + +Reverting that commit would break BUILD_BUG() because negative-size-array +is evaluated before the code is optimized out. + +Let's give up __compiletime_assert_fallback(). This commit does not +change the current behavior since it just rips off the useless code. + +Signed-off-by: Masahiro Yamada +Reviewed-by: Kees Cook +Reviewed-by: Nick Desaulniers +Signed-off-by: Kees Cook +--- + include/linux/compiler.h | 17 +---------------- + 1 file changed, 1 insertion(+), 16 deletions(-) + +diff --git a/include/linux/compiler.h b/include/linux/compiler.h +index 681d866efb1e..87c776c3ce73 100644 +--- a/include/linux/compiler.h ++++ b/include/linux/compiler.h +@@ -314,29 +314,14 @@ static inline void *offset_to_ptr(const int *off) + #endif + #ifndef __compiletime_error + # define __compiletime_error(message) +-/* +- * Sparse complains of variable sized arrays due to the temporary variable in +- * __compiletime_assert. Unfortunately we can't just expand it out to make +- * sparse see a constant array size without breaking compiletime_assert on old +- * versions of GCC (e.g. 4.2.4), so hide the array from sparse altogether. +- */ +-# ifndef __CHECKER__ +-# define __compiletime_error_fallback(condition) \ +- do { ((void)sizeof(char[1 - 2 * condition])); } while (0) +-# endif +-#endif +-#ifndef __compiletime_error_fallback +-# define __compiletime_error_fallback(condition) do { } while (0) + #endif + + #ifdef __OPTIMIZE__ + # define __compiletime_assert(condition, msg, prefix, suffix) \ + do { \ +- int __cond = !(condition); \ + extern void prefix ## suffix(void) __compiletime_error(msg); \ +- if (__cond) \ ++ if (!(condition)) \ + prefix ## suffix(); \ +- __compiletime_error_fallback(__cond); \ + } while (0) + #else + # define __compiletime_assert(condition, msg, prefix, suffix) do { } while (0) +-- +2.17.1 +