Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 35 additions & 18 deletions packages/grub/0017-gpt-add-search-by-disk-uuid-command.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From a4ecd2c5ff6cb23af51977a622dca5fc2a9b7cef Mon Sep 17 00:00:00 2001
From d474ef64bf0229a6aeefca63f03c808f2e519e59 Mon Sep 17 00:00:00 2001
From: Alex Crawford <alex.crawford@coreos.com>
Date: Mon, 31 Aug 2015 15:15:48 -0700
Subject: [PATCH] gpt: add search by disk uuid command
Expand All @@ -7,18 +7,18 @@ Subject: [PATCH] gpt: add search by disk uuid command
general search_flags parameter now instead of a no_floppy flag.]

Signed-off-by: Markus Boehme <markubo@amazon.com>

Signed-off-by: Jingwei Wang <jweiw@amazon.com>
---
Makefile.util.def | 1 +
grub-core/Makefile.core.def | 5 ++++
grub-core/commands/search.c | 28 +++++++++++++++++++++--
grub-core/commands/search.c | 32 ++++++++++++++++++++++----
grub-core/commands/search_disk_uuid.c | 5 ++++
grub-core/commands/search_wrap.c | 5 ++++
grub-core/lib/gpt.c | 21 +++++++++++++++++
include/grub/gpt_partition.h | 4 ++++
include/grub/search.h | 3 +++
tests/gpt_unit_test.c | 33 +++++++++++++++++++++++++++
9 files changed, 103 insertions(+), 2 deletions(-)
9 files changed, 105 insertions(+), 4 deletions(-)
create mode 100644 grub-core/commands/search_disk_uuid.c

diff --git a/Makefile.util.def b/Makefile.util.def
Expand All @@ -34,10 +34,10 @@ index 8f74405..33ce60d 100644
common = grub-core/kern/emu/hostfs.c;
common = grub-core/lib/gpt.c;
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 3cde624..3096cd4 100644
index 87f3ae7..5b8728e 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -1162,6 +1162,11 @@ module = {
@@ -1163,6 +1163,11 @@ module = {
common = commands/search_part_label.c;
};

Expand All @@ -50,7 +50,7 @@ index 3cde624..3096cd4 100644
name = setpci;
common = commands/setpci.c;
diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c
index bb0c7cb..ec03c75 100644
index 382bbc2..4df3be7 100644
--- a/grub-core/commands/search.c
+++ b/grub-core/commands/search.c
@@ -30,7 +30,8 @@
Expand All @@ -63,16 +63,16 @@ index bb0c7cb..ec03c75 100644
#include <grub/gpt_partition.h>
#endif

@@ -88,7 +89,7 @@ iterate_device (const char *name, void *data)
grub_device_close (dev);
@@ -124,7 +125,7 @@ iterate_device (const char *name, void *data)
}
}

-#ifdef DO_SEARCH_FS_UUID
+#if defined(DO_SEARCH_FS_UUID) || defined(DO_SEARCH_DISK_UUID)
#define compare_fn grub_strcasecmp
#else
#define compare_fn grub_strcmp
@@ -128,6 +129,25 @@ iterate_device (const char *name, void *data)
@@ -164,6 +165,25 @@ iterate_device (const char *name, void *data)
grub_free (quid);
}

Expand All @@ -98,7 +98,24 @@ index bb0c7cb..ec03c75 100644
grub_device_close (dev);
}
}
@@ -379,6 +399,8 @@ GRUB_MOD_INIT(search_part_uuid)
@@ -277,14 +297,14 @@ part_hook (grub_disk_t disk, const grub_partition_t partition, void *data)
if (!devname)
return 1;
ret = iterate_device (devname, ctx);
- grub_free (devname);
+ grub_free (devname);

return ret;
}

/* Helper for FUNC_NAME. */
static void
-try (struct search_ctx *ctx)
+try (struct search_ctx *ctx)
{
unsigned i;
struct cache_entry **prev;
@@ -415,6 +435,8 @@ GRUB_MOD_INIT(search_part_uuid)
GRUB_MOD_INIT(search_part_label)
#elif defined (DO_SEARCH_FS_UUID)
GRUB_MOD_INIT(search_fs_uuid)
Expand All @@ -107,7 +124,7 @@ index bb0c7cb..ec03c75 100644
#else
GRUB_MOD_INIT(search_label)
#endif
@@ -397,6 +419,8 @@ GRUB_MOD_FINI(search_part_uuid)
@@ -433,6 +455,8 @@ GRUB_MOD_FINI(search_part_uuid)
GRUB_MOD_FINI(search_part_label)
#elif defined (DO_SEARCH_FS_UUID)
GRUB_MOD_FINI(search_fs_uuid)
Expand All @@ -128,7 +145,7 @@ index 0000000..fba96f6
+#define HELP_MESSAGE N_("Search devices by disk UUID. If VARIABLE is specified, the first device found is set to a variable.")
+#include "search.c"
diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c
index 82f8e63..c8152b1 100644
index 5773583..fd77b1c 100644
--- a/grub-core/commands/search_wrap.c
+++ b/grub-core/commands/search_wrap.c
@@ -40,6 +40,8 @@ static const struct grub_arg_option options[] =
Expand All @@ -140,15 +157,15 @@ index 82f8e63..c8152b1 100644
{"set", 's', GRUB_ARG_OPTION_OPTIONAL,
N_("Set a variable to the first device found."), N_("VARNAME"),
ARG_TYPE_STRING},
@@ -78,6 +80,7 @@ enum options
@@ -79,6 +81,7 @@ enum options
SEARCH_FS_UUID,
SEARCH_PART_LABEL,
SEARCH_PART_UUID,
+ SEARCH_DISK_UUID,
SEARCH_SET,
SEARCH_NO_FLOPPY,
SEARCH_EFIDISK_ONLY,
@@ -203,6 +206,8 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
@@ -208,6 +211,8 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
grub_search_part_label (id, var, flags, hints, nhints);
else if (state[SEARCH_PART_UUID].set)
grub_search_part_uuid (id, var, flags, hints, nhints);
Expand Down Expand Up @@ -203,10 +220,10 @@ index 1eb2f7b..16fdd7f 100644
+
#endif /* ! GRUB_GPT_PARTITION_HEADER */
diff --git a/include/grub/search.h b/include/grub/search.h
index 66722a6..a5f56b2 100644
index 1086944..8727409 100644
--- a/include/grub/search.h
+++ b/include/grub/search.h
@@ -40,5 +40,8 @@ void grub_search_part_uuid (const char *key, const char *var,
@@ -41,5 +41,8 @@ void grub_search_part_uuid (const char *key, const char *var,
void grub_search_part_label (const char *key, const char *var,
enum search_flags flags,
char **hints, unsigned nhints);
Expand Down Expand Up @@ -273,5 +290,5 @@ index 7a1af46..60f6017 100644
grub_fini_all ();
}
--
2.36.1
2.47.0

163 changes: 0 additions & 163 deletions packages/grub/0048-add-flag-to-only-search-root-dev.patch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
From 90349c56c909fcbc250cc780f2db39c66f5254f8 Mon Sep 17 00:00:00 2001
From: B Horn <b@horn.uk>
Date: Sun, 12 May 2024 02:47:54 +0100
Subject: [PATCH] fs/tar: Initialize name in grub_cpio_find_file()

It was possible to iterate through grub_cpio_find_file() without
allocating name and not setting mode to GRUB_ARCHELP_ATTR_END, which
would cause the uninitialized value for name to be used as an argument
for canonicalize() in grub_archelp_dir().

Reported-by: B Horn <b@horn.uk>
Signed-off-by: B Horn <b@horn.uk>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Jingwei Wang <jweiw@amazon.com>
---
grub-core/fs/tar.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/grub-core/fs/tar.c b/grub-core/fs/tar.c
index 63fda1c..898544c 100644
--- a/grub-core/fs/tar.c
+++ b/grub-core/fs/tar.c
@@ -80,10 +80,12 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name,
grub_size_t sz;

data->hofs = data->next_hofs;
+ *name = NULL;

for (reread = 0; reread < 3; reread++)
{
- if (grub_disk_read (data->disk, 0, data->hofs, sizeof (hd), &hd))
+ if (grub_cpio_find_file (struct grub_archelp_data *data, char
+**name, sizeof (hd), &hd))
return grub_errno;

if (!hd.name[0] && !hd.prefix[0])
@@ -224,6 +226,10 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name,
}
return GRUB_ERR_NONE;
}
+
+ if (*name == NULL)
+ return grub_error (GRUB_ERR_BAD_FS, "invalid tar archive");
+
return GRUB_ERR_NONE;
}

--
2.47.0

Loading