mirror of
https://git.yoctoproject.org/poky
synced 2026-04-08 17:02:22 +02:00
grub: upgrade 2.04 -> 2.06~rc1
2.06 RC1 release have a number of CVEs fixed: CVE-2020-15705 CVE-2021-3418 CVE-2020-27749 CVE-2021-20233 CVE-2021-20225 CVE-2020-25647 CVE-2020-25632 CVE-2020-27779 CVE-2020-14372 CVE-2020-15707 CVE-2020-15706 CVE-2020-14309 CVE-2020-14310 CVE-2020-14311 CVE-2020-14308 CVE-2020-10713 CVE-2014-4607 Dropped backported patches. (From OE-Core rev: 36a59d63619c2225fe48aa1d8fb1cdabedfffc03) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
9825a860ee
commit
da9b0583de
@@ -1,47 +0,0 @@
|
||||
From 6643507ce30f775008e093580f0c9499dfb2c485 Mon Sep 17 00:00:00 2001
|
||||
From: Simon Hardy <simon.hardy@itdev.co.uk>
|
||||
Date: Tue, 24 Mar 2020 13:29:12 +0000
|
||||
Subject: build: Fix GRUB i386-pc build with Ubuntu gcc
|
||||
|
||||
With recent versions of gcc on Ubuntu a very large lzma_decompress.img file is
|
||||
output. (e.g. 134479600 bytes instead of 2864.) This causes grub-mkimage to
|
||||
fail with: "error: Decompressor is too big."
|
||||
|
||||
This seems to be caused by a section .note.gnu.property that is placed at an
|
||||
offset such that objcopy needs to pad the img file with zeros.
|
||||
|
||||
This issue is present on:
|
||||
Ubuntu 19.10 with gcc (Ubuntu 8.3.0-26ubuntu1~19.10) 8.3.0
|
||||
Ubuntu 19.10 with gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008
|
||||
|
||||
This issue is not present on:
|
||||
Ubuntu 19.10 with gcc (Ubuntu 7.5.0-3ubuntu1~19.10) 7.5.0
|
||||
RHEL 8.0 with gcc 8.3.1 20190507 (Red Hat 8.3.1-4)
|
||||
|
||||
The issue can be fixed by removing the section using objcopy as shown in
|
||||
this patch.
|
||||
|
||||
Signed-off-by: Simon Hardy <simon.hardy@itdev.co.uk>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
---
|
||||
gentpl.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
Upstream-Status: Backport
|
||||
|
||||
diff --git a/gentpl.py b/gentpl.py
|
||||
index 387588c05..c86550d4f 100644
|
||||
--- a/gentpl.py
|
||||
+++ b/gentpl.py
|
||||
@@ -766,7 +766,7 @@ def image(defn, platform):
|
||||
if test x$(TARGET_APPLE_LINKER) = x1; then \
|
||||
$(MACHO2IMG) $< $@; \
|
||||
else \
|
||||
- $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .ARM.exidx $< $@; \
|
||||
+ $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .note.gnu.property -R .ARM.exidx $< $@; \
|
||||
fi
|
||||
""")
|
||||
|
||||
--
|
||||
cgit v1.2.1
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
From a4d3fbdff1e3ca8f87642af2ac8752c30c617a3e Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 15 Apr 2020 15:45:02 -0400
|
||||
Subject: yylex: Make lexer fatal errors actually be fatal
|
||||
|
||||
When presented with a command that can't be tokenized to anything
|
||||
smaller than YYLMAX characters, the parser calls YY_FATAL_ERROR(errmsg),
|
||||
expecting that will stop further processing, as such:
|
||||
|
||||
#define YY_DO_BEFORE_ACTION \
|
||||
yyg->yytext_ptr = yy_bp; \
|
||||
yyleng = (int) (yy_cp - yy_bp); \
|
||||
yyg->yy_hold_char = *yy_cp; \
|
||||
*yy_cp = '\0'; \
|
||||
if ( yyleng >= YYLMAX ) \
|
||||
YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \
|
||||
yy_flex_strncpy( yytext, yyg->yytext_ptr, yyleng + 1 , yyscanner); \
|
||||
yyg->yy_c_buf_p = yy_cp;
|
||||
|
||||
The code flex generates expects that YY_FATAL_ERROR() will either return
|
||||
for it or do some form of longjmp(), or handle the error in some way at
|
||||
least, and so the strncpy() call isn't in an "else" clause, and thus if
|
||||
YY_FATAL_ERROR() is *not* actually fatal, it does the call with the
|
||||
questionable limit, and predictable results ensue.
|
||||
|
||||
Unfortunately, our implementation of YY_FATAL_ERROR() is:
|
||||
|
||||
#define YY_FATAL_ERROR(msg) \
|
||||
do { \
|
||||
grub_printf (_("fatal error: %s\n"), _(msg)); \
|
||||
} while (0)
|
||||
|
||||
The same pattern exists in yyless(), and similar problems exist in users
|
||||
of YY_INPUT(), several places in the main parsing loop,
|
||||
yy_get_next_buffer(), yy_load_buffer_state(), yyensure_buffer_stack,
|
||||
yy_scan_buffer(), etc.
|
||||
|
||||
All of these callers expect YY_FATAL_ERROR() to actually be fatal, and
|
||||
the things they do if it returns after calling it are wildly unsafe.
|
||||
|
||||
Fixes: CVE-2020-10713
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=a4d3fbdff1e3ca8f87642af2ac8752c30c617a3e]
|
||||
CVE: CVE-2020-10713
|
||||
Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
|
||||
---
|
||||
grub-core/script/yylex.l | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l
|
||||
index 7b44c37b7..b7203c823 100644
|
||||
--- a/grub-core/script/yylex.l
|
||||
+++ b/grub-core/script/yylex.l
|
||||
@@ -37,11 +37,11 @@
|
||||
|
||||
/*
|
||||
* As we don't have access to yyscanner, we cannot do much except to
|
||||
- * print the fatal error.
|
||||
+ * print the fatal error and exit.
|
||||
*/
|
||||
#define YY_FATAL_ERROR(msg) \
|
||||
do { \
|
||||
- grub_printf (_("fatal error: %s\n"), _(msg)); \
|
||||
+ grub_fatal (_("fatal error: %s\n"), _(msg));\
|
||||
} while (0)
|
||||
|
||||
#define COPY(str, hint) \
|
||||
--
|
||||
cgit v1.2.1
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,117 +0,0 @@
|
||||
From c65fc7e75b7b7e880d90766057040011701e97f4 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Coulson <chris.coulson@canonical.com>
|
||||
Date: Fri, 10 Jul 2020 14:41:45 +0100
|
||||
Subject: [PATCH 8/9] script: Avoid a use-after-free when redefining a function
|
||||
during execution
|
||||
|
||||
Defining a new function with the same name as a previously defined
|
||||
function causes the grub_script and associated resources for the
|
||||
previous function to be freed. If the previous function is currently
|
||||
executing when a function with the same name is defined, this results
|
||||
in use-after-frees when processing subsequent commands in the original
|
||||
function.
|
||||
|
||||
Instead, reject a new function definition if it has the same name as
|
||||
a previously defined function, and that function is currently being
|
||||
executed. Although a behavioural change, this should be backwards
|
||||
compatible with existing configurations because they can't be
|
||||
dependent on the current behaviour without being broken.
|
||||
|
||||
Fixes: CVE-2020-15706
|
||||
|
||||
Signed-off-by: Chris Coulson <chris.coulson@canonical.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport
|
||||
CVE: CVE-2020-15706
|
||||
|
||||
Reference to upstream patch:
|
||||
https://git.savannah.gnu.org/cgit/grub.git/commit/?id=426f57383d647406ae9c628c472059c27cd6e040
|
||||
|
||||
Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
|
||||
---
|
||||
grub-core/script/execute.c | 2 ++
|
||||
grub-core/script/function.c | 16 +++++++++++++---
|
||||
grub-core/script/parser.y | 3 ++-
|
||||
include/grub/script_sh.h | 2 ++
|
||||
4 files changed, 19 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c
|
||||
index c8d6806..7e028e1 100644
|
||||
--- a/grub-core/script/execute.c
|
||||
+++ b/grub-core/script/execute.c
|
||||
@@ -838,7 +838,9 @@ grub_script_function_call (grub_script_function_t func, int argc, char **args)
|
||||
old_scope = scope;
|
||||
scope = &new_scope;
|
||||
|
||||
+ func->executing++;
|
||||
ret = grub_script_execute (func->func);
|
||||
+ func->executing--;
|
||||
|
||||
function_return = 0;
|
||||
active_loops = loops;
|
||||
diff --git a/grub-core/script/function.c b/grub-core/script/function.c
|
||||
index d36655e..3aad04b 100644
|
||||
--- a/grub-core/script/function.c
|
||||
+++ b/grub-core/script/function.c
|
||||
@@ -34,6 +34,7 @@ grub_script_function_create (struct grub_script_arg *functionname_arg,
|
||||
func = (grub_script_function_t) grub_malloc (sizeof (*func));
|
||||
if (! func)
|
||||
return 0;
|
||||
+ func->executing = 0;
|
||||
|
||||
func->name = grub_strdup (functionname_arg->str);
|
||||
if (! func->name)
|
||||
@@ -60,10 +61,19 @@ grub_script_function_create (struct grub_script_arg *functionname_arg,
|
||||
grub_script_function_t q;
|
||||
|
||||
q = *p;
|
||||
- grub_script_free (q->func);
|
||||
- q->func = cmd;
|
||||
grub_free (func);
|
||||
- func = q;
|
||||
+ if (q->executing > 0)
|
||||
+ {
|
||||
+ grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
+ N_("attempt to redefine a function being executed"));
|
||||
+ func = NULL;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ grub_script_free (q->func);
|
||||
+ q->func = cmd;
|
||||
+ func = q;
|
||||
+ }
|
||||
}
|
||||
else
|
||||
{
|
||||
diff --git a/grub-core/script/parser.y b/grub-core/script/parser.y
|
||||
index 4f0ab83..f80b86b 100644
|
||||
--- a/grub-core/script/parser.y
|
||||
+++ b/grub-core/script/parser.y
|
||||
@@ -289,7 +289,8 @@ function: "function" "name"
|
||||
grub_script_mem_free (state->func_mem);
|
||||
else {
|
||||
script->children = state->scripts;
|
||||
- grub_script_function_create ($2, script);
|
||||
+ if (!grub_script_function_create ($2, script))
|
||||
+ grub_script_free (script);
|
||||
}
|
||||
|
||||
state->scripts = $<scripts>3;
|
||||
diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h
|
||||
index b382bcf..6c48e07 100644
|
||||
--- a/include/grub/script_sh.h
|
||||
+++ b/include/grub/script_sh.h
|
||||
@@ -361,6 +361,8 @@ struct grub_script_function
|
||||
|
||||
/* The next element. */
|
||||
struct grub_script_function *next;
|
||||
+
|
||||
+ unsigned executing;
|
||||
};
|
||||
typedef struct grub_script_function *grub_script_function_t;
|
||||
|
||||
--
|
||||
2.14.4
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
From 68a09a74f6d726d79709847f3671c0a08e4fb5a0 Mon Sep 17 00:00:00 2001
|
||||
From: Colin Watson <cjwatson@debian.org>
|
||||
Date: Sat, 25 Jul 2020 12:15:37 +0100
|
||||
Subject: [PATCH 9/9] linux: Fix integer overflows in initrd size handling
|
||||
|
||||
These could be triggered by a crafted filesystem with very large files.
|
||||
|
||||
Fixes: CVE-2020-15707
|
||||
|
||||
Signed-off-by: Colin Watson <cjwatson@debian.org>
|
||||
Reviewed-by: Jan Setje-Eilers <jan.setjeeilers@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport
|
||||
CVE: CVE-2020-15707
|
||||
|
||||
Reference to upstream patch:
|
||||
https://git.savannah.gnu.org/cgit/grub.git/commit/?id=e7b8856f8be3292afdb38d2e8c70ad8d62a61e10
|
||||
|
||||
Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
|
||||
---
|
||||
grub-core/loader/linux.c | 74 +++++++++++++++++++++++++++++++++++-------------
|
||||
1 file changed, 54 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c
|
||||
index 471b214..8c8565a 100644
|
||||
--- a/grub-core/loader/linux.c
|
||||
+++ b/grub-core/loader/linux.c
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <grub/misc.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/mm.h>
|
||||
+#include <grub/safemath.h>
|
||||
|
||||
struct newc_head
|
||||
{
|
||||
@@ -98,13 +99,13 @@ free_dir (struct dir *root)
|
||||
grub_free (root);
|
||||
}
|
||||
|
||||
-static grub_size_t
|
||||
+static grub_err_t
|
||||
insert_dir (const char *name, struct dir **root,
|
||||
- grub_uint8_t *ptr)
|
||||
+ grub_uint8_t *ptr, grub_size_t *size)
|
||||
{
|
||||
struct dir *cur, **head = root;
|
||||
const char *cb, *ce = name;
|
||||
- grub_size_t size = 0;
|
||||
+ *size = 0;
|
||||
while (1)
|
||||
{
|
||||
for (cb = ce; *cb == '/'; cb++);
|
||||
@@ -130,14 +131,22 @@ insert_dir (const char *name, struct dir **root,
|
||||
ptr = make_header (ptr, name, ce - name,
|
||||
040777, 0);
|
||||
}
|
||||
- size += ALIGN_UP ((ce - (char *) name)
|
||||
- + sizeof (struct newc_head), 4);
|
||||
+ if (grub_add (*size,
|
||||
+ ALIGN_UP ((ce - (char *) name)
|
||||
+ + sizeof (struct newc_head), 4),
|
||||
+ size))
|
||||
+ {
|
||||
+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
|
||||
+ grub_free (n->name);
|
||||
+ grub_free (n);
|
||||
+ return grub_errno;
|
||||
+ }
|
||||
*head = n;
|
||||
cur = n;
|
||||
}
|
||||
root = &cur->next;
|
||||
}
|
||||
- return size;
|
||||
+ return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
@@ -173,26 +182,33 @@ grub_initrd_init (int argc, char *argv[],
|
||||
eptr = grub_strchr (ptr, ':');
|
||||
if (eptr)
|
||||
{
|
||||
+ grub_size_t dir_size, name_len;
|
||||
+
|
||||
initrd_ctx->components[i].newc_name = grub_strndup (ptr, eptr - ptr);
|
||||
- if (!initrd_ctx->components[i].newc_name)
|
||||
+ if (!initrd_ctx->components[i].newc_name ||
|
||||
+ insert_dir (initrd_ctx->components[i].newc_name, &root, 0,
|
||||
+ &dir_size))
|
||||
{
|
||||
grub_initrd_close (initrd_ctx);
|
||||
return grub_errno;
|
||||
}
|
||||
- initrd_ctx->size
|
||||
- += ALIGN_UP (sizeof (struct newc_head)
|
||||
- + grub_strlen (initrd_ctx->components[i].newc_name),
|
||||
- 4);
|
||||
- initrd_ctx->size += insert_dir (initrd_ctx->components[i].newc_name,
|
||||
- &root, 0);
|
||||
+ name_len = grub_strlen (initrd_ctx->components[i].newc_name);
|
||||
+ if (grub_add (initrd_ctx->size,
|
||||
+ ALIGN_UP (sizeof (struct newc_head) + name_len, 4),
|
||||
+ &initrd_ctx->size) ||
|
||||
+ grub_add (initrd_ctx->size, dir_size, &initrd_ctx->size))
|
||||
+ goto overflow;
|
||||
newc = 1;
|
||||
fname = eptr + 1;
|
||||
}
|
||||
}
|
||||
else if (newc)
|
||||
{
|
||||
- initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
|
||||
- + sizeof ("TRAILER!!!") - 1, 4);
|
||||
+ if (grub_add (initrd_ctx->size,
|
||||
+ ALIGN_UP (sizeof (struct newc_head)
|
||||
+ + sizeof ("TRAILER!!!") - 1, 4),
|
||||
+ &initrd_ctx->size))
|
||||
+ goto overflow;
|
||||
free_dir (root);
|
||||
root = 0;
|
||||
newc = 0;
|
||||
@@ -208,19 +224,29 @@ grub_initrd_init (int argc, char *argv[],
|
||||
initrd_ctx->nfiles++;
|
||||
initrd_ctx->components[i].size
|
||||
= grub_file_size (initrd_ctx->components[i].file);
|
||||
- initrd_ctx->size += initrd_ctx->components[i].size;
|
||||
+ if (grub_add (initrd_ctx->size, initrd_ctx->components[i].size,
|
||||
+ &initrd_ctx->size))
|
||||
+ goto overflow;
|
||||
}
|
||||
|
||||
if (newc)
|
||||
{
|
||||
initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
|
||||
- initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
|
||||
- + sizeof ("TRAILER!!!") - 1, 4);
|
||||
+ if (grub_add (initrd_ctx->size,
|
||||
+ ALIGN_UP (sizeof (struct newc_head)
|
||||
+ + sizeof ("TRAILER!!!") - 1, 4),
|
||||
+ &initrd_ctx->size))
|
||||
+ goto overflow;
|
||||
free_dir (root);
|
||||
root = 0;
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
+
|
||||
+ overflow:
|
||||
+ free_dir (root);
|
||||
+ grub_initrd_close (initrd_ctx);
|
||||
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
|
||||
}
|
||||
|
||||
grub_size_t
|
||||
@@ -261,8 +287,16 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
|
||||
|
||||
if (initrd_ctx->components[i].newc_name)
|
||||
{
|
||||
- ptr += insert_dir (initrd_ctx->components[i].newc_name,
|
||||
- &root, ptr);
|
||||
+ grub_size_t dir_size;
|
||||
+
|
||||
+ if (insert_dir (initrd_ctx->components[i].newc_name, &root, ptr,
|
||||
+ &dir_size))
|
||||
+ {
|
||||
+ free_dir (root);
|
||||
+ grub_initrd_close (initrd_ctx);
|
||||
+ return grub_errno;
|
||||
+ }
|
||||
+ ptr += dir_size;
|
||||
ptr = make_header (ptr, initrd_ctx->components[i].newc_name,
|
||||
grub_strlen (initrd_ctx->components[i].newc_name),
|
||||
0100777,
|
||||
--
|
||||
2.14.4
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
From 72c30928d3d461e0e2d20c5ff33bd96b6991d585 Mon Sep 17 00:00:00 2001
|
||||
From: Robert Yang <liezhi.yang@windriver.com>
|
||||
Date: Sat, 25 Jan 2014 23:49:44 -0500
|
||||
From 8790aa8bea736f52341a0430ff3e317d3be0f99b Mon Sep 17 00:00:00 2001
|
||||
From: Naveen Saini <naveen.kumar.saini@intel.com>
|
||||
Date: Mon, 15 Mar 2021 14:44:15 +0800
|
||||
Subject: [PATCH] autogen.sh: exclude .pc from po/POTFILES.in
|
||||
|
||||
Exclude the .pc from po/POTFILES.in since quilt uses "patch --backup",
|
||||
@@ -13,23 +13,24 @@ Upstream-Status: Inappropriate [OE specific]
|
||||
|
||||
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
|
||||
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
|
||||
Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
|
||||
---
|
||||
autogen.sh | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/autogen.sh b/autogen.sh
|
||||
index ef43270..a7067a7 100755
|
||||
index 31b0ced7e..c63ae766c 100755
|
||||
--- a/autogen.sh
|
||||
+++ b/autogen.sh
|
||||
@@ -13,7 +13,7 @@ fi
|
||||
export LC_COLLATE=C
|
||||
unset LC_ALL
|
||||
|
||||
-find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' ! -ipath './gnulib/*' ! -iname './grub-core/lib/gnulib/*' |sort > po/POTFILES.in
|
||||
+find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' ! -ipath './gnulib/*' ! -iname './grub-core/lib/gnulib/*' ! -path './.pc/*' |sort > po/POTFILES.in
|
||||
-find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' ! -ipath './gnulib/*' ! -ipath './grub-core/lib/gnulib/*' |sort > po/POTFILES.in
|
||||
+find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' ! -ipath './gnulib/*' ! -ipath './grub-core/lib/gnulib/*' ! -path './.pc/*' |sort > po/POTFILES.in
|
||||
find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in
|
||||
|
||||
echo "Importing unicode..."
|
||||
--
|
||||
2.7.4
|
||||
2.17.1
|
||||
|
||||
|
||||
@@ -1,246 +0,0 @@
|
||||
From c005f62f5c4b26a77b916c8f76a852324439ecb3 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 15 Jun 2020 12:15:29 -0400
|
||||
Subject: [PATCH 2/9] calloc: Make sure we always have an overflow-checking
|
||||
calloc() available
|
||||
|
||||
This tries to make sure that everywhere in this source tree, we always have
|
||||
an appropriate version of calloc() (i.e. grub_calloc(), xcalloc(), etc.)
|
||||
available, and that they all safely check for overflow and return NULL when
|
||||
it would occur.
|
||||
|
||||
Upstream-Status: Backport [commit 64e26162ebfe68317c143ca5ec996c892019f8f8
|
||||
from https://git.savannah.gnu.org/git/grub.git]
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
|
||||
---
|
||||
grub-core/kern/emu/misc.c | 12 ++++++++++++
|
||||
grub-core/kern/emu/mm.c | 10 ++++++++++
|
||||
grub-core/kern/mm.c | 40 ++++++++++++++++++++++++++++++++++++++
|
||||
grub-core/lib/libgcrypt_wrap/mem.c | 11 +++++++++--
|
||||
grub-core/lib/posix_wrap/stdlib.h | 8 +++++++-
|
||||
include/grub/emu/misc.h | 1 +
|
||||
include/grub/mm.h | 6 ++++++
|
||||
7 files changed, 85 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c
|
||||
index 65db79b..dfd8a8e 100644
|
||||
--- a/grub-core/kern/emu/misc.c
|
||||
+++ b/grub-core/kern/emu/misc.c
|
||||
@@ -85,6 +85,18 @@ grub_util_error (const char *fmt, ...)
|
||||
exit (1);
|
||||
}
|
||||
|
||||
+void *
|
||||
+xcalloc (grub_size_t nmemb, grub_size_t size)
|
||||
+{
|
||||
+ void *p;
|
||||
+
|
||||
+ p = calloc (nmemb, size);
|
||||
+ if (!p)
|
||||
+ grub_util_error ("%s", _("out of memory"));
|
||||
+
|
||||
+ return p;
|
||||
+}
|
||||
+
|
||||
void *
|
||||
xmalloc (grub_size_t size)
|
||||
{
|
||||
diff --git a/grub-core/kern/emu/mm.c b/grub-core/kern/emu/mm.c
|
||||
index f262e95..145b01d 100644
|
||||
--- a/grub-core/kern/emu/mm.c
|
||||
+++ b/grub-core/kern/emu/mm.c
|
||||
@@ -25,6 +25,16 @@
|
||||
#include <string.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
+void *
|
||||
+grub_calloc (grub_size_t nmemb, grub_size_t size)
|
||||
+{
|
||||
+ void *ret;
|
||||
+ ret = calloc (nmemb, size);
|
||||
+ if (!ret)
|
||||
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
void *
|
||||
grub_malloc (grub_size_t size)
|
||||
{
|
||||
diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c
|
||||
index ee88ff6..f2822a8 100644
|
||||
--- a/grub-core/kern/mm.c
|
||||
+++ b/grub-core/kern/mm.c
|
||||
@@ -67,8 +67,10 @@
|
||||
#include <grub/dl.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/mm_private.h>
|
||||
+#include <grub/safemath.h>
|
||||
|
||||
#ifdef MM_DEBUG
|
||||
+# undef grub_calloc
|
||||
# undef grub_malloc
|
||||
# undef grub_zalloc
|
||||
# undef grub_realloc
|
||||
@@ -375,6 +377,30 @@ 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)
|
||||
@@ -561,6 +587,20 @@ grub_mm_dump (unsigned lineno)
|
||||
grub_printf ("\n");
|
||||
}
|
||||
|
||||
+void *
|
||||
+grub_debug_calloc (const char *file, int line, grub_size_t nmemb, grub_size_t size)
|
||||
+{
|
||||
+ void *ptr;
|
||||
+
|
||||
+ if (grub_mm_debug)
|
||||
+ grub_printf ("%s:%d: calloc (0x%" PRIxGRUB_SIZE ", 0x%" PRIxGRUB_SIZE ") = ",
|
||||
+ file, line, size);
|
||||
+ ptr = grub_calloc (nmemb, size);
|
||||
+ if (grub_mm_debug)
|
||||
+ grub_printf ("%p\n", ptr);
|
||||
+ return ptr;
|
||||
+}
|
||||
+
|
||||
void *
|
||||
grub_debug_malloc (const char *file, int line, grub_size_t size)
|
||||
{
|
||||
diff --git a/grub-core/lib/libgcrypt_wrap/mem.c b/grub-core/lib/libgcrypt_wrap/mem.c
|
||||
index beeb661..74c6eaf 100644
|
||||
--- a/grub-core/lib/libgcrypt_wrap/mem.c
|
||||
+++ b/grub-core/lib/libgcrypt_wrap/mem.c
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <grub/crypto.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/env.h>
|
||||
+#include <grub/safemath.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
@@ -36,7 +37,10 @@ void *
|
||||
gcry_xcalloc (size_t n, size_t m)
|
||||
{
|
||||
void *ret;
|
||||
- ret = grub_zalloc (n * m);
|
||||
+ size_t sz;
|
||||
+ if (grub_mul (n, m, &sz))
|
||||
+ grub_fatal ("gcry_xcalloc would overflow");
|
||||
+ ret = grub_zalloc (sz);
|
||||
if (!ret)
|
||||
grub_fatal ("gcry_xcalloc failed");
|
||||
return ret;
|
||||
@@ -56,7 +60,10 @@ void *
|
||||
gcry_xcalloc_secure (size_t n, size_t m)
|
||||
{
|
||||
void *ret;
|
||||
- ret = grub_zalloc (n * m);
|
||||
+ size_t sz;
|
||||
+ if (grub_mul (n, m, &sz))
|
||||
+ grub_fatal ("gcry_xcalloc would overflow");
|
||||
+ ret = grub_zalloc (sz);
|
||||
if (!ret)
|
||||
grub_fatal ("gcry_xcalloc failed");
|
||||
return ret;
|
||||
diff --git a/grub-core/lib/posix_wrap/stdlib.h b/grub-core/lib/posix_wrap/stdlib.h
|
||||
index 3b46f47..7a8d385 100644
|
||||
--- a/grub-core/lib/posix_wrap/stdlib.h
|
||||
+++ b/grub-core/lib/posix_wrap/stdlib.h
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
+#include <grub/safemath.h>
|
||||
|
||||
static inline void
|
||||
free (void *ptr)
|
||||
@@ -37,7 +38,12 @@ malloc (grub_size_t size)
|
||||
static inline void *
|
||||
calloc (grub_size_t size, grub_size_t nelem)
|
||||
{
|
||||
- return grub_zalloc (size * nelem);
|
||||
+ grub_size_t sz;
|
||||
+
|
||||
+ if (grub_mul (size, nelem, &sz))
|
||||
+ return NULL;
|
||||
+
|
||||
+ return grub_zalloc (sz);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h
|
||||
index ce464cf..ff9c48a 100644
|
||||
--- a/include/grub/emu/misc.h
|
||||
+++ b/include/grub/emu/misc.h
|
||||
@@ -47,6 +47,7 @@ grub_util_device_is_mapped (const char *dev);
|
||||
#define GRUB_HOST_PRIuLONG_LONG "llu"
|
||||
#define GRUB_HOST_PRIxLONG_LONG "llx"
|
||||
|
||||
+void * EXPORT_FUNC(xcalloc) (grub_size_t nmemb, grub_size_t size) WARN_UNUSED_RESULT;
|
||||
void * EXPORT_FUNC(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT;
|
||||
void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) WARN_UNUSED_RESULT;
|
||||
char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT;
|
||||
diff --git a/include/grub/mm.h b/include/grub/mm.h
|
||||
index 28e2e53..9c38dd3 100644
|
||||
--- a/include/grub/mm.h
|
||||
+++ b/include/grub/mm.h
|
||||
@@ -29,6 +29,7 @@
|
||||
#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);
|
||||
@@ -48,6 +49,9 @@ extern int EXPORT_VAR(grub_mm_debug);
|
||||
void grub_mm_dump_free (void);
|
||||
void grub_mm_dump (unsigned lineno);
|
||||
|
||||
+#define grub_calloc(nmemb, size) \
|
||||
+ grub_debug_calloc (GRUB_FILE, __LINE__, nmemb, size)
|
||||
+
|
||||
#define grub_malloc(size) \
|
||||
grub_debug_malloc (GRUB_FILE, __LINE__, size)
|
||||
|
||||
@@ -63,6 +67,8 @@ void grub_mm_dump (unsigned lineno);
|
||||
#define grub_free(ptr) \
|
||||
grub_debug_free (GRUB_FILE, __LINE__, ptr)
|
||||
|
||||
+void *EXPORT_FUNC(grub_debug_calloc) (const char *file, int line,
|
||||
+ grub_size_t nmemb, grub_size_t size);
|
||||
void *EXPORT_FUNC(grub_debug_malloc) (const char *file, int line,
|
||||
grub_size_t size);
|
||||
void *EXPORT_FUNC(grub_debug_zalloc) (const char *file, int line,
|
||||
--
|
||||
2.14.4
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
The output in moddep.lst generated from syminfo.lst using genmoddep.awk is
|
||||
not deterministic since the order of the dependencies on each line can vary
|
||||
depending on how awk sorts the values in the array.
|
||||
From b6f9b3f6fa782807c4a7ec16ee8ef868cdfbf468 Mon Sep 17 00:00:00 2001
|
||||
From: Naveen Saini <naveen.kumar.saini@intel.com>
|
||||
Date: Mon, 15 Mar 2021 14:56:18 +0800
|
||||
Subject: [PATCH] The output in moddep.lst generated from syminfo.lst using
|
||||
genmoddep.awk is not deterministic since the order of the dependencies on
|
||||
each line can vary depending on how awk sorts the values in the array.
|
||||
|
||||
Be deterministic in the output by sorting the dependencies on each line.
|
||||
|
||||
@@ -13,11 +16,29 @@ keys of the dict.
|
||||
|
||||
Upstream-Status: Pending
|
||||
Richard Purdie <richard.purdie@linuxfoundation.org>
|
||||
Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
|
||||
---
|
||||
gentpl.py | 1 +
|
||||
grub-core/genmoddep.awk | 4 +++-
|
||||
util/import_unicode.py | 2 +-
|
||||
3 files changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
Index: grub-2.04/grub-core/genmoddep.awk
|
||||
===================================================================
|
||||
--- grub-2.04.orig/grub-core/genmoddep.awk
|
||||
+++ grub-2.04/grub-core/genmoddep.awk
|
||||
diff --git a/gentpl.py b/gentpl.py
|
||||
index c86550d4f..589285192 100644
|
||||
--- a/gentpl.py
|
||||
+++ b/gentpl.py
|
||||
@@ -568,6 +568,7 @@ def foreach_platform_value(defn, platform, suffix, closure):
|
||||
for group in RMAP[platform]:
|
||||
for value in defn.find_all(group + suffix):
|
||||
r.append(closure(value))
|
||||
+ r.sort()
|
||||
return ''.join(r)
|
||||
|
||||
def platform_conditional(platform, closure):
|
||||
diff --git a/grub-core/genmoddep.awk b/grub-core/genmoddep.awk
|
||||
index 04c2863e5..247436392 100644
|
||||
--- a/grub-core/genmoddep.awk
|
||||
+++ b/grub-core/genmoddep.awk
|
||||
@@ -59,7 +59,9 @@ END {
|
||||
}
|
||||
modlist = ""
|
||||
@@ -29,22 +50,10 @@ Index: grub-2.04/grub-core/genmoddep.awk
|
||||
modlist = modlist " " depmod;
|
||||
inverse_dependencies[depmod] = inverse_dependencies[depmod] " " mod
|
||||
depcount[mod]++
|
||||
Index: grub-2.04/gentpl.py
|
||||
===================================================================
|
||||
--- grub-2.04.orig/gentpl.py
|
||||
+++ grub-2.04/gentpl.py
|
||||
@@ -568,6 +568,7 @@ def foreach_platform_value(defn, platfor
|
||||
for group in RMAP[platform]:
|
||||
for value in defn.find_all(group + suffix):
|
||||
r.append(closure(value))
|
||||
+ r.sort()
|
||||
return ''.join(r)
|
||||
|
||||
def platform_conditional(platform, closure):
|
||||
Index: grub-2.04/util/import_unicode.py
|
||||
===================================================================
|
||||
--- grub-2.04.orig/util/import_unicode.py
|
||||
+++ grub-2.04/util/import_unicode.py
|
||||
diff --git a/util/import_unicode.py b/util/import_unicode.py
|
||||
index 08f80591e..1f434a069 100644
|
||||
--- a/util/import_unicode.py
|
||||
+++ b/util/import_unicode.py
|
||||
@@ -174,7 +174,7 @@ infile.close ()
|
||||
|
||||
outfile.write ("struct grub_unicode_arabic_shape grub_unicode_arabic_shapes[] = {\n ")
|
||||
@@ -54,3 +63,6 @@ Index: grub-2.04/util/import_unicode.py
|
||||
try:
|
||||
if arabicsubst[x]['join'] == "DUAL":
|
||||
outfile.write ("{0x%x, 0x%x, 0x%x, 0x%x, 0x%x},\n " % (arabicsubst[x][0], arabicsubst[x][1], arabicsubst[x][2], arabicsubst[x][3], arabicsubst[x][4]))
|
||||
--
|
||||
2.17.1
|
||||
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
From 8eb02bcb5897b238b29ff762402bb0c3028f0eab Mon Sep 17 00:00:00 2001
|
||||
From: Michael Chang <mchang@suse.com>
|
||||
Date: Thu, 19 Mar 2020 13:56:13 +0800
|
||||
Subject: [PATCH 3/9] lvm: Add LVM cache logical volume handling
|
||||
|
||||
The LVM cache logical volume is the logical volume consisting of the original
|
||||
and the cache pool logical volume. The original is usually on a larger and
|
||||
slower storage device while the cache pool is on a smaller and faster one. The
|
||||
performance of the original volume can be improved by storing the frequently
|
||||
used data on the cache pool to utilize the greater performance of faster
|
||||
device.
|
||||
|
||||
The default cache mode "writethrough" ensures that any data written will be
|
||||
stored both in the cache and on the origin LV, therefore grub can be straight
|
||||
to read the original lv as no data loss is guarenteed.
|
||||
|
||||
The second cache mode is "writeback", which delays writing from the cache pool
|
||||
back to the origin LV to have increased performance. The drawback is potential
|
||||
data loss if losing the associated cache device.
|
||||
|
||||
During the boot time grub reads the LVM offline i.e. LVM volumes are not
|
||||
activated and mounted, hence it should be fine to read directly from original
|
||||
lv since all cached data should have been flushed back in the process of taking
|
||||
it offline.
|
||||
|
||||
It is also not much helpful to the situation by adding fsync calls to the
|
||||
install code. The fsync did not force to write back dirty cache to the original
|
||||
device and rather it would update associated cache metadata to complete the
|
||||
write transaction with the cache device. IOW the writes to cached blocks still
|
||||
go only to the cache device.
|
||||
|
||||
To write back dirty cache, as LVM cache did not support dirty cache flush per
|
||||
block range, there'no way to do it for file. On the other hand the "cleaner"
|
||||
policy is implemented and can be used to write back "all" dirty blocks in a
|
||||
cache, which effectively drain all dirty cache gradually to attain and last in
|
||||
the "clean" state, which can be useful for shrinking or decommissioning a
|
||||
cache. The result and effect is not what we are looking for here.
|
||||
|
||||
In conclusion, as it seems no way to enforce file writes to the original
|
||||
device, grub may suffer from power failure as it cannot assemble the cache
|
||||
device and read the dirty data from it. However since the case is only
|
||||
applicable to writeback mode which is sensitive to data lost in nature, I'd
|
||||
still like to propose my (relatively simple) patch and treat reading dirty
|
||||
cache as improvement.
|
||||
|
||||
Upstream-Status: Backport [commit 0454b0445393aafc5600e92ef0c39494e333b135
|
||||
from https://git.savannah.gnu.org/git/grub.git]
|
||||
|
||||
Signed-off-by: Michael Chang <mchang@suse.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
|
||||
---
|
||||
grub-core/disk/lvm.c | 190 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 190 insertions(+)
|
||||
|
||||
diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c
|
||||
index 7b265c7..dc6b83b 100644
|
||||
--- a/grub-core/disk/lvm.c
|
||||
+++ b/grub-core/disk/lvm.c
|
||||
@@ -33,6 +33,14 @@
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
+struct cache_lv
|
||||
+{
|
||||
+ struct grub_diskfilter_lv *lv;
|
||||
+ char *cache_pool;
|
||||
+ char *origin;
|
||||
+ struct cache_lv *next;
|
||||
+};
|
||||
+
|
||||
|
||||
/* Go the string STR and return the number after STR. *P will point
|
||||
at the number. In case STR is not found, *P will be NULL and the
|
||||
@@ -95,6 +103,34 @@ grub_lvm_check_flag (char *p, const char *str, const char *flag)
|
||||
}
|
||||
}
|
||||
|
||||
+static void
|
||||
+grub_lvm_free_cache_lvs (struct cache_lv *cache_lvs)
|
||||
+{
|
||||
+ struct cache_lv *cache;
|
||||
+
|
||||
+ while ((cache = cache_lvs))
|
||||
+ {
|
||||
+ cache_lvs = cache_lvs->next;
|
||||
+
|
||||
+ if (cache->lv)
|
||||
+ {
|
||||
+ unsigned int i;
|
||||
+
|
||||
+ for (i = 0; i < cache->lv->segment_count; ++i)
|
||||
+ if (cache->lv->segments)
|
||||
+ grub_free (cache->lv->segments[i].nodes);
|
||||
+ grub_free (cache->lv->segments);
|
||||
+ grub_free (cache->lv->fullname);
|
||||
+ grub_free (cache->lv->idname);
|
||||
+ grub_free (cache->lv->name);
|
||||
+ }
|
||||
+ grub_free (cache->lv);
|
||||
+ grub_free (cache->origin);
|
||||
+ grub_free (cache->cache_pool);
|
||||
+ grub_free (cache);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static struct grub_diskfilter_vg *
|
||||
grub_lvm_detect (grub_disk_t disk,
|
||||
struct grub_diskfilter_pv_id *id,
|
||||
@@ -242,6 +278,8 @@ grub_lvm_detect (grub_disk_t disk,
|
||||
|
||||
if (! vg)
|
||||
{
|
||||
+ struct cache_lv *cache_lvs = NULL;
|
||||
+
|
||||
/* First time we see this volume group. We've to create the
|
||||
whole volume group structure. */
|
||||
vg = grub_malloc (sizeof (*vg));
|
||||
@@ -671,6 +709,106 @@ grub_lvm_detect (grub_disk_t disk,
|
||||
seg->nodes[seg->node_count - 1].name = tmp;
|
||||
}
|
||||
}
|
||||
+ else if (grub_memcmp (p, "cache\"",
|
||||
+ sizeof ("cache\"") - 1) == 0)
|
||||
+ {
|
||||
+ struct cache_lv *cache = NULL;
|
||||
+
|
||||
+ char *p2, *p3;
|
||||
+ grub_size_t sz;
|
||||
+
|
||||
+ cache = grub_zalloc (sizeof (*cache));
|
||||
+ if (!cache)
|
||||
+ goto cache_lv_fail;
|
||||
+ cache->lv = grub_zalloc (sizeof (*cache->lv));
|
||||
+ if (!cache->lv)
|
||||
+ goto cache_lv_fail;
|
||||
+ grub_memcpy (cache->lv, lv, sizeof (*cache->lv));
|
||||
+
|
||||
+ if (lv->fullname)
|
||||
+ {
|
||||
+ cache->lv->fullname = grub_strdup (lv->fullname);
|
||||
+ if (!cache->lv->fullname)
|
||||
+ goto cache_lv_fail;
|
||||
+ }
|
||||
+ if (lv->idname)
|
||||
+ {
|
||||
+ cache->lv->idname = grub_strdup (lv->idname);
|
||||
+ if (!cache->lv->idname)
|
||||
+ goto cache_lv_fail;
|
||||
+ }
|
||||
+ if (lv->name)
|
||||
+ {
|
||||
+ cache->lv->name = grub_strdup (lv->name);
|
||||
+ if (!cache->lv->name)
|
||||
+ goto cache_lv_fail;
|
||||
+ }
|
||||
+
|
||||
+ skip_lv = 1;
|
||||
+
|
||||
+ p2 = grub_strstr (p, "cache_pool = \"");
|
||||
+ if (!p2)
|
||||
+ goto cache_lv_fail;
|
||||
+
|
||||
+ p2 = grub_strchr (p2, '"');
|
||||
+ if (!p2)
|
||||
+ goto cache_lv_fail;
|
||||
+
|
||||
+ p3 = ++p2;
|
||||
+ p3 = grub_strchr (p3, '"');
|
||||
+ if (!p3)
|
||||
+ goto cache_lv_fail;
|
||||
+
|
||||
+ sz = p3 - p2;
|
||||
+
|
||||
+ cache->cache_pool = grub_malloc (sz + 1);
|
||||
+ if (!cache->cache_pool)
|
||||
+ goto cache_lv_fail;
|
||||
+ grub_memcpy (cache->cache_pool, p2, sz);
|
||||
+ cache->cache_pool[sz] = '\0';
|
||||
+
|
||||
+ p2 = grub_strstr (p, "origin = \"");
|
||||
+ if (!p2)
|
||||
+ goto cache_lv_fail;
|
||||
+
|
||||
+ p2 = grub_strchr (p2, '"');
|
||||
+ if (!p2)
|
||||
+ goto cache_lv_fail;
|
||||
+
|
||||
+ p3 = ++p2;
|
||||
+ p3 = grub_strchr (p3, '"');
|
||||
+ if (!p3)
|
||||
+ goto cache_lv_fail;
|
||||
+
|
||||
+ sz = p3 - p2;
|
||||
+
|
||||
+ cache->origin = grub_malloc (sz + 1);
|
||||
+ if (!cache->origin)
|
||||
+ goto cache_lv_fail;
|
||||
+ grub_memcpy (cache->origin, p2, sz);
|
||||
+ cache->origin[sz] = '\0';
|
||||
+
|
||||
+ cache->next = cache_lvs;
|
||||
+ cache_lvs = cache;
|
||||
+ break;
|
||||
+
|
||||
+ cache_lv_fail:
|
||||
+ if (cache)
|
||||
+ {
|
||||
+ grub_free (cache->origin);
|
||||
+ grub_free (cache->cache_pool);
|
||||
+ if (cache->lv)
|
||||
+ {
|
||||
+ grub_free (cache->lv->fullname);
|
||||
+ grub_free (cache->lv->idname);
|
||||
+ grub_free (cache->lv->name);
|
||||
+ }
|
||||
+ grub_free (cache->lv);
|
||||
+ grub_free (cache);
|
||||
+ }
|
||||
+ grub_lvm_free_cache_lvs (cache_lvs);
|
||||
+ goto fail4;
|
||||
+ }
|
||||
else
|
||||
{
|
||||
#ifdef GRUB_UTIL
|
||||
@@ -747,6 +885,58 @@ grub_lvm_detect (grub_disk_t disk,
|
||||
}
|
||||
|
||||
}
|
||||
+
|
||||
+ {
|
||||
+ struct cache_lv *cache;
|
||||
+
|
||||
+ for (cache = cache_lvs; cache; cache = cache->next)
|
||||
+ {
|
||||
+ struct grub_diskfilter_lv *lv;
|
||||
+
|
||||
+ for (lv = vg->lvs; lv; lv = lv->next)
|
||||
+ if (grub_strcmp (lv->name, cache->origin) == 0)
|
||||
+ break;
|
||||
+ if (lv)
|
||||
+ {
|
||||
+ cache->lv->segments = grub_malloc (lv->segment_count * sizeof (*lv->segments));
|
||||
+ if (!cache->lv->segments)
|
||||
+ {
|
||||
+ grub_lvm_free_cache_lvs (cache_lvs);
|
||||
+ goto fail4;
|
||||
+ }
|
||||
+ grub_memcpy (cache->lv->segments, lv->segments, lv->segment_count * sizeof (*lv->segments));
|
||||
+
|
||||
+ for (i = 0; i < lv->segment_count; ++i)
|
||||
+ {
|
||||
+ struct grub_diskfilter_node *nodes = lv->segments[i].nodes;
|
||||
+ grub_size_t node_count = lv->segments[i].node_count;
|
||||
+
|
||||
+ cache->lv->segments[i].nodes = grub_malloc (node_count * sizeof (*nodes));
|
||||
+ if (!cache->lv->segments[i].nodes)
|
||||
+ {
|
||||
+ for (j = 0; j < i; ++j)
|
||||
+ grub_free (cache->lv->segments[j].nodes);
|
||||
+ grub_free (cache->lv->segments);
|
||||
+ cache->lv->segments = NULL;
|
||||
+ grub_lvm_free_cache_lvs (cache_lvs);
|
||||
+ goto fail4;
|
||||
+ }
|
||||
+ grub_memcpy (cache->lv->segments[i].nodes, nodes, node_count * sizeof (*nodes));
|
||||
+ }
|
||||
+
|
||||
+ if (cache->lv->segments)
|
||||
+ {
|
||||
+ cache->lv->segment_count = lv->segment_count;
|
||||
+ cache->lv->vg = vg;
|
||||
+ cache->lv->next = vg->lvs;
|
||||
+ vg->lvs = cache->lv;
|
||||
+ cache->lv = NULL;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ grub_lvm_free_cache_lvs (cache_lvs);
|
||||
if (grub_diskfilter_vg_register (vg))
|
||||
goto fail4;
|
||||
}
|
||||
--
|
||||
2.14.4
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
From 06c361a71c4998635493610e5d76d0d223925251 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 15 Jun 2020 10:58:42 -0400
|
||||
Subject: [PATCH 5/9] safemath: Add some arithmetic primitives that check for
|
||||
overflow
|
||||
|
||||
This adds a new header, include/grub/safemath.h, that includes easy to
|
||||
use wrappers for __builtin_{add,sub,mul}_overflow() declared like:
|
||||
|
||||
bool OP(a, b, res)
|
||||
|
||||
where OP is grub_add, grub_sub or grub_mul. OP() returns true in the
|
||||
case where the operation would overflow and res is not modified.
|
||||
Otherwise, false is returned and the operation is executed.
|
||||
|
||||
These arithmetic primitives require newer compiler versions. So, bump
|
||||
these requirements in the INSTALL file too.
|
||||
|
||||
Upstream-Status: Backport [commit 68708c4503018d61dbcce7ac11cbb511d6425f4d
|
||||
from https://git.savannah.gnu.org/git/grub.git]
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
[YL: omit the change to INSTALL from original patch]
|
||||
Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
|
||||
---
|
||||
include/grub/compiler.h | 8 ++++++++
|
||||
include/grub/safemath.h | 37 +++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 45 insertions(+)
|
||||
create mode 100644 include/grub/safemath.h
|
||||
|
||||
diff --git a/include/grub/compiler.h b/include/grub/compiler.h
|
||||
index c9e1d7a..8f3be3a 100644
|
||||
--- a/include/grub/compiler.h
|
||||
+++ b/include/grub/compiler.h
|
||||
@@ -48,4 +48,12 @@
|
||||
# define WARN_UNUSED_RESULT
|
||||
#endif
|
||||
|
||||
+#if defined(__clang__) && defined(__clang_major__) && defined(__clang_minor__)
|
||||
+# define CLANG_PREREQ(maj,min) \
|
||||
+ ((__clang_major__ > (maj)) || \
|
||||
+ (__clang_major__ == (maj) && __clang_minor__ >= (min)))
|
||||
+#else
|
||||
+# define CLANG_PREREQ(maj,min) 0
|
||||
+#endif
|
||||
+
|
||||
#endif /* ! GRUB_COMPILER_HEADER */
|
||||
diff --git a/include/grub/safemath.h b/include/grub/safemath.h
|
||||
new file mode 100644
|
||||
index 0000000..c17b89b
|
||||
--- /dev/null
|
||||
+++ b/include/grub/safemath.h
|
||||
@@ -0,0 +1,37 @@
|
||||
+/*
|
||||
+ * GRUB -- GRand Unified Bootloader
|
||||
+ * Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
+ *
|
||||
+ * GRUB is free software: you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation, either version 3 of the License, or
|
||||
+ * (at your option) any later version.
|
||||
+ *
|
||||
+ * GRUB is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License
|
||||
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
+ *
|
||||
+ * Arithmetic operations that protect against overflow.
|
||||
+ */
|
||||
+
|
||||
+#ifndef GRUB_SAFEMATH_H
|
||||
+#define GRUB_SAFEMATH_H 1
|
||||
+
|
||||
+#include <grub/compiler.h>
|
||||
+
|
||||
+/* These appear in gcc 5.1 and clang 3.8. */
|
||||
+#if GNUC_PREREQ(5, 1) || CLANG_PREREQ(3, 8)
|
||||
+
|
||||
+#define grub_add(a, b, res) __builtin_add_overflow(a, b, res)
|
||||
+#define grub_sub(a, b, res) __builtin_sub_overflow(a, b, res)
|
||||
+#define grub_mul(a, b, res) __builtin_mul_overflow(a, b, res)
|
||||
+
|
||||
+#else
|
||||
+#error gcc 5.1 or newer or clang 3.8 or newer is required
|
||||
+#endif
|
||||
+
|
||||
+#endif /* GRUB_SAFEMATH_H */
|
||||
--
|
||||
2.14.4
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
From e219bad8cee67b2bb21712df8f055706f8da25d2 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Coulson <chris.coulson@canonical.com>
|
||||
Date: Fri, 10 Jul 2020 11:21:14 +0100
|
||||
Subject: [PATCH 7/9] script: Remove unused fields from grub_script_function
|
||||
struct
|
||||
|
||||
Upstream-Status: Backport [commit 1a8d9c9b4ab6df7669b5aa36a56477f297825b96
|
||||
from https://git.savannah.gnu.org/git/grub.git]
|
||||
|
||||
Signed-off-by: Chris Coulson <chris.coulson@canonical.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
|
||||
---
|
||||
include/grub/script_sh.h | 5 -----
|
||||
1 file changed, 5 deletions(-)
|
||||
|
||||
diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h
|
||||
index 360c2be..b382bcf 100644
|
||||
--- a/include/grub/script_sh.h
|
||||
+++ b/include/grub/script_sh.h
|
||||
@@ -359,13 +359,8 @@ struct grub_script_function
|
||||
/* The script function. */
|
||||
struct grub_script *func;
|
||||
|
||||
- /* The flags. */
|
||||
- unsigned flags;
|
||||
-
|
||||
/* The next element. */
|
||||
struct grub_script_function *next;
|
||||
-
|
||||
- int references;
|
||||
};
|
||||
typedef struct grub_script_function *grub_script_function_t;
|
||||
|
||||
--
|
||||
2.14.4
|
||||
|
||||
@@ -11,8 +11,6 @@ SRC_URI += " \
|
||||
file://cfg \
|
||||
"
|
||||
|
||||
S = "${WORKDIR}/grub-${PV}"
|
||||
|
||||
# Determine the target arch for the grub modules
|
||||
python __anonymous () {
|
||||
import re
|
||||
@@ -13,25 +13,23 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
|
||||
|
||||
CVE_PRODUCT = "grub2"
|
||||
|
||||
SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
|
||||
SRC_URI = "https://alpha.gnu.org/gnu/grub/grub-${REALPV}.tar.xz \
|
||||
file://0001-Disable-mfpmath-sse-as-well-when-SSE-is-disabled.patch \
|
||||
file://autogen.sh-exclude-pc.patch \
|
||||
file://grub-module-explicitly-keeps-symbole-.module_license.patch \
|
||||
file://0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch \
|
||||
file://CVE-2020-10713.patch \
|
||||
file://calloc-Make-sure-we-always-have-an-overflow-checking.patch \
|
||||
file://lvm-Add-LVM-cache-logical-volume-handling.patch \
|
||||
file://CVE-2020-14308-calloc-Use-calloc-at-most-places.patch \
|
||||
file://safemath-Add-some-arithmetic-primitives-that-check-f.patch \
|
||||
file://CVE-2020-14309-CVE-2020-14310-CVE-2020-14311-malloc-Use-overflow-checking-primitives-where-we-do-.patch \
|
||||
file://script-Remove-unused-fields-from-grub_script_functio.patch \
|
||||
file://CVE-2020-15706-script-Avoid-a-use-after-free-when-redefining-a-func.patch \
|
||||
file://CVE-2020-15707-linux-Fix-integer-overflows-in-initrd-size-handling.patch \
|
||||
file://6643507ce30f775008e093580f0c9499dfb2c485.patch \
|
||||
file://determinism.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934"
|
||||
SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"
|
||||
|
||||
SRC_URI[sha256sum] = "2c87f1f21e2ab50043e6cd9163c08f1b6c3a6171556bf23ff9ed65b074145484"
|
||||
|
||||
REALPV = "2.06~rc1"
|
||||
PV = "2.04+${REALPV}"
|
||||
|
||||
S = "${WORKDIR}/grub-${REALPV}"
|
||||
|
||||
UPSTREAM_CHECK_URI = "${GNU_MIRROR}/grub"
|
||||
UPSTREAM_CHECK_REGEX = "grub-(?P<pver>\d+(\.\d+)+)\.tar\.(gz|xz)"
|
||||
|
||||
DEPENDS = "flex-native bison-native gettext-native"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user