From 72a96948f04d95bb4d8d6a070f4fc4127640ee0bdfaf97ca58d0ffa15d57d46f Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Sat, 15 Aug 2020 19:18:32 +0000 Subject: [PATCH] Accepting request 826245 from Base:System OBS-URL: https://build.opensuse.org/request/show/826245 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=224 --- 0001-kern-mm.c-Make-grub_calloc-inline.patch | 116 +++++++++++++++++++ grub2.changes | 7 ++ grub2.spec | 2 + 3 files changed, 125 insertions(+) create mode 100644 0001-kern-mm.c-Make-grub_calloc-inline.patch diff --git a/0001-kern-mm.c-Make-grub_calloc-inline.patch b/0001-kern-mm.c-Make-grub_calloc-inline.patch new file mode 100644 index 0000000..033eb65 --- /dev/null +++ b/0001-kern-mm.c-Make-grub_calloc-inline.patch @@ -0,0 +1,116 @@ +From c2475f1337dff2e2a3e45514119d5186e55753c1 Mon Sep 17 00:00:00 2001 +From: Michael Chang +Date: Thu, 13 Aug 2020 09:36:45 +0800 +Subject: [PATCH] kern/mm.c : Make grub_calloc inline + +To circumvent the situation that symbol 'grub_calloc' not found would +happen if system is using stray grub (ie not managed by system update) +as stage1 that can be too old to load updated modules. +--- + grub-core/kern/mm.c | 28 ---------------------------- + include/grub/mm.h | 32 +++++++++++++++++++++++++++++++- + 2 files changed, 31 insertions(+), 29 deletions(-) + +diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c +index f2822a836..dacdaa239 100644 +--- a/grub-core/kern/mm.c ++++ b/grub-core/kern/mm.c +@@ -60,14 +60,10 @@ + + #include + #include +-#include +-#include + #include + #include + #include +-#include + #include +-#include + + #ifdef MM_DEBUG + # undef grub_calloc +@@ -377,30 +373,6 @@ grub_memalign (grub_size_t align, grub_size_t size) + return 0; + } + +-/* +- * Allocate NMEMB instances of SIZE bytes and return the pointer, or error on +- * integer overflow. +- */ +-void * +-grub_calloc (grub_size_t nmemb, grub_size_t size) +-{ +- void *ret; +- grub_size_t sz = 0; +- +- if (grub_mul (nmemb, size, &sz)) +- { +- grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); +- return NULL; +- } +- +- ret = grub_memalign (0, sz); +- if (!ret) +- return NULL; +- +- grub_memset (ret, 0, sz); +- return ret; +-} +- + /* Allocate SIZE bytes and return the pointer. */ + void * + grub_malloc (grub_size_t size) +diff --git a/include/grub/mm.h b/include/grub/mm.h +index 9c38dd3ca..1754635e7 100644 +--- a/include/grub/mm.h ++++ b/include/grub/mm.h +@@ -29,7 +29,6 @@ + #endif + + void grub_mm_init_region (void *addr, grub_size_t size); +-void *EXPORT_FUNC(grub_calloc) (grub_size_t nmemb, grub_size_t size); + void *EXPORT_FUNC(grub_malloc) (grub_size_t size); + void *EXPORT_FUNC(grub_zalloc) (grub_size_t size); + void EXPORT_FUNC(grub_free) (void *ptr); +@@ -37,6 +36,37 @@ void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size); + #ifndef GRUB_MACHINE_EMU + void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size); + #endif ++#if !defined(GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) ++#include ++#include ++#include ++#include ++/* ++ * Allocate NMEMB instances of SIZE bytes and return the pointer, or error on ++ * integer overflow. ++ */ ++static inline void * ++grub_calloc (grub_size_t nmemb, grub_size_t size) ++{ ++ void *ret; ++ grub_size_t sz = 0; ++ ++ if (grub_mul (nmemb, size, &sz)) ++ { ++ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); ++ return NULL; ++ } ++ ++ ret = grub_memalign (0, sz); ++ if (!ret) ++ return NULL; ++ ++ grub_memset (ret, 0, sz); ++ return ret; ++} ++#else ++void *EXPORT_FUNC(grub_calloc) (grub_size_t nmemb, grub_size_t size); ++#endif + + void grub_mm_check_real (const char *file, int line); + #define grub_mm_check() grub_mm_check_real (GRUB_FILE, __LINE__); +-- +2.26.2 + diff --git a/grub2.changes b/grub2.changes index 1694b26..7a89503 100644 --- a/grub2.changes +++ b/grub2.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Aug 13 06:41:16 UTC 2020 - Michael Chang + +- Make grub-calloc inline to avoid symbol not found error as the system may not + use updated grub to boot the system (bsc#1174782) (bsc#1175060) (bsc#1175036) + * 0001-kern-mm.c-Make-grub_calloc-inline.patch + ------------------------------------------------------------------- Mon Jul 27 10:04:49 UTC 2020 - Michael Chang diff --git a/grub2.spec b/grub2.spec index 834da37..e320615 100644 --- a/grub2.spec +++ b/grub2.spec @@ -320,6 +320,7 @@ Patch712: 0009-script-Avoid-a-use-after-free-when-redefining-a-func.patch # bsc#1174570 VUL-0: EMBARGOED: CVE-2020-15707: grub2: linux: Fix integer # overflows in initrd size handling Patch713: 0010-linux-Fix-integer-overflows-in-initrd-size-handling.patch +Patch714: 0001-kern-mm.c-Make-grub_calloc-inline.patch Requires: gettext-runtime %if 0%{?suse_version} >= 1140 @@ -635,6 +636,7 @@ swap partition while in resuming %patch711 -p1 %patch712 -p1 %patch713 -p1 +%patch714 -p1 %build # collect evidence to debug spurious build failure on SLE15