From 30454c5887c5ba7ab472859be7787ffdb33e1d0b Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 23 Jun 2021 21:35:00 -0400 Subject: [PATCH] add big-hammer patch for GCC bug 95189 this is a critical wrong-codegen bug in gcc 9 and 10 that can have security impact, and oddly the fix still does not seem to have been backported, so just disable builtin memcmp expansion entirely until there's a known-good fix. --- patches/gcc-9.2.0/0019-broken-builtin-memcmp.diff | 11 +++++++++++ patches/gcc-9.4.0/0019-broken-builtin-memcmp.diff | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 patches/gcc-9.2.0/0019-broken-builtin-memcmp.diff create mode 100644 patches/gcc-9.4.0/0019-broken-builtin-memcmp.diff diff --git a/patches/gcc-9.2.0/0019-broken-builtin-memcmp.diff b/patches/gcc-9.2.0/0019-broken-builtin-memcmp.diff new file mode 100644 index 0000000..84d8b3a --- /dev/null +++ b/patches/gcc-9.2.0/0019-broken-builtin-memcmp.diff @@ -0,0 +1,11 @@ +diff -ur gcc-9.3.0.orig/gcc/builtins.c gcc-9.3.0/gcc/builtins.c +--- gcc-9.3.0.orig/gcc/builtins.c 2020-03-12 11:07:21.000000000 +0000 ++++ gcc-9.3.0/gcc/builtins.c 2020-09-23 22:16:54.815251679 +0000 +@@ -4658,6 +4658,7 @@ + static rtx + expand_builtin_memcmp (tree exp, rtx target, bool result_eq) + { ++ return NULL_RTX; + if (!validate_arglist (exp, + POINTER_TYPE, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) + return NULL_RTX; diff --git a/patches/gcc-9.4.0/0019-broken-builtin-memcmp.diff b/patches/gcc-9.4.0/0019-broken-builtin-memcmp.diff new file mode 100644 index 0000000..84d8b3a --- /dev/null +++ b/patches/gcc-9.4.0/0019-broken-builtin-memcmp.diff @@ -0,0 +1,11 @@ +diff -ur gcc-9.3.0.orig/gcc/builtins.c gcc-9.3.0/gcc/builtins.c +--- gcc-9.3.0.orig/gcc/builtins.c 2020-03-12 11:07:21.000000000 +0000 ++++ gcc-9.3.0/gcc/builtins.c 2020-09-23 22:16:54.815251679 +0000 +@@ -4658,6 +4658,7 @@ + static rtx + expand_builtin_memcmp (tree exp, rtx target, bool result_eq) + { ++ return NULL_RTX; + if (!validate_arglist (exp, + POINTER_TYPE, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) + return NULL_RTX;