Sync from SUSE:SLFO:Main grub2 revision fdc751393c4e37b3cfb79a25b0d597a4
This commit is contained in:
34
0001-autofs-Ignore-zfs-not-found.patch
Normal file
34
0001-autofs-Ignore-zfs-not-found.patch
Normal file
@@ -0,0 +1,34 @@
|
||||
From f85cc4bac3cfb787c5a47a8864a4565519dd01e9 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Chang <mchang@suse.com>
|
||||
Date: Thu, 6 Mar 2025 16:29:48 +0800
|
||||
Subject: [PATCH] autofs: Ignore zfs not found
|
||||
|
||||
We put zfs modules in a separate package so they can be missing during
|
||||
the file-system probe that kicks in automatic file-system module
|
||||
loading. We ignore the error message for the missing zfs module, as that
|
||||
is not an abnormal condition like others.
|
||||
|
||||
Signed-off-by: Michael Chang <mchang@suse.com>
|
||||
---
|
||||
grub-core/normal/autofs.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/grub-core/normal/autofs.c b/grub-core/normal/autofs.c
|
||||
index 7a7cf2b0f7..591b5fc8c3 100644
|
||||
--- a/grub-core/normal/autofs.c
|
||||
+++ b/grub-core/normal/autofs.c
|
||||
@@ -42,6 +42,11 @@ autoload_fs_module (void)
|
||||
break;
|
||||
}
|
||||
|
||||
+ /* We put zfs in a separate package, so ignoring if it's not found */
|
||||
+ if (grub_strcmp (p->name, "zfs") == 0 &&
|
||||
+ grub_errno == GRUB_ERR_FILE_NOT_FOUND)
|
||||
+ grub_errno = GRUB_ERR_NONE;
|
||||
+
|
||||
if (grub_errno)
|
||||
grub_print_error ();
|
||||
|
||||
--
|
||||
2.48.1
|
||||
|
44
0001-bls-Accept-.conf-suffix-in-setting-default-entry.patch
Normal file
44
0001-bls-Accept-.conf-suffix-in-setting-default-entry.patch
Normal file
@@ -0,0 +1,44 @@
|
||||
From e873743f4ed7841542dd7dc11a183cb136670382 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Chang <mchang@suse.com>
|
||||
Date: Wed, 19 Feb 2025 14:52:52 +0800
|
||||
Subject: [PATCH] bls: Accept .conf suffix in setting default entry
|
||||
|
||||
Signed-off-by: Michael Chang <mchang@suse.com>
|
||||
---
|
||||
grub-core/normal/menu.c | 20 ++++++++++++++++++++
|
||||
1 file changed, 20 insertions(+)
|
||||
|
||||
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
|
||||
index b11b28e0d9..dfdf0c7268 100644
|
||||
--- a/grub-core/normal/menu.c
|
||||
+++ b/grub-core/normal/menu.c
|
||||
@@ -557,6 +557,26 @@ get_entry_number (grub_menu_t menu, const char *name)
|
||||
entry = i;
|
||||
break;
|
||||
}
|
||||
+
|
||||
+ if (e->bls)
|
||||
+ {
|
||||
+ char *v, *ext;
|
||||
+
|
||||
+ if ((v = grub_strdup (val)) &&
|
||||
+ (ext = grub_strrchr (v, '.')) &&
|
||||
+ grub_strcmp (ext, ".conf") == 0)
|
||||
+ {
|
||||
+ *ext = '\0';
|
||||
+ if (menuentry_eq (e->id, v))
|
||||
+ {
|
||||
+ entry = i;
|
||||
+ grub_free (v);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ grub_free (v);
|
||||
+ }
|
||||
+
|
||||
e = e->next;
|
||||
|
||||
/* Skip hidden entries */
|
||||
--
|
||||
2.48.1
|
||||
|
@@ -0,0 +1,65 @@
|
||||
From 7a8d9a29358fbe9eb5dcc70e63c417c4f3cd5068 Mon Sep 17 00:00:00 2001
|
||||
From: "Darrick J. Wong" <djwong@kernel.org>
|
||||
Date: Mon, 3 Feb 2025 15:41:22 -0800
|
||||
Subject: [PATCH 1/3] fs/xfs: Add new superblock features added in Linux
|
||||
6.12/6.13
|
||||
|
||||
The Linux port of XFS added a few new features in 2024. The existing
|
||||
GRUB driver doesn't attempt to read or write any of the new metadata,
|
||||
so, all three can be added to the incompat allowlist.
|
||||
|
||||
On the occasion align XFS_SB_FEAT_INCOMPAT_NREXT64 value.
|
||||
|
||||
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
---
|
||||
grub-core/fs/xfs.c | 19 +++++++++++++++++--
|
||||
1 file changed, 17 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c
|
||||
index c17e54e447..e3a69fe498 100644
|
||||
--- a/grub-core/fs/xfs.c
|
||||
+++ b/grub-core/fs/xfs.c
|
||||
@@ -88,7 +88,10 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
||||
#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */
|
||||
#define XFS_SB_FEAT_INCOMPAT_BIGTIME (1 << 3) /* large timestamps */
|
||||
#define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4) /* needs xfs_repair */
|
||||
-#define XFS_SB_FEAT_INCOMPAT_NREXT64 (1 << 5) /* large extent counters */
|
||||
+#define XFS_SB_FEAT_INCOMPAT_NREXT64 (1 << 5) /* large extent counters */
|
||||
+#define XFS_SB_FEAT_INCOMPAT_EXCHRANGE (1 << 6) /* exchangerange supported */
|
||||
+#define XFS_SB_FEAT_INCOMPAT_PARENT (1 << 7) /* parent pointers */
|
||||
+#define XFS_SB_FEAT_INCOMPAT_METADIR (1 << 8) /* metadata dir tree */
|
||||
|
||||
/*
|
||||
* Directory entries with ftype are explicitly handled by GRUB code.
|
||||
@@ -98,6 +101,15 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
||||
*
|
||||
* We do not currently verify metadata UUID, so it is safe to read filesystems
|
||||
* with the XFS_SB_FEAT_INCOMPAT_META_UUID feature.
|
||||
+ *
|
||||
+ * We do not currently replay the log, so it is safe to read filesystems
|
||||
+ * with the XFS_SB_FEAT_INCOMPAT_EXCHRANGE feature.
|
||||
+ *
|
||||
+ * We do not currently read directory parent pointers, so it is safe to read
|
||||
+ * filesystems with the XFS_SB_FEAT_INCOMPAT_PARENT feature.
|
||||
+ *
|
||||
+ * We do not currently look at realtime or quota metadata, so it is safe to
|
||||
+ * read filesystems with the XFS_SB_FEAT_INCOMPAT_METADIR feature.
|
||||
*/
|
||||
#define XFS_SB_FEAT_INCOMPAT_SUPPORTED \
|
||||
(XFS_SB_FEAT_INCOMPAT_FTYPE | \
|
||||
@@ -105,7 +117,10 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
||||
XFS_SB_FEAT_INCOMPAT_META_UUID | \
|
||||
XFS_SB_FEAT_INCOMPAT_BIGTIME | \
|
||||
XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR | \
|
||||
- XFS_SB_FEAT_INCOMPAT_NREXT64)
|
||||
+ XFS_SB_FEAT_INCOMPAT_NREXT64 | \
|
||||
+ XFS_SB_FEAT_INCOMPAT_EXCHRANGE | \
|
||||
+ XFS_SB_FEAT_INCOMPAT_PARENT | \
|
||||
+ XFS_SB_FEAT_INCOMPAT_METADIR)
|
||||
|
||||
struct grub_xfs_sblock
|
||||
{
|
||||
--
|
||||
2.48.1
|
||||
|
@@ -0,0 +1,56 @@
|
||||
From 5025c64afc876d91d3947ce07bb59ffe9af7209d Mon Sep 17 00:00:00 2001
|
||||
From: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Date: Tue, 25 Feb 2025 19:14:24 +0530
|
||||
Subject: [PATCH 1/9] ieee1275: adding failure check condition on
|
||||
/ibm,secure-boot
|
||||
|
||||
failure check condition is missing while finding device "/" and
|
||||
get property "ibm,secure-boot". So, adding the failure check condition.
|
||||
|
||||
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
---
|
||||
grub-core/kern/ieee1275/init.c | 20 ++++++++++++++------
|
||||
1 file changed, 14 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
|
||||
index f86543da0d..0e1cbf24c3 100644
|
||||
--- a/grub-core/kern/ieee1275/init.c
|
||||
+++ b/grub-core/kern/ieee1275/init.c
|
||||
@@ -987,12 +987,20 @@ grub_get_ieee1275_secure_boot (void)
|
||||
int rc;
|
||||
grub_uint32_t is_sb;
|
||||
|
||||
- grub_ieee1275_finddevice ("/", &root);
|
||||
-
|
||||
- rc = grub_ieee1275_get_integer_property (root, "ibm,secure-boot", &is_sb,
|
||||
- sizeof (is_sb), 0);
|
||||
+ if (grub_ieee1275_finddevice ("/", &root))
|
||||
+ {
|
||||
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, "couldn't find / node");
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
- /* ibm,secure-boot:
|
||||
+ rc = grub_ieee1275_get_integer_property (root, "ibm,secure-boot", &is_sb, sizeof (is_sb), 0);
|
||||
+ if (rc < 0)
|
||||
+ {
|
||||
+ grub_error (GRUB_ERR_UNKNOWN_DEVICE, "couldn't examine /ibm,secure-boot property");
|
||||
+ return;
|
||||
+ }
|
||||
+ /*
|
||||
+ * ibm,secure-boot:
|
||||
* 0 - disabled
|
||||
* 1 - audit
|
||||
* 2 - enforce
|
||||
@@ -1000,7 +1008,7 @@ grub_get_ieee1275_secure_boot (void)
|
||||
*
|
||||
* We only support enforce.
|
||||
*/
|
||||
- if (rc >= 0 && is_sb >= 2)
|
||||
+ if (is_sb >= 2)
|
||||
grub_lockdown ();
|
||||
}
|
||||
|
||||
--
|
||||
2.48.1
|
||||
|
@@ -15,11 +15,9 @@ Signed-off-by: Avnish Chouhan <avnish@linux.ibm.com>
|
||||
include/grub/util/ofpath.h | 4 ++
|
||||
4 files changed, 74 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c
|
||||
index 51d331f06..55ed7ddf2 100644
|
||||
--- a/grub-core/osdep/linux/ofpath.c
|
||||
+++ b/grub-core/osdep/linux/ofpath.c
|
||||
@@ -209,7 +209,7 @@ find_obppath (const char *sysfs_path_orig)
|
||||
@@ -209,7 +209,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +26,7 @@ index 51d331f06..55ed7ddf2 100644
|
||||
xrealpath (const char *in)
|
||||
{
|
||||
char *out;
|
||||
@@ -224,7 +224,7 @@ xrealpath (const char *in)
|
||||
@@ -224,7 +224,7 @@
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -37,17 +35,15 @@ index 51d331f06..55ed7ddf2 100644
|
||||
block_device_get_sysfs_path_and_link(const char *devicenode)
|
||||
{
|
||||
char *rpath;
|
||||
@@ -535,7 +535,7 @@ of_path_get_nvme_nsid(const char* devname)
|
||||
|
||||
@@ -613,7 +613,7 @@
|
||||
return nsid;
|
||||
}
|
||||
|
||||
-static char *
|
||||
+char *
|
||||
nvme_get_syspath(const char *nvmedev)
|
||||
nvme_get_syspath (const char *nvmedev)
|
||||
{
|
||||
char *sysfs_path, *controller_node;
|
||||
diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c
|
||||
index 1e2961e00..bafcc84d7 100644
|
||||
--- a/grub-core/osdep/unix/platform.c
|
||||
+++ b/grub-core/osdep/unix/platform.c
|
||||
@@ -28,6 +28,8 @@
|
||||
@@ -59,7 +55,7 @@ index 1e2961e00..bafcc84d7 100644
|
||||
|
||||
static char *
|
||||
get_ofpathname (const char *dev)
|
||||
@@ -203,6 +205,56 @@ grub_install_register_efi (const grub_disk_t *efidir_grub_disk,
|
||||
@@ -203,6 +205,56 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -116,7 +112,7 @@ index 1e2961e00..bafcc84d7 100644
|
||||
void
|
||||
grub_install_register_ieee1275 (int is_prep, const char *install_device,
|
||||
int partno, const char *relpath)
|
||||
@@ -242,8 +294,19 @@ grub_install_register_ieee1275 (int is_prep, const char *install_device,
|
||||
@@ -242,8 +294,19 @@
|
||||
}
|
||||
*ptr = '\0';
|
||||
}
|
||||
@@ -137,11 +133,9 @@ index 1e2961e00..bafcc84d7 100644
|
||||
|
||||
if (grub_util_exec ((const char * []){ "nvsetenv", "boot-device",
|
||||
boot_device, NULL }))
|
||||
diff --git a/include/grub/util/install.h b/include/grub/util/install.h
|
||||
index 563cf68e9..2fd102649 100644
|
||||
--- a/include/grub/util/install.h
|
||||
+++ b/include/grub/util/install.h
|
||||
@@ -241,6 +241,9 @@ grub_install_register_efi (const grub_disk_t *efidir_grub_disk,
|
||||
@@ -241,6 +241,9 @@
|
||||
const char *efi_distributor,
|
||||
const char *force_disk);
|
||||
|
||||
@@ -151,20 +145,15 @@ index 563cf68e9..2fd102649 100644
|
||||
void
|
||||
grub_install_register_ieee1275 (int is_prep, const char *install_device,
|
||||
int partno, const char *relpath);
|
||||
diff --git a/include/grub/util/ofpath.h b/include/grub/util/ofpath.h
|
||||
index a0ec30620..cc3c4bfbd 100644
|
||||
--- a/include/grub/util/ofpath.h
|
||||
+++ b/include/grub/util/ofpath.h
|
||||
@@ -31,5 +31,9 @@ void add_filename_to_pile(char *filename, struct ofpath_files_list_root* root);
|
||||
void find_file(char* filename, char* directory, struct ofpath_files_list_root* root, int max_depth, int depth);
|
||||
|
||||
char* of_find_fc_host(char* host_wwpn);
|
||||
@@ -30,5 +30,9 @@
|
||||
void find_file (char* filename, char* directory, struct ofpath_files_list_root* root, int max_depth, int depth);
|
||||
char* of_find_fc_host (char* host_wwpn);
|
||||
void free_ofpath_files_list (struct ofpath_files_list_root* root);
|
||||
+char* nvme_get_syspath (const char *nvmedev);
|
||||
+char* block_device_get_sysfs_path_and_link (const char *devicenode);
|
||||
+char* xrealpath (const char *in);
|
||||
+unsigned int of_path_get_nvme_nsid (const char* devname);
|
||||
|
||||
#endif /* ! GRUB_OFPATH_MACHINE_UTIL_HEADER */
|
||||
--
|
||||
2.47.0
|
||||
|
||||
|
171
0001-ofpath-Add-error-check-in-NVMEoF-device-translation.patch
Normal file
171
0001-ofpath-Add-error-check-in-NVMEoF-device-translation.patch
Normal file
@@ -0,0 +1,171 @@
|
||||
From 4b26a490def61786bfd5f66f0f68a33447dccb90 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Chang <mchang@suse.com>
|
||||
Date: Mon, 10 Feb 2025 18:20:28 +0800
|
||||
Subject: [PATCH] ofpath: Add error check in NVMEoF device translation
|
||||
|
||||
Signed-Off-by: Michael Chang <mchang@suse.com>
|
||||
---
|
||||
grub-core/osdep/linux/ofpath.c | 95 ++++++++++++++++++++++++----------
|
||||
1 file changed, 69 insertions(+), 26 deletions(-)
|
||||
|
||||
diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c
|
||||
index 66a256b18b..4b920ddc20 100644
|
||||
--- a/grub-core/osdep/linux/ofpath.c
|
||||
+++ b/grub-core/osdep/linux/ofpath.c
|
||||
@@ -536,52 +536,90 @@ of_path_get_nvmeof_adapter_info (char* sysfs_path,
|
||||
}
|
||||
|
||||
snprintf (buf, 512, "%s/subsysnqn", sysfs_path);
|
||||
- fp = fopen (buf, "r");
|
||||
- fscanf (fp, "%s", nvmeof_info->nqn);
|
||||
+ if (! (fp = fopen (buf, "r")) ||
|
||||
+ fscanf (fp, "%s", nvmeof_info->nqn) != 1)
|
||||
+ {
|
||||
+ if (fp)
|
||||
+ fclose (fp);
|
||||
+ free (nvmeof_info->host_wwpn);
|
||||
+ free (nvmeof_info->target_wwpn);
|
||||
+ free (nvmeof_info->nqn);
|
||||
+ free (buf);
|
||||
+ return -1;
|
||||
+ }
|
||||
fclose (fp);
|
||||
|
||||
snprintf (buf, 512, "%s/cntlid", sysfs_path);
|
||||
- fp = fopen (buf, "r");
|
||||
- fscanf (fp, "%u", &(nvmeof_info->cntlid));
|
||||
+ if (! (fp = fopen (buf, "r")) ||
|
||||
+ fscanf (fp, "%u", &(nvmeof_info->cntlid)) != 1)
|
||||
+ {
|
||||
+ if (fp)
|
||||
+ fclose (fp);
|
||||
+ free (nvmeof_info->host_wwpn);
|
||||
+ free (nvmeof_info->target_wwpn);
|
||||
+ free (nvmeof_info->nqn);
|
||||
+ free (buf);
|
||||
+ return -1;
|
||||
+ }
|
||||
fclose (fp);
|
||||
|
||||
snprintf (buf, 512, "%s/address", sysfs_path);
|
||||
- fp = fopen (buf, "r");
|
||||
- buf2 = malloc (sizeof (char) * 512);
|
||||
-
|
||||
- if (!buf2)
|
||||
+ buf2 = NULL;
|
||||
+ fp = NULL;
|
||||
+ if (! (buf2 = malloc (sizeof (char) * 512)) ||
|
||||
+ ! (fp = fopen (buf, "r")) ||
|
||||
+ fscanf (fp, "%s", buf2) != 1)
|
||||
{
|
||||
+ if (fp)
|
||||
+ fclose (fp);
|
||||
free (nvmeof_info->host_wwpn);
|
||||
free (nvmeof_info->target_wwpn);
|
||||
free (nvmeof_info->nqn);
|
||||
free (buf);
|
||||
+ free (buf2);
|
||||
return -1;
|
||||
}
|
||||
-
|
||||
- fscanf (fp, "%s", buf2);
|
||||
fclose (fp);
|
||||
|
||||
- buf3 = strrchr (buf2, '-') + 1;
|
||||
- grub_memcpy (nvmeof_info->host_wwpn, buf3, 256);
|
||||
- buf3=strchr (buf2, '-') + 1;
|
||||
- buf3=strchr (buf3, '-') + 1;
|
||||
- buf3=strchr (buf3, 'x') + 1;
|
||||
- grub_memcpy (nvmeof_info->target_wwpn, buf3, 256);
|
||||
+ if (! (buf3 = strrchr (buf2, '-')))
|
||||
+ {
|
||||
+ free (nvmeof_info->host_wwpn);
|
||||
+ free (nvmeof_info->target_wwpn);
|
||||
+ free (nvmeof_info->nqn);
|
||||
+ free (buf);
|
||||
+ free (buf2);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ grub_memcpy (nvmeof_info->host_wwpn, buf3 + 1, 256);
|
||||
+ if (! (buf3 = strchr (buf2, '-')) ||
|
||||
+ ! (buf3 = strchr (buf3 + 1, '-')) ||
|
||||
+ ! (buf3 = strchr (buf3 + 1, 'x')))
|
||||
+ {
|
||||
+ free (nvmeof_info->host_wwpn);
|
||||
+ free (nvmeof_info->target_wwpn);
|
||||
+ free (nvmeof_info->nqn);
|
||||
+ free (buf);
|
||||
+ free (buf2);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ grub_memcpy (nvmeof_info->target_wwpn, buf3 + 1, 256);
|
||||
buf3 = strchr (nvmeof_info->target_wwpn, ',');
|
||||
- *buf3 = '\0';
|
||||
+ if (buf3)
|
||||
+ *buf3 = '\0';
|
||||
free (buf);
|
||||
free (buf2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
-#define MAX_NVME_NSID_DIGITS 6
|
||||
+#define OFPATH_MAX_UINT_HEX_DIGITS 8
|
||||
+#define OFPATH_MAX_INT_DIGITS 10
|
||||
|
||||
static char *
|
||||
of_path_get_nvme_controller_name_node (const char* devname)
|
||||
{
|
||||
char *controller_node, *end;
|
||||
|
||||
- controller_node = strdup (devname);
|
||||
+ controller_node = xstrdup (devname);
|
||||
end = grub_strchr (controller_node + 1, 'n');
|
||||
if (end != NULL)
|
||||
{
|
||||
@@ -616,15 +654,20 @@ of_path_get_nvme_nsid (const char* devname)
|
||||
char *
|
||||
nvme_get_syspath (const char *nvmedev)
|
||||
{
|
||||
- char *sysfs_path, *controller_node;
|
||||
+ char *sysfs_path;
|
||||
|
||||
sysfs_path = block_device_get_sysfs_path_and_link (nvmedev);
|
||||
if (strstr (sysfs_path, "nvme-subsystem"))
|
||||
{
|
||||
- controller_node = of_path_get_nvme_controller_name_node (nvmedev);
|
||||
- strcat (sysfs_path, "/");
|
||||
- strcat (sysfs_path, controller_node);
|
||||
- sysfs_path = xrealpath (sysfs_path);
|
||||
+ char *controller_node = of_path_get_nvme_controller_name_node (nvmedev);
|
||||
+ char *buf = xmalloc (strlen (sysfs_path) + strlen ("/") + strlen (controller_node) + 1);
|
||||
+ strcpy (buf, sysfs_path);
|
||||
+ strcat (buf, "/");
|
||||
+ strcat (buf, controller_node);
|
||||
+ free (sysfs_path);
|
||||
+ free (controller_node);
|
||||
+ sysfs_path = xrealpath (buf);
|
||||
+ free (buf);
|
||||
}
|
||||
|
||||
return sysfs_path;
|
||||
@@ -693,7 +736,7 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)),
|
||||
unsigned int nsid = of_path_get_nvme_nsid (nvmedev);
|
||||
if (nsid)
|
||||
{
|
||||
- snprintf (disk+chars_written, sizeof("/namespace@") + MAX_NVME_NSID_DIGITS,
|
||||
+ snprintf (disk+chars_written, sizeof("/namespace@") + OFPATH_MAX_UINT_HEX_DIGITS + OFPATH_MAX_INT_DIGITS,
|
||||
"/namespace@%x:%d", nsid, part);
|
||||
}
|
||||
free (nvmeof_info);
|
||||
@@ -734,7 +777,7 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)),
|
||||
unsigned int nsid = of_path_get_nvme_nsid (device);
|
||||
if (nsid)
|
||||
{
|
||||
- snprintf (disk+chars_written,sizeof("/namespace@") + sizeof(char) * MAX_NVME_NSID_DIGITS,
|
||||
+ snprintf (disk+chars_written,sizeof("/namespace@") + sizeof(char) * OFPATH_MAX_UINT_HEX_DIGITS,
|
||||
"/namespace@%x", nsid);
|
||||
}
|
||||
free (nvmeof_info);
|
||||
--
|
||||
2.48.1
|
||||
|
71
0001-s390x-emu-Pass-through-PAES-cipher-as-AES.patch
Normal file
71
0001-s390x-emu-Pass-through-PAES-cipher-as-AES.patch
Normal file
@@ -0,0 +1,71 @@
|
||||
From c6f690a50ab75edf06cd2a8d2100e9312a86decc Mon Sep 17 00:00:00 2001
|
||||
From: Michael Chang <mchang@suse.com>
|
||||
Date: Wed, 26 Feb 2025 16:35:14 +0800
|
||||
Subject: [PATCH] s390x-emu: Pass through PAES cipher as AES
|
||||
|
||||
Protected AES (PAES) enhances AES encryption with hardware key
|
||||
protection exclusively on IBM Z's s390x architecture.
|
||||
|
||||
This patch addresses issues in GRUB utilities that cannot handle
|
||||
PAES-encrypted volumes due to a lack of native cipher support. The
|
||||
solution works because, on s390x, grub-emu is used to boot the target
|
||||
via kexec. As a Linux userspace program, grub-emu leverages kernel
|
||||
support and bypasses the limitations of GRUB's built-in functionality.
|
||||
|
||||
We can pass through PAES as AES on Linux platforms since the underlying
|
||||
cipher appears as plain AES from a userland application's perspective.
|
||||
Additionally, GRUB's linux applications perform "cheat mount" that
|
||||
doesn't attempt to open the LUKS container. Instead, they initialize the
|
||||
cryptodisk structure using attributes from the LUKS header to obtain
|
||||
necessary information like crypto-uuid.
|
||||
|
||||
Furthermore, root probing for Btrfs can be skipped to avoid issues with
|
||||
unsupported devices, as grub-emu doesn't rely on GRUB's own
|
||||
configurations for booting Btrfs. Instead, it operates entirely from a
|
||||
Dracut initramfs.
|
||||
|
||||
Signed-off-by: Michael Chang <mchang@suse.com>
|
||||
---
|
||||
grub-core/osdep/devmapper/getroot.c | 5 +++++
|
||||
util/grub-install.c | 6 ++++--
|
||||
2 files changed, 9 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c
|
||||
index 3b37336bc9..344df9a589 100644
|
||||
--- a/grub-core/osdep/devmapper/getroot.c
|
||||
+++ b/grub-core/osdep/devmapper/getroot.c
|
||||
@@ -266,6 +266,11 @@ grub_util_pull_devmapper (const char *os_dev)
|
||||
remaining -= seek_head - c + 1;
|
||||
c = seek_head + 1;
|
||||
|
||||
+#if defined (__s390x__)
|
||||
+ if (grub_strcasecmp (cipher, "paes") == 0)
|
||||
+ grub_strcpy(cipher, "aes");
|
||||
+#endif
|
||||
+
|
||||
/* Now, the cipher mode. */
|
||||
seek_head = grub_memchr (c, ' ', remaining);
|
||||
if (seek_head == NULL)
|
||||
diff --git a/util/grub-install.c b/util/grub-install.c
|
||||
index a187a9c63c..0ab0cf8fe7 100644
|
||||
--- a/util/grub-install.c
|
||||
+++ b/util/grub-install.c
|
||||
@@ -1108,11 +1108,13 @@ main (int argc, char *argv[])
|
||||
char *t = grub_util_path_concat (2, "/", rootdir);
|
||||
|
||||
#ifdef __linux__
|
||||
- if (!grub_can_guess_from_mountinfo (t))
|
||||
+ if (!grub_can_guess_from_mountinfo (t) || platform == GRUB_INSTALL_PLATFORM_S390X_EMU)
|
||||
{
|
||||
free(t);
|
||||
/* We can safely ignore the root probe here; whichever cannot be
|
||||
- * reliably detected is irrelevant and of no interest */
|
||||
+ * reliably detected is irrelevant and of no interest.
|
||||
+ * Also the s390x-emu, this btrfs root detection can be omitted given
|
||||
+ * it is not relevant to the capability of linux host system */
|
||||
goto skip_root_probe;
|
||||
}
|
||||
#endif
|
||||
--
|
||||
2.48.1
|
||||
|
@@ -1,60 +0,0 @@
|
||||
From 72a582b1c3954f9b917a4d687c95fc94faf551c6 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Chang <mchang@suse.com>
|
||||
Date: Wed, 24 Jan 2024 18:03:51 +0800
|
||||
Subject: [PATCH] squash! ieee1275/ofpath: enable NVMeoF logical device
|
||||
translation
|
||||
|
||||
Fixes build error on gcc-14:
|
||||
|
||||
[ 73s] In file included from ../grub-core/osdep/ofpath.c:2:
|
||||
[ 73s] ../grub-core/osdep/linux/ofpath.c: In function 'of_find_fc_host':
|
||||
[ 73s] ../grub-core/osdep/linux/ofpath.c:427:22: error: allocation of insufficient size '8' for type 'struct ofpath_files_list_root' with size '16' [-Werror=alloc-size]
|
||||
[ 73s] 427 | portnames_file_list=malloc(sizeof(portnames_file_list));
|
||||
[ 73s] | ^
|
||||
[ 73s] ../grub-core/osdep/linux/ofpath.c: In function 'of_path_of_nvme':
|
||||
[ 73s] ../grub-core/osdep/linux/ofpath.c:589:21: error: allocation of insufficient size '8' for type 'struct ofpath_nvmeof_info' with size '32' [-Werror=alloc-size]
|
||||
[ 73s] 589 | nvmeof_info = malloc(sizeof(nvmeof_info));
|
||||
[ 73s] | ^
|
||||
[ 73s] ../grub-core/osdep/linux/ofpath.c:618:21: error: allocation of insufficient size '8' for type 'struct ofpath_nvmeof_info' with size '32' [-Werror=alloc-size]
|
||||
[ 73s] 618 | nvmeof_info = malloc(sizeof(nvmeof_info));
|
||||
[ 73s] | ^
|
||||
|
||||
Signed-off-by: Michael Chang <mchang@suse.com>
|
||||
---
|
||||
grub-core/osdep/linux/ofpath.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c
|
||||
index 7129099db..55ed7ddf2 100644
|
||||
--- a/grub-core/osdep/linux/ofpath.c
|
||||
+++ b/grub-core/osdep/linux/ofpath.c
|
||||
@@ -424,7 +424,7 @@ of_find_fc_host(char* host_wwpn){
|
||||
|
||||
struct ofpath_files_list_root* portnames_file_list;
|
||||
|
||||
- portnames_file_list=malloc(sizeof(portnames_file_list));
|
||||
+ portnames_file_list=malloc(sizeof(*portnames_file_list));
|
||||
portnames_file_list->items=0;
|
||||
portnames_file_list->first=NULL;
|
||||
|
||||
@@ -586,7 +586,7 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)),
|
||||
/* If is a NVMeoF */
|
||||
if(strstr(sysfs_path,"nvme-fabrics")){
|
||||
struct ofpath_nvmeof_info* nvmeof_info;
|
||||
- nvmeof_info = malloc(sizeof(nvmeof_info));
|
||||
+ nvmeof_info = malloc(sizeof(*nvmeof_info));
|
||||
|
||||
of_path_get_nvmeof_adapter_info(sysfs_path, nvmeof_info);
|
||||
|
||||
@@ -615,7 +615,7 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)),
|
||||
sysfs_path = nvme_get_syspath (device);
|
||||
if(strstr(sysfs_path,"nvme-fabrics")){
|
||||
struct ofpath_nvmeof_info* nvmeof_info;
|
||||
- nvmeof_info = malloc(sizeof(nvmeof_info));
|
||||
+ nvmeof_info = malloc(sizeof(*nvmeof_info));
|
||||
|
||||
of_path_get_nvmeof_adapter_info(sysfs_path, nvmeof_info);
|
||||
|
||||
--
|
||||
2.43.0
|
||||
|
@@ -1,4 +1,4 @@
|
||||
From 5b4ecd408417249dec8bfc71a3c0b7ef1070d3fa Mon Sep 17 00:00:00 2001
|
||||
From 53c3dc557890466757090ee390a2c5d241e50483 Mon Sep 17 00:00:00 2001
|
||||
From: Gary Lin <glin@suse.com>
|
||||
Date: Thu, 25 Apr 2024 16:21:45 +0800
|
||||
Subject: [PATCH] tpm2: Add extra RSA SRK types
|
||||
@@ -6,29 +6,30 @@ Subject: [PATCH] tpm2: Add extra RSA SRK types
|
||||
Since fde-tools may set RSA3072 and RSA4096 as the SRK type, grub2 has
|
||||
to support those parameters.
|
||||
|
||||
Also prevent RSA SRK type from being overwritten when 'rsaparent' is set
|
||||
in the key file.
|
||||
|
||||
Signed-off-by: Gary Lin <glin@suse.com>
|
||||
---
|
||||
grub-core/commands/tpm2_key_protector/args.c | 12 ++++++++++++
|
||||
grub-core/commands/tpm2_key_protector/module.c | 16 ++++++++++++++--
|
||||
grub-core/commands/tpm2_key_protector/args.c | 10 ++++++++++
|
||||
grub-core/commands/tpm2_key_protector/module.c | 18 +++++++++++++++---
|
||||
util/grub-protect.c | 4 ++--
|
||||
3 files changed, 28 insertions(+), 4 deletions(-)
|
||||
3 files changed, 27 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/grub-core/commands/tpm2_key_protector/args.c b/grub-core/commands/tpm2_key_protector/args.c
|
||||
index 48c39de01..b291793a7 100644
|
||||
index 48c39de01..5781a31f1 100644
|
||||
--- a/grub-core/commands/tpm2_key_protector/args.c
|
||||
+++ b/grub-core/commands/tpm2_key_protector/args.c
|
||||
@@ -85,6 +85,18 @@ grub_tpm2_protector_parse_asymmetric (const char *value,
|
||||
@@ -85,6 +85,16 @@ grub_tpm2_protector_parse_asymmetric (const char *value,
|
||||
srk_type->type = TPM_ALG_RSA;
|
||||
srk_type->detail.rsa_bits = 2048;
|
||||
}
|
||||
+ else if (grub_strcasecmp (value, "RSA") == 0 ||
|
||||
+ grub_strcasecmp (value, "RSA3072") == 0)
|
||||
+ else if (grub_strcasecmp (value, "RSA3072") == 0)
|
||||
+ {
|
||||
+ srk_type->type = TPM_ALG_RSA;
|
||||
+ srk_type->detail.rsa_bits = 3072;
|
||||
+ }
|
||||
+ else if (grub_strcasecmp (value, "RSA") == 0 ||
|
||||
+ grub_strcasecmp (value, "RSA4096") == 0)
|
||||
+ else if (grub_strcasecmp (value, "RSA4096") == 0)
|
||||
+ {
|
||||
+ srk_type->type = TPM_ALG_RSA;
|
||||
+ srk_type->detail.rsa_bits = 4096;
|
||||
@@ -37,7 +38,7 @@ index 48c39de01..b291793a7 100644
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("value '%s' is not a valid asymmetric key type"), value);
|
||||
|
||||
diff --git a/grub-core/commands/tpm2_key_protector/module.c b/grub-core/commands/tpm2_key_protector/module.c
|
||||
index 74e79a545..ee16d7f15 100644
|
||||
index 74e79a545..1b2eb6b20 100644
|
||||
--- a/grub-core/commands/tpm2_key_protector/module.c
|
||||
+++ b/grub-core/commands/tpm2_key_protector/module.c
|
||||
@@ -138,8 +138,8 @@ static const struct grub_arg_option tpm2_protector_init_cmd_options[] =
|
||||
@@ -77,6 +78,15 @@ index 74e79a545..ee16d7f15 100644
|
||||
{
|
||||
.type = TPM_ALG_RSA,
|
||||
.detail.rsa_bits = 2048,
|
||||
@@ -882,7 +894,7 @@ tpm2_protector_srk_recover (const tpm2_protector_context_t *ctx,
|
||||
if (err != GRUB_ERR_NONE)
|
||||
goto exit1;
|
||||
|
||||
- if (rsaparent == 1)
|
||||
+ if (rsaparent == 1 && ctx->srk_type.type != TPM_ALG_RSA)
|
||||
{
|
||||
tpm2_protector_context_t *ctx_w;
|
||||
|
||||
diff --git a/util/grub-protect.c b/util/grub-protect.c
|
||||
index 5b7e952f4..f1108f2c5 100644
|
||||
--- a/util/grub-protect.c
|
||||
|
@@ -0,0 +1,52 @@
|
||||
From 3a69e9126d532214d940c1386f2933a124611a6c Mon Sep 17 00:00:00 2001
|
||||
From: Egor Ignatov <egori@altlinux.org>
|
||||
Date: Thu, 23 Jan 2025 20:44:14 +0300
|
||||
Subject: [PATCH 2/3] fs/xfs: Fix grub_xfs_iterate_dir() return value in case
|
||||
of failure
|
||||
|
||||
Commit ef7850c757 (fs/xfs: Fix issues found while fuzzing the XFS
|
||||
filesystem) introduced multiple boundary checks in grub_xfs_iterate_dir()
|
||||
but handled the error incorrectly returning error code instead of 0.
|
||||
Fix it. Also change the error message so that it doesn't match the
|
||||
message in grub_xfs_read_inode().
|
||||
|
||||
Fixes: ef7850c757 (fs/xfs: Fix issues found while fuzzing the XFS filesystem)
|
||||
|
||||
Signed-off-by: Egor Ignatov <egori@altlinux.org>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
---
|
||||
grub-core/fs/xfs.c | 11 +++++++++--
|
||||
1 file changed, 9 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c
|
||||
index e3a69fe498..30e3e7f6d9 100644
|
||||
--- a/grub-core/fs/xfs.c
|
||||
+++ b/grub-core/fs/xfs.c
|
||||
@@ -859,7 +859,11 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
|
||||
grub_uint8_t c;
|
||||
|
||||
if ((inopos + (smallino ? 4 : 8)) > (grub_uint8_t *) dir + grub_xfs_fshelp_size (dir->data))
|
||||
- return grub_error (GRUB_ERR_BAD_FS, "not a correct XFS inode");
|
||||
+ {
|
||||
+ grub_error (GRUB_ERR_BAD_FS, "invalid XFS inode");
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
|
||||
/* inopos might be unaligned. */
|
||||
if (smallino)
|
||||
@@ -968,7 +972,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
|
||||
|
||||
filename = (char *)(direntry + 1);
|
||||
if (filename + direntry->len + 1 > (char *) end)
|
||||
- return grub_error (GRUB_ERR_BAD_FS, "invalid XFS directory entry");
|
||||
+ {
|
||||
+ grub_error (GRUB_ERR_BAD_FS, "invalid XFS directory entry");
|
||||
+ return 0;
|
||||
+ }
|
||||
|
||||
/* The byte after the filename is for the filetype, padding, or
|
||||
tag, which is not used by GRUB. So it can be overwritten. */
|
||||
--
|
||||
2.48.1
|
||||
|
@@ -1,7 +1,7 @@
|
||||
From 04e8509f04a4cd123bc9f290e60f582d57b2f258 Mon Sep 17 00:00:00 2001
|
||||
From ec0951f742d03f585454f0a50f588fc7ea42a257 Mon Sep 17 00:00:00 2001
|
||||
From: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Date: Tue, 27 Dec 2022 17:47:41 +0530
|
||||
Subject: [PATCH 1/8] ieee1275: Platform Keystore (PKS) Support
|
||||
Date: Mon, 24 Feb 2025 18:40:11 +0530
|
||||
Subject: [PATCH 2/9] ieee1275: Platform Keystore (PKS) Support
|
||||
|
||||
enhancing the infrastructure to enable the Platform Keystore (PKS) feature,
|
||||
which provides access to the SB VERSION, DB, and DBX secure boot variables
|
||||
@@ -9,20 +9,68 @@ from PKS.
|
||||
|
||||
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
|
||||
Tested-by: Nageswara Sastry <rnsastry@linux.ibm.com>
|
||||
Reviewed-by: Avnish Chouhan <avnish@linux.ibm.com>
|
||||
---
|
||||
grub-core/kern/ieee1275/ieee1275.c | 117 +++++++++++++++++++++++++++++
|
||||
include/grub/ieee1275/ieee1275.h | 15 ++++
|
||||
2 files changed, 132 insertions(+)
|
||||
grub-core/Makefile.am | 1 +
|
||||
grub-core/Makefile.core.def | 1 +
|
||||
grub-core/kern/powerpc/ieee1275/ieee1275.c | 140 +++++++++++++++++++++
|
||||
include/grub/powerpc/ieee1275/ieee1275.h | 14 +++
|
||||
4 files changed, 156 insertions(+)
|
||||
create mode 100644 grub-core/kern/powerpc/ieee1275/ieee1275.c
|
||||
|
||||
diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c
|
||||
index 36ca2dbfc..8d0048844 100644
|
||||
--- a/grub-core/kern/ieee1275/ieee1275.c
|
||||
+++ b/grub-core/kern/ieee1275/ieee1275.c
|
||||
@@ -807,3 +807,120 @@ grub_ieee1275_get_block_size (grub_ieee1275_ihandle_t ihandle)
|
||||
diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
|
||||
index 9d3d5f5193..40ed353aba 100644
|
||||
--- a/grub-core/Makefile.am
|
||||
+++ b/grub-core/Makefile.am
|
||||
@@ -241,6 +241,7 @@ KERNEL_HEADER_FILES += $(top_builddir)/include/grub/machine/kernel.h
|
||||
endif
|
||||
|
||||
return args.size;
|
||||
}
|
||||
if COND_powerpc_ieee1275
|
||||
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/powerpc/ieee1275/ieee1275.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/alloc.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
|
||||
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
||||
index e1698a6923..1dfcf5f991 100644
|
||||
--- a/grub-core/Makefile.core.def
|
||||
+++ b/grub-core/Makefile.core.def
|
||||
@@ -328,6 +328,7 @@ kernel = {
|
||||
extra_dist = video/sis315_init.c;
|
||||
mips_loongson = commands/keylayouts.c;
|
||||
|
||||
+ powerpc_ieee1275 = kern/powerpc/ieee1275/ieee1275.c;
|
||||
powerpc_ieee1275 = kern/powerpc/cache.S;
|
||||
powerpc_ieee1275 = kern/powerpc/dl.c;
|
||||
powerpc_ieee1275 = kern/powerpc/compiler-rt.S;
|
||||
diff --git a/grub-core/kern/powerpc/ieee1275/ieee1275.c b/grub-core/kern/powerpc/ieee1275/ieee1275.c
|
||||
new file mode 100644
|
||||
index 0000000000..f685afcfff
|
||||
--- /dev/null
|
||||
+++ b/grub-core/kern/powerpc/ieee1275/ieee1275.c
|
||||
@@ -0,0 +1,140 @@
|
||||
+/* of.c - Access the Open Firmware client interface. */
|
||||
+/*
|
||||
+ * GRUB -- GRand Unified Bootloader
|
||||
+ * Copyright (C) 2003,2004,2005,2007,2008,2009 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/>.
|
||||
+ */
|
||||
+#include <grub/ieee1275/ieee1275.h>
|
||||
+#include <grub/powerpc/ieee1275/ieee1275.h>
|
||||
+#include <grub/misc.h>
|
||||
+
|
||||
+#define IEEE1275_CELL_INVALID ((grub_ieee1275_cell_t) - 1)
|
||||
+
|
||||
+int
|
||||
+grub_ieee1275_test (const char *name, grub_ieee1275_cell_t *missing)
|
||||
@@ -140,18 +188,17 @@ index 36ca2dbfc..8d0048844 100644
|
||||
+
|
||||
+ return (int) args.rc;
|
||||
+}
|
||||
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
|
||||
index ea90d79f7..6d8dd9463 100644
|
||||
--- a/include/grub/ieee1275/ieee1275.h
|
||||
+++ b/include/grub/ieee1275/ieee1275.h
|
||||
@@ -237,6 +237,21 @@ char *EXPORT_FUNC(grub_ieee1275_encode_uint4) (grub_ieee1275_ihandle_t ihandle,
|
||||
grub_size_t *size);
|
||||
int EXPORT_FUNC(grub_ieee1275_get_block_size) (grub_ieee1275_ihandle_t ihandle);
|
||||
diff --git a/include/grub/powerpc/ieee1275/ieee1275.h b/include/grub/powerpc/ieee1275/ieee1275.h
|
||||
index 4eb2070188..0d48331c26 100644
|
||||
--- a/include/grub/powerpc/ieee1275/ieee1275.h
|
||||
+++ b/include/grub/powerpc/ieee1275/ieee1275.h
|
||||
@@ -28,4 +28,18 @@ typedef grub_uint32_t grub_ieee1275_cell_t;
|
||||
#define PRIxGRUB_IEEE1275_CELL_T PRIxGRUB_UINT32_T
|
||||
#define PRIuGRUB_IEEE1275_CELL_T PRIuGRUB_UINT32_T
|
||||
|
||||
+int EXPORT_FUNC (grub_ieee1275_test) (const char *name,
|
||||
+ grub_ieee1275_cell_t *missing);
|
||||
+
|
||||
+// not exported: I don't want modules interacting with PKS.
|
||||
+int grub_ieee1275_pks_max_object_size (grub_size_t *result);
|
||||
+
|
||||
+int grub_ieee1275_pks_read_object (grub_uint8_t consumer, grub_uint8_t *label,
|
||||
@@ -163,9 +210,7 @@ index ea90d79f7..6d8dd9463 100644
|
||||
+ grub_uint8_t *buffer, grub_size_t buffer_len,
|
||||
+ grub_size_t *data_len);
|
||||
+
|
||||
grub_err_t EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
|
||||
void EXPORT_FUNC(grub_releasemap) (void);
|
||||
|
||||
#endif /* ! GRUB_IEEE1275_MACHINE_HEADER */
|
||||
--
|
||||
2.47.0
|
||||
2.48.1
|
||||
|
@@ -1,16 +1,20 @@
|
||||
From 9e61624db77e5073961126457f599bc70e877fd1 Mon Sep 17 00:00:00 2001
|
||||
From: Diego Domingos <diegodo@br.ibm.com>
|
||||
Date: Tue, 15 Mar 2022 15:59:41 -0400
|
||||
Subject: [PATCH 2/4] ieee1275/ofpath: enable NVMeoF logical device translation
|
||||
From ba5fee5cdbe6fa4871419c54008a7efb87d99e23 Mon Sep 17 00:00:00 2001
|
||||
From: Avnish Chouhan <avnish@linux.ibm.com>
|
||||
Date: Fri, 30 Aug 2024 17:11:04 +0530
|
||||
Subject: [PATCH 2/3] ieee1275: ofpath enable NVMeoF logical device translate
|
||||
|
||||
This patch add code to enable the translation of logical devices to the of NVMeoFC paths.
|
||||
This patch adds code to enable the translation of logical devices to the of NVMeoFC paths.
|
||||
|
||||
Signed-off-by: Diego Domingos <diegodo@br.ibm.com>
|
||||
Signed-off-by: Avnish Chouhan <avnish@linux.ibm.com>
|
||||
Link: https://lore.kernel.org/r/20240830114104.32234-6-avnish@linux.ibm.com
|
||||
---
|
||||
grub-core/osdep/linux/ofpath.c | 260 +++++++++++++++++++++++++++++++--
|
||||
include/grub/util/ofpath.h | 29 ++++
|
||||
2 files changed, 280 insertions(+), 9 deletions(-)
|
||||
grub-core/osdep/linux/ofpath.c | 370 ++++++++++++++++++++++++++++++++-
|
||||
include/grub/util/ofpath.h | 28 +++
|
||||
2 files changed, 389 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c
|
||||
index 89beceef4..212782d3f 100644
|
||||
index 89beceef4a..dd50d785dd 100644
|
||||
--- a/grub-core/osdep/linux/ofpath.c
|
||||
+++ b/grub-core/osdep/linux/ofpath.c
|
||||
@@ -137,7 +137,7 @@ trim_newline (char *path)
|
||||
@@ -22,261 +26,358 @@ index 89beceef4..212782d3f 100644
|
||||
|
||||
static char *
|
||||
find_obppath (const char *sysfs_path_orig)
|
||||
@@ -313,6 +313,69 @@ get_basename(char *p)
|
||||
@@ -313,6 +313,91 @@ get_basename(char *p)
|
||||
return ret;
|
||||
}
|
||||
|
||||
+int
|
||||
+add_filename_to_pile (char *filename, struct ofpath_files_list_root* root)
|
||||
+{
|
||||
+ struct ofpath_files_list_node* file;
|
||||
+
|
||||
+void
|
||||
+add_filename_to_pile(char *filename, struct ofpath_files_list_root* root){
|
||||
+ struct ofpath_files_list_node* file;
|
||||
+ file = malloc (sizeof (struct ofpath_files_list_node));
|
||||
+ if (!file)
|
||||
+ return -1;
|
||||
+
|
||||
+ file = malloc(sizeof(struct ofpath_files_list_node));
|
||||
+ file->filename = malloc (sizeof (char) * 1024);
|
||||
+ if (!file->filename)
|
||||
+ {
|
||||
+ free (file);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ file->filename = filename;
|
||||
+
|
||||
+ if(root->first == NULL){
|
||||
+ grub_strcpy (file->filename, filename);
|
||||
+ if (root->first == NULL)
|
||||
+ {
|
||||
+ root->items = 1;
|
||||
+ root->first = file;
|
||||
+ file->next = NULL;
|
||||
+ } else {
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ root->items++;
|
||||
+ file->next = root->first;
|
||||
+ root->first = file;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+find_file(char* filename, char* directory, struct ofpath_files_list_root* root, int max_depth, int depth){
|
||||
+ struct dirent *ep;
|
||||
+ struct stat statbuf;
|
||||
+ DIR *dp;
|
||||
+find_file (char* filename, char* directory, struct ofpath_files_list_root* root, int max_depth, int depth)
|
||||
+{
|
||||
+ struct dirent *ep;
|
||||
+ struct stat statbuf;
|
||||
+ DIR *dp;
|
||||
+ int ret_val=0;
|
||||
+ char* full_path;
|
||||
+
|
||||
+ if(depth > max_depth){
|
||||
+ return;
|
||||
+ }
|
||||
+ if (depth > max_depth)
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if((dp = opendir(directory)) == NULL){
|
||||
+
|
||||
+ if ((dp = opendir (directory)) == NULL)
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ full_path = malloc (1024 * sizeof (char));
|
||||
+ if (!full_path)
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ while((ep = readdir(dp)) != NULL){
|
||||
+ while ((ep = readdir(dp)) != NULL)
|
||||
+ {
|
||||
+ snprintf (full_path, 1024, "%s/%s", directory, ep->d_name);
|
||||
+ lstat (full_path, &statbuf);
|
||||
+
|
||||
+ char* full_path = malloc(1024*sizeof(char));
|
||||
+ snprintf(full_path,1024,"%s/%s",directory,ep->d_name);
|
||||
+ if (S_ISLNK (statbuf.st_mode))
|
||||
+ {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ lstat(full_path,&statbuf);
|
||||
+ if (!strcmp (ep->d_name, ".") || !strcmp(ep->d_name, ".."))
|
||||
+ {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if(S_ISLNK(statbuf.st_mode)){
|
||||
+
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (!strcmp (ep->d_name, filename))
|
||||
+ {
|
||||
+ ret_val = add_filename_to_pile (full_path, root);
|
||||
+ if (ret_val == -1)
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if(!strcmp(ep->d_name,".") || !strcmp(ep->d_name,"..")){
|
||||
+ continue;
|
||||
+ }
|
||||
+ find_file (filename, full_path, root, max_depth, depth+1);
|
||||
+ }
|
||||
+
|
||||
+ if(!strcmp(ep->d_name,filename)){
|
||||
+ add_filename_to_pile(full_path, root);
|
||||
+ }
|
||||
+
|
||||
+ find_file(filename, full_path, root, max_depth, depth+1);
|
||||
+
|
||||
+ }
|
||||
+ closedir(dp);
|
||||
+ free (full_path);
|
||||
+ closedir (dp);
|
||||
+}
|
||||
+
|
||||
+
|
||||
static char *
|
||||
of_path_of_vdisk(const char *sys_devname __attribute__((unused)),
|
||||
const char *device,
|
||||
@@ -351,7 +414,142 @@ of_path_of_ide(const char *sys_devname __attribute__((unused)), const char *devi
|
||||
@@ -351,7 +436,200 @@ of_path_of_ide(const char *sys_devname __attribute__((unused)), const char *devi
|
||||
return ret;
|
||||
}
|
||||
|
||||
-#ifdef __sparc__
|
||||
+char*
|
||||
+of_find_fc_host(char* host_wwpn){
|
||||
+void
|
||||
+free_ofpath_files_list (struct ofpath_files_list_root* root)
|
||||
+{
|
||||
+ struct ofpath_files_list_node* node = root->first;
|
||||
+ struct ofpath_files_list_node* next;
|
||||
+
|
||||
+ while (node!=NULL)
|
||||
+ {
|
||||
+ next = node->next;
|
||||
+ free (node->filename);
|
||||
+ free (node);
|
||||
+ node = next;
|
||||
+ }
|
||||
+
|
||||
+ free (root);
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+char*
|
||||
+of_find_fc_host (char* host_wwpn)
|
||||
+{
|
||||
+ FILE* fp;
|
||||
+ char *buf;
|
||||
+ char portname_filename[sizeof("port_name")] = "port_name";
|
||||
+ char devices_path[sizeof("/sys/devices")] = "/sys/devices";
|
||||
+
|
||||
+ char *ret_val;
|
||||
+ char portname_filename[sizeof ("port_name")] = "port_name";
|
||||
+ char devices_path[sizeof ("/sys/devices")] = "/sys/devices";
|
||||
+ struct ofpath_files_list_root* portnames_file_list;
|
||||
+ struct ofpath_files_list_node* node;
|
||||
+
|
||||
+ portnames_file_list=malloc(sizeof(portnames_file_list));
|
||||
+ portnames_file_list->items=0;
|
||||
+ portnames_file_list->first=NULL;
|
||||
+ ret_val = malloc (sizeof (char) * 1024);
|
||||
+ if (!ret_val)
|
||||
+ return NULL;
|
||||
+
|
||||
+ find_file(portname_filename, devices_path, portnames_file_list, 10, 0);
|
||||
+ portnames_file_list = malloc (sizeof (struct ofpath_files_list_root));
|
||||
+ if (!portnames_file_list)
|
||||
+ {
|
||||
+ free (ret_val);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ portnames_file_list->items = 0;
|
||||
+ portnames_file_list->first = NULL;
|
||||
+ find_file (portname_filename, devices_path, portnames_file_list, 10, 0);
|
||||
+ node = portnames_file_list->first;
|
||||
+
|
||||
+ while (node != NULL)
|
||||
+ {
|
||||
+ fp = fopen(node->filename, "r");
|
||||
+ buf = malloc (sizeof (char) * 512);
|
||||
+ if (!buf)
|
||||
+ break;
|
||||
+
|
||||
+ fscanf (fp, "%s", buf);
|
||||
+ fclose (fp);
|
||||
+
|
||||
+ if ((strcmp (buf, host_wwpn) == 0) && grub_strstr (node->filename, "fc_host"))
|
||||
+ {
|
||||
+ free (buf);
|
||||
+ grub_strcpy (ret_val, node->filename);
|
||||
+ free_ofpath_files_list (portnames_file_list);
|
||||
+ return ret_val;
|
||||
+ }
|
||||
+
|
||||
+ struct ofpath_files_list_node* node = portnames_file_list->first;
|
||||
+ while(node != NULL){
|
||||
+ fp = fopen(node->filename,"r");
|
||||
+ buf = malloc(sizeof(char)*512);
|
||||
+ fscanf(fp, "%s", buf);
|
||||
+ fclose(fp);
|
||||
+ if((strcmp(buf,host_wwpn) == 0) && grub_strstr(node->filename, "fc_host")){
|
||||
+ return node->filename;
|
||||
+ }
|
||||
+ node = node->next;
|
||||
+ }
|
||||
+
|
||||
+ free (buf);
|
||||
+ }
|
||||
+ free_ofpath_files_list (portnames_file_list);
|
||||
+ free (ret_val);
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+of_path_get_nvmeof_adapter_info(char* sysfs_path,
|
||||
+ struct ofpath_nvmeof_info* nvmeof_info){
|
||||
+
|
||||
+int
|
||||
+of_path_get_nvmeof_adapter_info (char* sysfs_path,
|
||||
+ struct ofpath_nvmeof_info* nvmeof_info)
|
||||
+{
|
||||
+ FILE *fp;
|
||||
+ char *buf, *buf2, *buf3;
|
||||
+
|
||||
+ nvmeof_info->host_wwpn = malloc(sizeof(char)*256);
|
||||
+ nvmeof_info->target_wwpn = malloc(sizeof(char)*256);
|
||||
+ nvmeof_info->nqn = malloc(sizeof(char)*256);
|
||||
+ nvmeof_info->host_wwpn = malloc (sizeof (char) * 256);
|
||||
+ nvmeof_info->target_wwpn = malloc (sizeof (char) * 256);
|
||||
+ nvmeof_info->nqn = malloc (sizeof (char) * 256);
|
||||
+
|
||||
+ buf = malloc(sizeof(char)*512);
|
||||
+ snprintf(buf,512,"%s/subsysnqn",sysfs_path);
|
||||
+ fp = fopen(buf,"r");
|
||||
+ fscanf(fp, "%s", nvmeof_info->nqn);
|
||||
+ fclose(fp);
|
||||
+ if (nvmeof_info->host_wwpn == NULL || nvmeof_info->target_wwpn == NULL || nvmeof_info->nqn == NULL)
|
||||
+ {
|
||||
+ free (nvmeof_info->host_wwpn);
|
||||
+ free (nvmeof_info->target_wwpn);
|
||||
+ free (nvmeof_info->nqn);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ snprintf(buf,512,"%s/cntlid",sysfs_path);
|
||||
+ fp = fopen(buf,"r");
|
||||
+ fscanf(fp, "%u", &(nvmeof_info->cntlid));
|
||||
+ fclose(fp);
|
||||
+ buf = malloc (sizeof (char) * 512);
|
||||
+ if (!buf)
|
||||
+ {
|
||||
+ free (nvmeof_info->host_wwpn);
|
||||
+ free (nvmeof_info->target_wwpn);
|
||||
+ free (nvmeof_info->nqn);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ //snprintf(buf,512,"%s/nsid",sysfs_path);
|
||||
+ //fp = fopen(buf,"r");
|
||||
+ //fscanf(fp, "%u", &(nvmeof_info->nsid));
|
||||
+ //fclose(fp);
|
||||
+ snprintf (buf, 512, "%s/subsysnqn", sysfs_path);
|
||||
+ fp = fopen (buf, "r");
|
||||
+ fscanf (fp, "%s", nvmeof_info->nqn);
|
||||
+ fclose (fp);
|
||||
+
|
||||
+ snprintf(buf,512,"%s/address",sysfs_path);
|
||||
+ fp = fopen(buf,"r");
|
||||
+ buf2 = malloc(sizeof(char)*512);
|
||||
+ fscanf(fp, "%s", buf2);
|
||||
+ fclose(fp);
|
||||
+ snprintf (buf, 512, "%s/cntlid", sysfs_path);
|
||||
+ fp = fopen (buf, "r");
|
||||
+ fscanf (fp, "%u", &(nvmeof_info->cntlid));
|
||||
+ fclose (fp);
|
||||
+
|
||||
+ nvmeof_info->host_wwpn = strrchr(buf2,'-')+1;
|
||||
+ snprintf (buf, 512, "%s/address", sysfs_path);
|
||||
+ fp = fopen (buf, "r");
|
||||
+ buf2 = malloc (sizeof (char) * 512);
|
||||
+
|
||||
+ buf3=strchr(buf2,'-')+1;
|
||||
+ buf3=strchr(buf3,'-')+1;
|
||||
+ nvmeof_info->target_wwpn = buf3;
|
||||
+ buf3 = strchr(nvmeof_info->target_wwpn,',');
|
||||
+ if (!buf2)
|
||||
+ {
|
||||
+ free (nvmeof_info->host_wwpn);
|
||||
+ free (nvmeof_info->target_wwpn);
|
||||
+ free (nvmeof_info->nqn);
|
||||
+ free (buf);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ fscanf (fp, "%s", buf2);
|
||||
+ fclose (fp);
|
||||
+
|
||||
+ buf3 = strrchr (buf2, '-') + 1;
|
||||
+ grub_memcpy (nvmeof_info->host_wwpn, buf3, 256);
|
||||
+ buf3=strchr (buf2, '-') + 1;
|
||||
+ buf3=strchr (buf3, '-') + 1;
|
||||
+ buf3=strchr (buf3, 'x') + 1;
|
||||
+ grub_memcpy (nvmeof_info->target_wwpn, buf3, 256);
|
||||
+ buf3 = strchr (nvmeof_info->target_wwpn, ',');
|
||||
+ *buf3 = '\0';
|
||||
+
|
||||
+
|
||||
+ free(buf);
|
||||
+
|
||||
+ return;
|
||||
+ free (buf);
|
||||
+ free (buf2);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#define MAX_NVME_NSID_DIGITS 6
|
||||
+
|
||||
+static char *
|
||||
+of_path_get_nvme_controller_name_node(const char* devname)
|
||||
+of_path_get_nvme_controller_name_node (const char* devname)
|
||||
+{
|
||||
+ char *controller_node, *end;
|
||||
+
|
||||
+ controller_node = strdup(devname);
|
||||
+
|
||||
+ end = grub_strchr(controller_node+1, 'n');
|
||||
+
|
||||
+ if(end != NULL){
|
||||
+ *end = '\0';
|
||||
+ }
|
||||
+ controller_node = strdup (devname);
|
||||
+ end = grub_strchr (controller_node + 1, 'n');
|
||||
+ if (end != NULL)
|
||||
+ {
|
||||
+ *end = '\0';
|
||||
+ }
|
||||
+
|
||||
+ return controller_node;
|
||||
+}
|
||||
+
|
||||
+unsigned int
|
||||
+of_path_get_nvme_nsid(const char* devname)
|
||||
+of_path_get_nvme_nsid (const char* devname)
|
||||
+{
|
||||
+ unsigned int nsid;
|
||||
+ char *sysfs_path, *buf;
|
||||
+ FILE *fp;
|
||||
+
|
||||
+ buf=malloc(sizeof(char)*512);
|
||||
+
|
||||
+ buf = malloc (sizeof(char) * 512);
|
||||
+ if (!buf)
|
||||
+ return 0;
|
||||
+
|
||||
+ sysfs_path = block_device_get_sysfs_path_and_link (devname);
|
||||
+ snprintf (buf, 512, "%s/%s/nsid", sysfs_path, devname);
|
||||
+ fp = fopen(buf, "r");
|
||||
+ fscanf (fp, "%u", &(nsid));
|
||||
+ fclose (fp);
|
||||
+
|
||||
+ snprintf(buf,512,"%s/%s/nsid",sysfs_path,devname);
|
||||
+ fp = fopen(buf,"r");
|
||||
+ fscanf(fp, "%u", &(nsid));
|
||||
+ fclose(fp);
|
||||
+
|
||||
+ free(sysfs_path);
|
||||
+ free(buf);
|
||||
+
|
||||
+ free (sysfs_path);
|
||||
+ free (buf);
|
||||
+ return nsid;
|
||||
+
|
||||
+}
|
||||
+
|
||||
+static char *
|
||||
+nvme_get_syspath(const char *nvmedev)
|
||||
+nvme_get_syspath (const char *nvmedev)
|
||||
+{
|
||||
+ char *sysfs_path, *controller_node;
|
||||
+
|
||||
+ sysfs_path = block_device_get_sysfs_path_and_link (nvmedev);
|
||||
+
|
||||
+ if(strstr(sysfs_path,"nvme-subsystem")){
|
||||
+ controller_node = of_path_get_nvme_controller_name_node(nvmedev);
|
||||
+ strcat(sysfs_path,"/");
|
||||
+ strcat(sysfs_path,controller_node);
|
||||
+ sysfs_path = xrealpath(sysfs_path);
|
||||
+ }
|
||||
+ if (strstr (sysfs_path, "nvme-subsystem"))
|
||||
+ {
|
||||
+ controller_node = of_path_get_nvme_controller_name_node (nvmedev);
|
||||
+ strcat (sysfs_path, "/");
|
||||
+ strcat (sysfs_path, controller_node);
|
||||
+ sysfs_path = xrealpath (sysfs_path);
|
||||
+ }
|
||||
+
|
||||
+ return sysfs_path;
|
||||
+}
|
||||
+
|
||||
+
|
||||
static char *
|
||||
of_path_of_nvme(const char *sys_devname __attribute__((unused)),
|
||||
const char *device,
|
||||
@@ -360,6 +558,7 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)),
|
||||
@@ -360,6 +638,8 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)),
|
||||
{
|
||||
char *sysfs_path, *of_path, disk[MAX_DISK_CAT];
|
||||
const char *digit_string, *part_end;
|
||||
+ int chars_written;
|
||||
+ int chars_written, ret_val;
|
||||
+ struct ofpath_nvmeof_info* nvmeof_info;
|
||||
|
||||
digit_string = trailing_digits (device);
|
||||
part_end = devicenode + strlen (devicenode) - 1;
|
||||
@@ -379,15 +578,61 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)),
|
||||
@@ -379,15 +659,90 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)),
|
||||
/* Remove the p. */
|
||||
*end = '\0';
|
||||
sscanf (digit_string, "%d", &part);
|
||||
- snprintf (disk, sizeof (disk), "/disk@1:%c", 'a' + (part - 1));
|
||||
- sysfs_path = block_device_get_sysfs_path_and_link (nvmedev);
|
||||
+
|
||||
+ sysfs_path = nvme_get_syspath(nvmedev);
|
||||
+ sysfs_path = nvme_get_syspath (nvmedev);
|
||||
+
|
||||
+ /* If is a NVMeoF */
|
||||
+ if(strstr(sysfs_path,"nvme-fabrics")){
|
||||
+ struct ofpath_nvmeof_info* nvmeof_info;
|
||||
+ nvmeof_info = malloc(sizeof(nvmeof_info));
|
||||
+ if (strstr (sysfs_path, "nvme-fabrics"))
|
||||
+ {
|
||||
+ nvmeof_info = malloc (sizeof (struct ofpath_nvmeof_info));
|
||||
+ if (!nvmeof_info)
|
||||
+ {
|
||||
+ free (nvmedev);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ of_path_get_nvmeof_adapter_info(sysfs_path, nvmeof_info);
|
||||
+ ret_val = of_path_get_nvmeof_adapter_info (sysfs_path, nvmeof_info);
|
||||
+ if (ret_val == -1)
|
||||
+ {
|
||||
+ free (nvmedev);
|
||||
+ free (nvmeof_info);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ sysfs_path = of_find_fc_host(nvmeof_info->host_wwpn);
|
||||
+ sysfs_path = of_find_fc_host (nvmeof_info->host_wwpn);
|
||||
+ if (!sysfs_path)
|
||||
+ {
|
||||
+ free (nvmedev);
|
||||
+ free (nvmeof_info);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ chars_written = snprintf(disk,sizeof(disk),"/nvme-of/controller@%s,%x:nqn=%s",
|
||||
+ nvmeof_info->target_wwpn,
|
||||
+ 0xffff,
|
||||
+ nvmeof_info->nqn);
|
||||
+
|
||||
+ unsigned int nsid = of_path_get_nvme_nsid(nvmedev);
|
||||
+
|
||||
+ if(nsid){
|
||||
+ snprintf(disk+chars_written,sizeof(disk) - chars_written,
|
||||
+ "/namespace@%x:%d",nsid, part);
|
||||
+ chars_written = snprintf (disk,sizeof(disk), "/nvme-of/controller@%s,%x:nqn=%s",
|
||||
+ nvmeof_info->target_wwpn,0xffff,
|
||||
+ nvmeof_info->nqn);
|
||||
+ unsigned int nsid = of_path_get_nvme_nsid (nvmedev);
|
||||
+ if (nsid)
|
||||
+ {
|
||||
+ snprintf (disk+chars_written, sizeof("/namespace@") + MAX_NVME_NSID_DIGITS,
|
||||
+ "/namespace@%x:%d", nsid, part);
|
||||
+ }
|
||||
+ free (nvmeof_info);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ snprintf (disk, sizeof (disk), "/disk@1:%c", 'a' + (part - 1));
|
||||
+ }
|
||||
+
|
||||
+ } else {
|
||||
+ snprintf (disk, sizeof (disk), "/disk@1:%c", 'a' + (part - 1));
|
||||
+ }
|
||||
free (nvmedev);
|
||||
}
|
||||
else
|
||||
@@ -285,32 +386,45 @@ index 89beceef4..212782d3f 100644
|
||||
- snprintf (disk, sizeof (disk), "/disk@1");
|
||||
- sysfs_path = block_device_get_sysfs_path_and_link (device);
|
||||
+ sysfs_path = nvme_get_syspath (device);
|
||||
+ if(strstr(sysfs_path,"nvme-fabrics")){
|
||||
+ struct ofpath_nvmeof_info* nvmeof_info;
|
||||
+ nvmeof_info = malloc(sizeof(nvmeof_info));
|
||||
+ if (strstr (sysfs_path, "nvme-fabrics"))
|
||||
+ {
|
||||
+ nvmeof_info = malloc (sizeof (struct ofpath_nvmeof_info));
|
||||
+ if (!nvmeof_info)
|
||||
+ return NULL;
|
||||
+
|
||||
+ of_path_get_nvmeof_adapter_info(sysfs_path, nvmeof_info);
|
||||
+
|
||||
+ sysfs_path = of_find_fc_host(nvmeof_info->host_wwpn);
|
||||
+ ret_val = of_path_get_nvmeof_adapter_info (sysfs_path, nvmeof_info);
|
||||
+ if (ret_val == -1)
|
||||
+ {
|
||||
+ free (nvmeof_info);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ chars_written = snprintf(disk,sizeof(disk),"/nvme-of/controller@%s,%x:nqn=%s",
|
||||
+ nvmeof_info->target_wwpn,
|
||||
+ 0xffff,
|
||||
+ nvmeof_info->nqn);
|
||||
+
|
||||
+ unsigned int nsid = of_path_get_nvme_nsid(device);
|
||||
+ if(nsid){
|
||||
+ snprintf(disk+chars_written,sizeof(disk) - chars_written,
|
||||
+ "/namespace@%x",nsid);
|
||||
+ }
|
||||
+ } else {
|
||||
+ snprintf (disk, sizeof (disk), "/disk@1");
|
||||
+ }
|
||||
+ sysfs_path = of_find_fc_host (nvmeof_info->host_wwpn);
|
||||
+ if (!sysfs_path)
|
||||
+ {
|
||||
+ free (nvmeof_info);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ chars_written = snprintf (disk,sizeof(disk), "/nvme-of/controller@%s,%x:nqn=%s",
|
||||
+ nvmeof_info->target_wwpn, 0xffff,
|
||||
+ nvmeof_info->nqn);
|
||||
+ unsigned int nsid = of_path_get_nvme_nsid (device);
|
||||
+ if (nsid)
|
||||
+ {
|
||||
+ snprintf (disk+chars_written,sizeof("/namespace@") + sizeof(char) * MAX_NVME_NSID_DIGITS,
|
||||
+ "/namespace@%x", nsid);
|
||||
+ }
|
||||
+ free (nvmeof_info);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ snprintf (disk, sizeof (disk), "/disk@1");
|
||||
+ }
|
||||
}
|
||||
|
||||
of_path = find_obppath (sysfs_path);
|
||||
@@ -398,7 +643,6 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)),
|
||||
@@ -398,7 +753,6 @@ of_path_of_nvme(const char *sys_devname __attribute__((unused)),
|
||||
free (sysfs_path);
|
||||
return of_path;
|
||||
}
|
||||
@@ -318,7 +432,7 @@ index 89beceef4..212782d3f 100644
|
||||
|
||||
static void
|
||||
of_fc_port_name(const char *path, const char *subpath, char *port_name)
|
||||
@@ -840,11 +1084,9 @@ grub_util_devname_to_ofpath (const char *sys_devname)
|
||||
@@ -840,11 +1194,9 @@ grub_util_devname_to_ofpath (const char *sys_devname)
|
||||
/* All the models I've seen have a devalias "floppy".
|
||||
New models have no floppy at all. */
|
||||
ofpath = xstrdup ("floppy");
|
||||
@@ -331,24 +445,27 @@ index 89beceef4..212782d3f 100644
|
||||
{
|
||||
grub_util_warn (_("unknown device type %s"), device);
|
||||
diff --git a/include/grub/util/ofpath.h b/include/grub/util/ofpath.h
|
||||
index b43c523cb..a0ec30620 100644
|
||||
index b43c523cb2..7ab377c7cc 100644
|
||||
--- a/include/grub/util/ofpath.h
|
||||
+++ b/include/grub/util/ofpath.h
|
||||
@@ -3,4 +3,33 @@
|
||||
@@ -3,4 +3,32 @@
|
||||
|
||||
char *grub_util_devname_to_ofpath (const char *devname);
|
||||
|
||||
+struct ofpath_files_list_node {
|
||||
+struct ofpath_files_list_node
|
||||
+{
|
||||
+ char* filename;
|
||||
+ struct ofpath_files_list_node* next;
|
||||
+};
|
||||
+
|
||||
+struct ofpath_files_list_root {
|
||||
+struct ofpath_files_list_root
|
||||
+{
|
||||
+ int items;
|
||||
+ struct ofpath_files_list_node* first;
|
||||
+};
|
||||
+
|
||||
+struct ofpath_nvmeof_info {
|
||||
+struct ofpath_nvmeof_info
|
||||
+{
|
||||
+ char* host_wwpn;
|
||||
+ char* target_wwpn;
|
||||
+ char* nqn;
|
||||
@@ -356,18 +473,14 @@ index b43c523cb..a0ec30620 100644
|
||||
+ int nsid;
|
||||
+};
|
||||
+
|
||||
+void of_path_get_nvmeof_adapter_info(char* sysfs_path,
|
||||
+ struct ofpath_nvmeof_info* nvmeof_info);
|
||||
+
|
||||
+unsigned int of_path_get_nvme_nsid(const char* devname);
|
||||
+
|
||||
+void add_filename_to_pile(char *filename, struct ofpath_files_list_root* root);
|
||||
+
|
||||
+void find_file(char* filename, char* directory, struct ofpath_files_list_root* root, int max_depth, int depth);
|
||||
+
|
||||
+char* of_find_fc_host(char* host_wwpn);
|
||||
+int of_path_get_nvmeof_adapter_info (char* sysfs_path, struct ofpath_nvmeof_info* nvmeof_info);
|
||||
+unsigned int of_path_get_nvme_nsid (const char* devname);
|
||||
+int add_filename_to_pile (char *filename, struct ofpath_files_list_root* root);
|
||||
+void find_file (char* filename, char* directory, struct ofpath_files_list_root* root, int max_depth, int depth);
|
||||
+char* of_find_fc_host (char* host_wwpn);
|
||||
+void free_ofpath_files_list (struct ofpath_files_list_root* root);
|
||||
+
|
||||
#endif /* ! GRUB_OFPATH_MACHINE_UTIL_HEADER */
|
||||
--
|
||||
2.35.3
|
||||
2.48.1
|
||||
|
||||
|
@@ -0,0 +1,49 @@
|
||||
From 846b1d8bebd316a18fae9fb90efb3e8451ec70cc Mon Sep 17 00:00:00 2001
|
||||
From: Eric Sandeen <sandeen@redhat.com>
|
||||
Date: Wed, 4 Dec 2024 07:50:28 -0600
|
||||
Subject: [PATCH 3/3] fs/xfs: fix large extent counters incompat feature
|
||||
support
|
||||
|
||||
When large extent counter / NREXT64 support was added to grub, it missed
|
||||
a couple of direct reads of nextents which need to be changed to the new
|
||||
NREXT64-aware helper as well. Without this, we'll have mis-reads of some
|
||||
directories with this feature enabled.
|
||||
|
||||
(The large extent counter fix likely raced on merge with
|
||||
07318ee7e ("fs/xfs: Fix XFS directory extent parsing") which added the new
|
||||
direct nextents reads just prior, causing this issue.)
|
||||
|
||||
Fixes: aa7c1322671e ("fs/xfs: Add large extent counters incompat feature support")
|
||||
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
|
||||
Reviewed-by: Anthony Iliopoulos <ailiop@suse.com>
|
||||
Reviewed-by: Jon DeVree <nuxi@vault24.org>
|
||||
Link: https://lore.kernel.org/r/985816b8-35e6-4083-994f-ec9138bd35d2@redhat.com
|
||||
---
|
||||
grub-core/fs/xfs.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c
|
||||
index 30e3e7f6d9..3ba232436e 100644
|
||||
--- a/grub-core/fs/xfs.c
|
||||
+++ b/grub-core/fs/xfs.c
|
||||
@@ -937,7 +937,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
|
||||
* Leaf and tail information are only in the data block if the number
|
||||
* of extents is 1.
|
||||
*/
|
||||
- if (dir->inode.nextents == grub_cpu_to_be32_compile_time (1))
|
||||
+ if (grub_xfs_get_inode_nextents(&dir->inode) == 1)
|
||||
{
|
||||
end = (char *) tail;
|
||||
|
||||
@@ -992,7 +992,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
|
||||
* The expected number of directory entries is only tracked for the
|
||||
* single extent case.
|
||||
*/
|
||||
- if (dir->inode.nextents == grub_cpu_to_be32_compile_time (1))
|
||||
+ if (grub_xfs_get_inode_nextents(&dir->inode) == 1)
|
||||
{
|
||||
/* Check if last direntry in this block is reached. */
|
||||
entries--;
|
||||
--
|
||||
2.48.1
|
||||
|
@@ -1,139 +1,150 @@
|
||||
From 8ef821ea18ed35f5969b98f2df6a76fefb71b175 Mon Sep 17 00:00:00 2001
|
||||
From 07b675536e5ae8a0f34d65c40027458d0474d802 Mon Sep 17 00:00:00 2001
|
||||
From: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Date: Wed, 28 Dec 2022 17:49:24 +0530
|
||||
Subject: [PATCH 2/8] ieee1275: Read the DB and DBX secure boot variables
|
||||
Date: Mon, 24 Feb 2025 20:01:51 +0530
|
||||
Subject: [PATCH 3/9] ieee1275: Read the DB and DBX secure boot variables
|
||||
|
||||
If secure boot is enabled with PKS, it will read secure boot variables
|
||||
such as db and dbx from PKS and extract certificates from ESL.
|
||||
It would be saved in the platform keystore buffer, and
|
||||
such as db and dbx from PKS and extract ESL's from it.
|
||||
The ESL's would be saved in the platform keystore buffer, and
|
||||
the appendedsig (module) would read it later to extract
|
||||
the certificate's details.
|
||||
the certificate's details from ESL.
|
||||
|
||||
In the following scenarios, static key mode will be activated:
|
||||
1. When secure boot is enabled with static
|
||||
1. When Secure Boot is enabled with static keys
|
||||
2. When SB Version is unavailable but Secure Boot is enabled
|
||||
3. When PKS support is unavailable but secure boot is enabled
|
||||
3. When PKS support is unavailable but Secure Boot is enabled
|
||||
|
||||
Note:-
|
||||
|
||||
SB Version - secure boot mode
|
||||
SB Version - Secure Boot mode
|
||||
1 - PKS
|
||||
0 - static key (embeded key)
|
||||
|
||||
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
|
||||
Tested-by: Nageswara Sastry <rnsastry@linux.ibm.com>
|
||||
Reviewed-by: Avnish Chouhan <avnish@linux.ibm.com>
|
||||
---
|
||||
grub-core/Makefile.am | 1 +
|
||||
grub-core/Makefile.core.def | 1 +
|
||||
grub-core/kern/ieee1275/init.c | 12 +-
|
||||
grub-core/kern/ieee1275/platform_keystore.c | 377 ++++++++++++++++++++
|
||||
include/grub/platform_keystore.h | 190 ++++++++++
|
||||
5 files changed, 580 insertions(+), 1 deletion(-)
|
||||
create mode 100644 grub-core/kern/ieee1275/platform_keystore.c
|
||||
create mode 100644 include/grub/platform_keystore.h
|
||||
grub-core/Makefile.am | 1 +
|
||||
grub-core/Makefile.core.def | 1 +
|
||||
grub-core/kern/ieee1275/init.c | 15 +-
|
||||
.../kern/powerpc/ieee1275/platform_keystore.c | 335 ++++++++++++++++++
|
||||
.../grub/powerpc/ieee1275/platform_keystore.h | 225 ++++++++++++
|
||||
include/grub/types.h | 9 +
|
||||
6 files changed, 584 insertions(+), 2 deletions(-)
|
||||
create mode 100644 grub-core/kern/powerpc/ieee1275/platform_keystore.c
|
||||
create mode 100644 include/grub/powerpc/ieee1275/platform_keystore.h
|
||||
|
||||
diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
|
||||
index 9d3d5f519..4630e2ba3 100644
|
||||
index 40ed353aba..999e62788f 100644
|
||||
--- a/grub-core/Makefile.am
|
||||
+++ b/grub-core/Makefile.am
|
||||
@@ -79,6 +79,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/file.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fs.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i18n.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/kernel.h
|
||||
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/platform_keystore.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/list.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lockdown.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/misc.h
|
||||
@@ -247,6 +247,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/alloc.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
|
||||
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
|
||||
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/powerpc/ieee1275/platform_keystore.h
|
||||
endif
|
||||
|
||||
if COND_sparc64_ieee1275
|
||||
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
||||
index dc639dd24..4ff35afb7 100644
|
||||
index 1dfcf5f991..85e717c122 100644
|
||||
--- a/grub-core/Makefile.core.def
|
||||
+++ b/grub-core/Makefile.core.def
|
||||
@@ -170,6 +170,7 @@ kernel = {
|
||||
ieee1275 = kern/ieee1275/openfw.c;
|
||||
ieee1275 = term/ieee1275/console.c;
|
||||
ieee1275 = kern/ieee1275/init.c;
|
||||
+ ieee1275 = kern/ieee1275/platform_keystore.c;
|
||||
@@ -333,6 +333,7 @@ kernel = {
|
||||
powerpc_ieee1275 = kern/powerpc/dl.c;
|
||||
powerpc_ieee1275 = kern/powerpc/compiler-rt.S;
|
||||
powerpc_ieee1275 = kern/lockdown.c;
|
||||
+ powerpc_ieee1275 = kern/powerpc/ieee1275/platform_keystore.c;
|
||||
|
||||
uboot = disk/uboot/ubootdisk.c;
|
||||
uboot = kern/uboot/uboot.c;
|
||||
sparc64_ieee1275 = kern/sparc64/cache.S;
|
||||
sparc64_ieee1275 = kern/sparc64/dl.c;
|
||||
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
|
||||
index 38f1f1f6e..bb800b275 100644
|
||||
index 0e1cbf24c3..45f787eff4 100644
|
||||
--- a/grub-core/kern/ieee1275/init.c
|
||||
+++ b/grub-core/kern/ieee1275/init.c
|
||||
@@ -50,6 +50,7 @@
|
||||
@@ -50,6 +50,8 @@
|
||||
#include <grub/ieee1275/alloc.h>
|
||||
#endif
|
||||
#include <grub/lockdown.h>
|
||||
+#include <grub/platform_keystore.h>
|
||||
+#include <grub/powerpc/ieee1275/ieee1275.h>
|
||||
+#include <grub/powerpc/ieee1275/platform_keystore.h>
|
||||
|
||||
/* The maximum heap size we're going to claim at boot. Not used by sparc. */
|
||||
#ifdef __i386__
|
||||
@@ -915,7 +916,16 @@ grub_get_ieee1275_secure_boot (void)
|
||||
@@ -985,7 +987,7 @@ grub_get_ieee1275_secure_boot (void)
|
||||
{
|
||||
grub_ieee1275_phandle_t root;
|
||||
int rc;
|
||||
- grub_uint32_t is_sb;
|
||||
+ grub_uint32_t is_sb = 0;
|
||||
|
||||
if (grub_ieee1275_finddevice ("/", &root))
|
||||
{
|
||||
@@ -1009,7 +1011,16 @@ grub_get_ieee1275_secure_boot (void)
|
||||
* We only support enforce.
|
||||
*/
|
||||
if (rc >= 0 && is_sb >= 2)
|
||||
if (is_sb >= 2)
|
||||
- grub_lockdown ();
|
||||
+ {
|
||||
+ grub_printf ("secure boot enabled\n");
|
||||
+ rc = grub_platform_keystore_init ();
|
||||
+ grub_printf ("Secure Boot Enabled\n");
|
||||
+ rc = grub_pks_keystore_init ();
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ grub_printf ("Warning: initialization of the platform keystore failed!\n");
|
||||
+ grub_printf ("Initialization of the Platform Keystore failed!\n");
|
||||
+
|
||||
+ grub_lockdown ();
|
||||
+ }
|
||||
+ else
|
||||
+ grub_printf ("secure boot disabled\n");
|
||||
+ grub_printf ("Secure Boot Disabled\n");
|
||||
}
|
||||
|
||||
grub_addr_t grub_modbase;
|
||||
diff --git a/grub-core/kern/ieee1275/platform_keystore.c b/grub-core/kern/ieee1275/platform_keystore.c
|
||||
diff --git a/grub-core/kern/powerpc/ieee1275/platform_keystore.c b/grub-core/kern/powerpc/ieee1275/platform_keystore.c
|
||||
new file mode 100644
|
||||
index 000000000..976e4e9b5
|
||||
index 0000000000..ea9f27eb22
|
||||
--- /dev/null
|
||||
+++ b/grub-core/kern/ieee1275/platform_keystore.c
|
||||
@@ -0,0 +1,377 @@
|
||||
+++ b/grub-core/kern/powerpc/ieee1275/platform_keystore.c
|
||||
@@ -0,0 +1,335 @@
|
||||
+/*
|
||||
+ * GRUB -- GRand Unified Bootloader
|
||||
+ * Copyright (C) 2024 Free Software Foundation, Inc.
|
||||
+ * Copyright (C) 2024 IBM Corporation
|
||||
+ *
|
||||
+ * 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/>.
|
||||
+ */
|
||||
+
|
||||
+#include <grub/mm.h>
|
||||
+#include <grub/ieee1275/ieee1275.h>
|
||||
+#include <grub/powerpc/ieee1275/ieee1275.h>
|
||||
+#include <grub/types.h>
|
||||
+#include <grub/misc.h>
|
||||
+#include <grub/lockdown.h>
|
||||
+#include <grub/platform_keystore.h>
|
||||
+#include <grub/powerpc/ieee1275/platform_keystore.h>
|
||||
+
|
||||
+#define PKS_CONSUMER_FW 1
|
||||
+#define SB_VERSION_KEY_NAME ((grub_uint8_t *) "SB_VERSION")
|
||||
+#define SB_VERSION_KEY_LEN 10
|
||||
+#define DB 1
|
||||
+#define DBX 2
|
||||
+
|
||||
+#define PKS_OBJECT_NOT_FOUND -7
|
||||
+#define PKS_UNPACK_ERROR 0x200
|
||||
+#define PKS_UNPACK_VERSION_ERROR 0x201
|
||||
+
|
||||
+struct pks_timestamp
|
||||
+{
|
||||
+ grub_uint16_t year;
|
||||
+ grub_uint8_t month;
|
||||
+ grub_uint8_t day;
|
||||
+ grub_uint8_t hour;
|
||||
+ grub_uint8_t minute;
|
||||
+ grub_uint8_t second;
|
||||
+} GRUB_PACKED;
|
||||
+
|
||||
+struct pks_signed_var
|
||||
+{
|
||||
+ grub_uint8_t version;
|
||||
+ struct pks_timestamp time;
|
||||
+} GRUB_PACKED;
|
||||
+#define PKS_OBJECT_NOT_FOUND ((grub_err_t) - 7)
|
||||
+
|
||||
+/* Platform Keystore */
|
||||
+static grub_size_t pks_max_object_size;
|
||||
+grub_uint8_t grub_use_platform_keystore = 0;
|
||||
+grub_pks_t grub_platform_keystore = { .use_static_keys = 0, .db = NULL, .dbx = NULL, .db_entries = 0, .dbx_entries = 0 };
|
||||
+grub_uint8_t grub_pks_use_keystore = 0;
|
||||
+grub_pks_t grub_pks_keystore = { .db = NULL, .dbx = NULL, .db_entries = 0, .dbx_entries = 0 };
|
||||
+
|
||||
+/* converts the esl data into the ESL */
|
||||
+/* Convert the esl data into the ESL */
|
||||
+static grub_esl_t *
|
||||
+grub_convert_to_esl (const grub_uint8_t *esl_data, const grub_size_t esl_data_size)
|
||||
+convert_to_esl (const grub_uint8_t *esl_data, const grub_size_t esl_data_size)
|
||||
+{
|
||||
+ grub_esl_t *esl = NULL;
|
||||
+
|
||||
@@ -146,13 +157,13 @@ index 000000000..976e4e9b5
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * imports the GUID, esd, and its size into the pks sd buffer and
|
||||
+ * Import the GUID, esd, and its size into the pks sd buffer and
|
||||
+ * pks sd entries from the EFI signature list.
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_esd_from_esl (const grub_uint8_t *esl_data, grub_size_t esl_size,
|
||||
+ const grub_size_t signature_size, const grub_uuid_t *guid,
|
||||
+ grub_pks_sd_t **pks_sd, grub_size_t *pks_sd_entries)
|
||||
+esd_from_esl (const grub_uint8_t *esl_data, grub_size_t esl_size,
|
||||
+ const grub_size_t signature_size, const grub_uuid_t *guid,
|
||||
+ grub_pks_sd_t **pks_sd, grub_size_t *pks_sd_entries)
|
||||
+{
|
||||
+ grub_esd_t *esd = NULL;
|
||||
+ grub_pks_sd_t *signature = *pks_sd;
|
||||
@@ -165,11 +176,7 @@ index 000000000..976e4e9b5
|
||||
+ esd = (grub_esd_t *) (esl_data + offset);
|
||||
+ data_size = signature_size - sizeof (grub_esd_t);
|
||||
+
|
||||
+ if (signature != NULL)
|
||||
+ signature = grub_realloc (signature, (entries + 1) * sizeof (grub_pks_sd_t));
|
||||
+ else
|
||||
+ signature = grub_malloc (sizeof (grub_pks_sd_t));
|
||||
+
|
||||
+ signature = grub_realloc (signature, (entries + 1) * sizeof (grub_pks_sd_t));
|
||||
+ if (signature == NULL)
|
||||
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
|
||||
+
|
||||
@@ -178,7 +185,7 @@ index 000000000..976e4e9b5
|
||||
+ {
|
||||
+ /*
|
||||
+ * allocated memory will be freed by
|
||||
+ * grub_release_platform_keystore
|
||||
+ * grub_free_platform_keystore
|
||||
+ */
|
||||
+ *pks_sd = signature;
|
||||
+ *pks_sd_entries = entries + 1;
|
||||
@@ -200,18 +207,18 @@ index 000000000..976e4e9b5
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * extracts the esd after removing the esl header from esl.
|
||||
+ * Extract the esd after removing the esl header from esl.
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_esl_to_esd (const grub_uint8_t *esl_data, grub_size_t *next_esl,
|
||||
+ grub_pks_sd_t **pks_sd, grub_size_t *pks_sd_entries)
|
||||
+esl_to_esd (const grub_uint8_t *esl_data, grub_size_t *next_esl,
|
||||
+ grub_pks_sd_t **pks_sd, grub_size_t *pks_sd_entries)
|
||||
+{
|
||||
+ grub_uuid_t guid = { 0 };
|
||||
+ grub_esl_t *esl = NULL;
|
||||
+ grub_size_t offset = 0, esl_size = 0,
|
||||
+ signature_size = 0, signature_header_size = 0;
|
||||
+
|
||||
+ esl = grub_convert_to_esl (esl_data, *next_esl);
|
||||
+ esl = convert_to_esl (esl_data, *next_esl);
|
||||
+ if (esl == NULL)
|
||||
+ return grub_error (GRUB_ERR_BUG, "invalid ESL");
|
||||
+
|
||||
@@ -227,24 +234,24 @@ index 000000000..976e4e9b5
|
||||
+ offset = sizeof (grub_esl_t) + signature_header_size;
|
||||
+ esl_size = esl_size - offset;
|
||||
+
|
||||
+ return grub_esd_from_esl (esl_data + offset, esl_size, signature_size, &guid,
|
||||
+ pks_sd, pks_sd_entries);
|
||||
+ return esd_from_esl (esl_data + offset, esl_size, signature_size, &guid,
|
||||
+ pks_sd, pks_sd_entries);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * imports the EFI signature data and the number of esd from the esl
|
||||
+ * Import the EFI signature data and the number of esd from the esl
|
||||
+ * into the pks sd buffer and pks sd entries.
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_pks_sd_from_esl (const grub_uint8_t *esl_data, grub_size_t esl_size,
|
||||
+ grub_pks_sd_t **pks_sd, grub_size_t *pks_sd_entries)
|
||||
+pks_sd_from_esl (const grub_uint8_t *esl_data, grub_size_t esl_size,
|
||||
+ grub_pks_sd_t **pks_sd, grub_size_t *pks_sd_entries)
|
||||
+{
|
||||
+ grub_err_t rc = GRUB_ERR_NONE;
|
||||
+ grub_size_t next_esl = esl_size;
|
||||
+
|
||||
+ do
|
||||
+ {
|
||||
+ rc = grub_esl_to_esd (esl_data, &next_esl, pks_sd, pks_sd_entries);
|
||||
+ rc = esl_to_esd (esl_data, &next_esl, pks_sd, pks_sd_entries);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ break;
|
||||
+
|
||||
@@ -258,36 +265,11 @@ index 000000000..976e4e9b5
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * unpacking the signed secure boot variable
|
||||
+ * return error if size too small or version mismatch
|
||||
+ * discards timestamp, only needed in verifying updates
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_unpack_signed_variable (grub_uint8_t *indata, grub_size_t insize,
|
||||
+ grub_uint8_t **data, grub_size_t *size)
|
||||
+{
|
||||
+ struct pks_signed_var *psv = NULL;
|
||||
+
|
||||
+ /* do not permit negative or size 0 data */
|
||||
+ if (insize <= sizeof (struct pks_signed_var))
|
||||
+ return PKS_UNPACK_ERROR;
|
||||
+
|
||||
+ psv = (struct pks_signed_var *) indata;
|
||||
+ if (psv->version != 0)
|
||||
+ return PKS_UNPACK_VERSION_ERROR;
|
||||
+
|
||||
+ *data = indata + sizeof (struct pks_signed_var);
|
||||
+ *size = insize - sizeof (struct pks_signed_var);
|
||||
+
|
||||
+ return GRUB_ERR_NONE;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * reads the secure boot version from PKS as an object.
|
||||
+ * Read the secure boot version from PKS as an object.
|
||||
+ * caller must free result
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_sbversion_from_pks (grub_uint8_t **out, grub_size_t *outlen, grub_size_t *policy)
|
||||
+read_sbversion_from_pks (grub_uint8_t **out, grub_size_t *outlen, grub_size_t *policy)
|
||||
+{
|
||||
+ *out = grub_malloc (pks_max_object_size);
|
||||
+ if (*out == NULL)
|
||||
@@ -303,7 +285,7 @@ index 000000000..976e4e9b5
|
||||
+ * caller must free result
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_sbvar_from_pks (const grub_uint8_t sbvarflags, const grub_uint8_t sbvartype,
|
||||
+read_sbvar_from_pks (const grub_uint8_t sbvarflags, const grub_uint8_t sbvartype,
|
||||
+ grub_uint8_t **out, grub_size_t *outlen)
|
||||
+{
|
||||
+ *out = grub_malloc (pks_max_object_size);
|
||||
@@ -315,38 +297,38 @@ index 000000000..976e4e9b5
|
||||
+}
|
||||
+
|
||||
+/* Test the availability of PKS support. */
|
||||
+static grub_err_t
|
||||
+grub_is_support_pks (void)
|
||||
+static int
|
||||
+is_support_pks (void)
|
||||
+{
|
||||
+ grub_err_t rc = GRUB_ERR_NONE;
|
||||
+ grub_ieee1275_cell_t missing = 0;
|
||||
+
|
||||
+ rc = grub_ieee1275_test ("pks-max-object-size", &missing);
|
||||
+ if (rc != GRUB_ERR_NONE || (int) missing == -1)
|
||||
+ grub_printf ("Warning: doesn't have PKS support!\n");
|
||||
+ grub_printf ("Firmware doesn't have PKS support!\n");
|
||||
+ else
|
||||
+ {
|
||||
+ rc = grub_ieee1275_pks_max_object_size (&pks_max_object_size);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ grub_printf ("Warning: PKS support is there but it has zero objects!\n");
|
||||
+ grub_printf ("PKS support is there but it has zero objects!\n");
|
||||
+ }
|
||||
+
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * retrieves the secure boot variable from PKS, unpacks it, reads the esd
|
||||
+ * from ESL, and stores the information in the pks sd buffer.
|
||||
+ * Retrieve the secure boot variable from PKS, unpacks it, read the esd
|
||||
+ * from ESL, and store the information in the pks sd buffer.
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_secure_boot_variables (const grub_uint8_t sbvarflags, const grub_uint8_t sbvartype,
|
||||
+read_secure_boot_variables (const grub_uint8_t sbvarflags, const grub_uint8_t sbvartype,
|
||||
+ grub_pks_sd_t **pks_sd, grub_size_t *pks_sd_entries)
|
||||
+{
|
||||
+ grub_err_t rc = GRUB_ERR_NONE;
|
||||
+ grub_uint8_t *data = NULL, *esl_data = NULL;
|
||||
+ grub_size_t data_len = 0, esl_data_size = 0;
|
||||
+ grub_uint8_t *esl_data = NULL;
|
||||
+ grub_size_t esl_data_size = 0;
|
||||
+
|
||||
+ rc = grub_sbvar_from_pks (sbvarflags, sbvartype, &data, &data_len);
|
||||
+ rc = read_sbvar_from_pks (sbvarflags, sbvartype, &esl_data, &esl_data_size);
|
||||
+ /*
|
||||
+ * at this point we have SB_VERSION, so any error is worth
|
||||
+ * at least some user-visible info
|
||||
@@ -354,111 +336,98 @@ index 000000000..976e4e9b5
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ rc = grub_error (rc, "secure boot variable %s reading (%d)",
|
||||
+ (sbvartype == DB ? "db" : "dbx"), rc);
|
||||
+ else
|
||||
+ {
|
||||
+ rc = grub_unpack_signed_variable (data, data_len, &esl_data, &esl_data_size);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ rc = grub_error (rc, "unpacking of signed variable %s structure (%d)",
|
||||
+ (sbvartype == DB ? "db" : "dbx"), rc);
|
||||
+ else
|
||||
+ rc = grub_pks_sd_from_esl ((const grub_uint8_t *) esl_data, esl_data_size,
|
||||
+ pks_sd, pks_sd_entries);
|
||||
+ }
|
||||
+
|
||||
+ grub_free (data);
|
||||
+ else if (esl_data_size != 0)
|
||||
+ rc = pks_sd_from_esl ((const grub_uint8_t *) esl_data, esl_data_size,
|
||||
+ pks_sd, pks_sd_entries);
|
||||
+ grub_free (esl_data);
|
||||
+
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
+/* reads secure boot version (SB_VERSION) */
|
||||
+/* reads secure boot version (SB_VERSION) and it supports following
|
||||
+ * SB_VERSION
|
||||
+ * 1 - PKS
|
||||
+ * 0 - static key (embeded key)
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_secure_boot_version (void)
|
||||
+get_secure_boot_version (void)
|
||||
+{
|
||||
+ grub_err_t rc = GRUB_ERR_NONE;
|
||||
+ grub_uint8_t *data = NULL;
|
||||
+ grub_size_t len = 0, policy = 0;
|
||||
+
|
||||
+ rc = grub_sbversion_from_pks (&data, &len, &policy);
|
||||
+ rc = read_sbversion_from_pks (&data, &len, &policy);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ grub_printf ("Warning: SB version read failed! (%d)\n", rc);
|
||||
+ grub_printf ("SB version read failed! (%d)\n", rc);
|
||||
+ else if (len != 1 || (*data != 1 && *data != 0))
|
||||
+ {
|
||||
+ grub_printf ("Warning: found unexpected SB version! (%d)\n", *data);
|
||||
+ grub_printf ("found unexpected SB version! (%d)\n", *data);
|
||||
+ rc = GRUB_ERR_INVALID_COMMAND;
|
||||
+ }
|
||||
+
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ grub_printf ("Warning: switch to static key!\n");
|
||||
+ grub_printf ("Switch to Static Key!\n");
|
||||
+ if (grub_is_lockdown () == GRUB_LOCKDOWN_ENABLED)
|
||||
+ grub_fatal ("Secure Boot locked down");
|
||||
+ }
|
||||
+ else
|
||||
+ grub_use_platform_keystore = *data;
|
||||
+ grub_pks_use_keystore = *data;
|
||||
+
|
||||
+ grub_free (data);
|
||||
+
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
+/* releasing allocated memory */
|
||||
+/* Free allocated memory */
|
||||
+void
|
||||
+grub_release_platform_keystore (void)
|
||||
+grub_pks_free_keystore (void)
|
||||
+{
|
||||
+ grub_size_t i = 0;
|
||||
+
|
||||
+ for (i = 0; i < grub_platform_keystore.db_entries; i++)
|
||||
+ grub_free (grub_platform_keystore.db[i].data);
|
||||
+ for (i = 0; i < grub_pks_keystore.db_entries; i++)
|
||||
+ grub_free (grub_pks_keystore.db[i].data);
|
||||
+
|
||||
+ for (i = 0; i < grub_platform_keystore.dbx_entries; i++)
|
||||
+ grub_free (grub_platform_keystore.dbx[i].data);
|
||||
+ for (i = 0; i < grub_pks_keystore.dbx_entries; i++)
|
||||
+ grub_free (grub_pks_keystore.dbx[i].data);
|
||||
+
|
||||
+ grub_free (grub_platform_keystore.db);
|
||||
+ grub_free (grub_platform_keystore.dbx);
|
||||
+ grub_memset (&grub_platform_keystore, 0x00, sizeof (grub_pks_t));
|
||||
+ grub_free (grub_pks_keystore.db);
|
||||
+ grub_free (grub_pks_keystore.dbx);
|
||||
+ grub_memset (&grub_pks_keystore, 0, sizeof (grub_pks_t));
|
||||
+}
|
||||
+
|
||||
+/* initialization of the Platform Keystore */
|
||||
+/* Initialization of the Platform Keystore */
|
||||
+grub_err_t
|
||||
+grub_platform_keystore_init (void)
|
||||
+grub_pks_keystore_init (void)
|
||||
+{
|
||||
+ grub_err_t rc = GRUB_ERR_NONE;
|
||||
+
|
||||
+ grub_printf ("trying to load Platform Keystore\n");
|
||||
+
|
||||
+ rc = grub_is_support_pks ();
|
||||
+ rc = is_support_pks ();
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ grub_printf ("Warning: switch to static key!\n");
|
||||
+ grub_printf ("Switch to Static Key!\n");
|
||||
+ return rc;
|
||||
+ }
|
||||
+
|
||||
+ /* SB_VERSION */
|
||||
+ rc = grub_secure_boot_version ();
|
||||
+ rc = get_secure_boot_version ();
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ return rc;
|
||||
+
|
||||
+ if (grub_use_platform_keystore)
|
||||
+ if (grub_pks_use_keystore)
|
||||
+ {
|
||||
+ grub_memset (&grub_platform_keystore, 0x00, sizeof (grub_pks_t));
|
||||
+ grub_memset (&grub_pks_keystore, 0, sizeof (grub_pks_t));
|
||||
+ /* DB */
|
||||
+ rc = grub_secure_boot_variables (0, DB, &grub_platform_keystore.db,
|
||||
+ &grub_platform_keystore.db_entries);
|
||||
+ if ((int)rc == PKS_OBJECT_NOT_FOUND)
|
||||
+ {
|
||||
+ rc = GRUB_ERR_NONE;
|
||||
+ /* DB variable won't be available by default in PKS, So, it will loads the Default Keys from ELF Note */
|
||||
+ grub_platform_keystore.use_static_keys = 1;
|
||||
+ }
|
||||
+
|
||||
+ rc = read_secure_boot_variables (0, DB, &grub_pks_keystore.db, &grub_pks_keystore.db_entries);
|
||||
+ if (rc == GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ /* DBX */
|
||||
+ rc = grub_secure_boot_variables (0, DBX, &grub_platform_keystore.dbx,
|
||||
+ &grub_platform_keystore.dbx_entries);
|
||||
+ if ((int)rc == PKS_OBJECT_NOT_FOUND)
|
||||
+ rc = read_secure_boot_variables (0, DBX, &grub_pks_keystore.dbx, &grub_pks_keystore.dbx_entries);
|
||||
+ if (rc == PKS_OBJECT_NOT_FOUND)
|
||||
+ {
|
||||
+ grub_printf ("Warning: dbx is not found!\n");
|
||||
+ grub_printf ("dbx is not found!\n");
|
||||
+ rc = GRUB_ERR_NONE;
|
||||
+ }
|
||||
+ }
|
||||
@@ -466,16 +435,53 @@ index 000000000..976e4e9b5
|
||||
+ }
|
||||
+
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ grub_release_platform_keystore ();
|
||||
+ grub_pks_free_keystore ();
|
||||
+
|
||||
+ return rc;
|
||||
+}
|
||||
diff --git a/include/grub/platform_keystore.h b/include/grub/platform_keystore.h
|
||||
diff --git a/include/grub/powerpc/ieee1275/platform_keystore.h b/include/grub/powerpc/ieee1275/platform_keystore.h
|
||||
new file mode 100644
|
||||
index 000000000..8cc4266c9
|
||||
index 0000000000..0641adb0f1
|
||||
--- /dev/null
|
||||
+++ b/include/grub/platform_keystore.h
|
||||
@@ -0,0 +1,190 @@
|
||||
+++ b/include/grub/powerpc/ieee1275/platform_keystore.h
|
||||
@@ -0,0 +1,225 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. This
|
||||
+ * program and the accompanying materials are licensed and made available
|
||||
+ * under the terms and conditions of the 2-Clause BSD License which
|
||||
+ * accompanies this distribution.
|
||||
+ *
|
||||
+ * Redistribution and use in source and binary forms, with or without
|
||||
+ * modification, are permitted provided that the following conditions are met:
|
||||
+ *
|
||||
+ * 1. Redistributions of source code must retain the above copyright notice,
|
||||
+ * this list of conditions and the following disclaimer.
|
||||
+ *
|
||||
+ * 2. Redistributions in binary form must reproduce the above copyright
|
||||
+ * notice, this list of conditions and the following disclaimer in the
|
||||
+ * documentation and/or other materials provided with the distribution.
|
||||
+ *
|
||||
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
+ * POSSIBILITY OF SUCH DAMAGE.
|
||||
+ *
|
||||
+ *
|
||||
+ * https://github.com/tianocore/edk2-staging (edk2-staging repo of tianocore),
|
||||
+ * the ImageAuthentication.h file under it, and here's the copyright and license.
|
||||
+ *
|
||||
+ * MdePkg/Include/Guid/ImageAuthentication.h
|
||||
+ *
|
||||
+ * Copyright 2024 IBM Corp.
|
||||
+ */
|
||||
+
|
||||
+#ifndef __PLATFORM_KEYSTORE_H__
|
||||
+#define __PLATFORM_KEYSTORE_H__
|
||||
+
|
||||
@@ -487,20 +493,16 @@ index 000000000..8cc4266c9
|
||||
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
|
||||
+#endif
|
||||
+
|
||||
+#define GRUB_UUID_SIZE 16
|
||||
+#define GRUB_MAX_HASH_SIZE 64
|
||||
+
|
||||
+typedef struct grub_uuid grub_uuid_t;
|
||||
+typedef struct grub_esd grub_esd_t;
|
||||
+typedef struct grub_esl grub_esl_t;
|
||||
+
|
||||
+/* The structure of a UUID.*/
|
||||
+struct grub_uuid
|
||||
+{
|
||||
+ grub_uint8_t b[GRUB_UUID_SIZE];
|
||||
+};
|
||||
+
|
||||
+/* The structure of an EFI signature database (ESD).*/
|
||||
+/*
|
||||
+ * It is derived from EFI_SIGNATURE_DATA
|
||||
+ * https://github.com/tianocore/edk2-staging/blob/master/MdePkg/Include/Guid/ImageAuthentication.h
|
||||
+ *
|
||||
+ * The structure of an EFI signature database (ESD).*/
|
||||
+struct grub_esd
|
||||
+{
|
||||
+ /*
|
||||
@@ -512,7 +514,11 @@ index 000000000..8cc4266c9
|
||||
+ grub_uint8_t signaturedata[];
|
||||
+} GRUB_PACKED;
|
||||
+
|
||||
+/* The structure of an EFI signature list (ESL).*/
|
||||
+/*
|
||||
+ * It is derived from EFI_SIGNATURE_LIST
|
||||
+ * https://github.com/tianocore/edk2-staging/blob/master/MdePkg/Include/Guid/ImageAuthentication.h
|
||||
+ *
|
||||
+ * The structure of an EFI signature list (ESL).*/
|
||||
+struct grub_esl
|
||||
+{
|
||||
+ /* Type of the signature. GUID signature types are defined in below.*/
|
||||
@@ -529,14 +535,9 @@ index 000000000..8cc4266c9
|
||||
+} GRUB_PACKED;
|
||||
+
|
||||
+/*
|
||||
+ * The GRUB_PKS_CERT_* is derived from the following files referred from edk2-staging[1] repo
|
||||
+ * of tianocore
|
||||
+ *
|
||||
+ * MdePkg/Include/Guid/ImageAuthentication.h
|
||||
+ *
|
||||
+ * [1] https://github.com/tianocore/edk2-staging
|
||||
+ * It is derived from EFI_CERT_X509_GUID
|
||||
+ * https://github.com/tianocore/edk2-staging/blob/master/MdePkg/Include/Guid/ImageAuthentication.h
|
||||
+ */
|
||||
+
|
||||
+#define GRUB_PKS_CERT_X509_GUID \
|
||||
+ (grub_uuid_t) \
|
||||
+ { \
|
||||
@@ -547,26 +548,10 @@ index 000000000..8cc4266c9
|
||||
+ } \
|
||||
+ }
|
||||
+
|
||||
+#define GRUB_PKS_CERT_SHA1_GUID \
|
||||
+ (grub_uuid_t) \
|
||||
+ { \
|
||||
+ { \
|
||||
+ 0x12, 0xa5, 0x6c, 0x82, 0x10, 0xcf, \
|
||||
+ 0xc9, 0x4a, 0xb1, 0x87, 0xbe, 0x1, \
|
||||
+ 0x49, 0x66, 0x31, 0xbd \
|
||||
+ } \
|
||||
+ }
|
||||
+
|
||||
+#define GRUB_PKS_CERT_SHA224_GUID \
|
||||
+ (grub_uuid_t) \
|
||||
+ { \
|
||||
+ { \
|
||||
+ 0x33, 0x52, 0x6e, 0xb, 0x5c, 0xa6, \
|
||||
+ 0xc9, 0x44, 0x94, 0x7, 0xd9, 0xab, \
|
||||
+ 0x83, 0xbf, 0xc8, 0xbd \
|
||||
+ } \
|
||||
+ }
|
||||
+
|
||||
+/*
|
||||
+ * It is derived from EFI_CERT_SHA256_GUID
|
||||
+ * https://github.com/tianocore/edk2-staging/blob/master/MdePkg/Include/Guid/ImageAuthentication.h
|
||||
+ */
|
||||
+#define GRUB_PKS_CERT_SHA256_GUID \
|
||||
+ (grub_uuid_t) \
|
||||
+ { \
|
||||
@@ -577,6 +562,10 @@ index 000000000..8cc4266c9
|
||||
+ } \
|
||||
+ }
|
||||
+
|
||||
+/*
|
||||
+ * It is derived from EFI_CERT_SHA384_GUID
|
||||
+ * https://github.com/tianocore/edk2-staging/blob/master/MdePkg/Include/Guid/ImageAuthentication.h
|
||||
+ */
|
||||
+#define GRUB_PKS_CERT_SHA384_GUID \
|
||||
+ (grub_uuid_t) \
|
||||
+ { \
|
||||
@@ -587,6 +576,10 @@ index 000000000..8cc4266c9
|
||||
+ } \
|
||||
+ }
|
||||
+
|
||||
+/*
|
||||
+ * It is derived from EFI_CERT_SHA512_GUID
|
||||
+ * https://github.com/tianocore/edk2-staging/blob/master/MdePkg/Include/Guid/ImageAuthentication.h
|
||||
+ */
|
||||
+#define GRUB_PKS_CERT_SHA512_GUID \
|
||||
+ (grub_uuid_t) \
|
||||
+ { \
|
||||
@@ -597,6 +590,10 @@ index 000000000..8cc4266c9
|
||||
+ } \
|
||||
+ }
|
||||
+
|
||||
+/*
|
||||
+ * It is derived from EFI_CERT_X509_SHA256_GUID
|
||||
+ * https://github.com/tianocore/edk2-staging/blob/master/MdePkg/Include/Guid/ImageAuthentication.h
|
||||
+ */
|
||||
+#define GRUB_PKS_CERT_X509_SHA256_GUID \
|
||||
+ (grub_uuid_t) \
|
||||
+ { \
|
||||
@@ -607,6 +604,10 @@ index 000000000..8cc4266c9
|
||||
+ } \
|
||||
+ }
|
||||
+
|
||||
+/*
|
||||
+ * It is derived from EFI_CERT_X509_SHA384_GUID
|
||||
+ * https://github.com/tianocore/edk2-staging/blob/master/MdePkg/Include/Guid/ImageAuthentication.h
|
||||
+ */
|
||||
+#define GRUB_PKS_CERT_X509_SHA384_GUID \
|
||||
+ (grub_uuid_t) \
|
||||
+ { \
|
||||
@@ -617,6 +618,10 @@ index 000000000..8cc4266c9
|
||||
+ } \
|
||||
+ }
|
||||
+
|
||||
+/*
|
||||
+ * It is derived from EFI_CERT_X509_SHA512_GUID
|
||||
+ * https://github.com/tianocore/edk2-staging/blob/master/MdePkg/Include/Guid/ImageAuthentication.h
|
||||
+ */
|
||||
+#define GRUB_PKS_CERT_X509_SHA512_GUID \
|
||||
+ (grub_uuid_t) \
|
||||
+ { \
|
||||
@@ -641,7 +646,6 @@ index 000000000..8cc4266c9
|
||||
+/* The structure of a PKS.*/
|
||||
+struct grub_pks
|
||||
+{
|
||||
+ grub_uint8_t use_static_keys;
|
||||
+ grub_pks_sd_t *db; /* signature database */
|
||||
+ grub_pks_sd_t *dbx; /* forbidden signature database */
|
||||
+ grub_size_t db_entries; /* size of signature database */
|
||||
@@ -650,22 +654,40 @@ index 000000000..8cc4266c9
|
||||
+
|
||||
+#ifdef __powerpc__
|
||||
+
|
||||
+/* initialization of the Platform Keystore */
|
||||
+grub_err_t grub_platform_keystore_init (void);
|
||||
+/* releasing allocated memory */
|
||||
+void EXPORT_FUNC(grub_release_platform_keystore) (void);
|
||||
+extern grub_uint8_t EXPORT_VAR(grub_use_platform_keystore);
|
||||
+extern grub_pks_t EXPORT_VAR(grub_platform_keystore);
|
||||
+/* Initialization of the Platform Keystore */
|
||||
+grub_err_t grub_pks_keystore_init (void);
|
||||
+/* Free allocated memory */
|
||||
+void EXPORT_FUNC(grub_pks_free_keystore) (void);
|
||||
+extern grub_uint8_t EXPORT_VAR(grub_pks_use_keystore);
|
||||
+extern grub_pks_t EXPORT_VAR(grub_pks_keystore);
|
||||
+
|
||||
+#else
|
||||
+
|
||||
+#define grub_use_platform_keystore 0
|
||||
+grub_pks_t grub_platform_keystore = {0, NULL, NULL, 0, 0};
|
||||
+void grub_release_platform_keystore (void);
|
||||
+#define grub_pks_use_keystore 0
|
||||
+grub_pks_t grub_pks_keystore = {NULL, NULL, 0, 0};
|
||||
+void grub_pks_free_keystore (void);
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
+#endif
|
||||
diff --git a/include/grub/types.h b/include/grub/types.h
|
||||
index 064066e2e1..5542b9aa09 100644
|
||||
--- a/include/grub/types.h
|
||||
+++ b/include/grub/types.h
|
||||
@@ -388,4 +388,13 @@ struct grub_packed_guid
|
||||
} GRUB_PACKED;
|
||||
typedef struct grub_packed_guid grub_packed_guid_t;
|
||||
|
||||
+
|
||||
+#define GRUB_UUID_SIZE 16
|
||||
+typedef struct grub_uuid grub_uuid_t;
|
||||
+/* The structure of a UUID.*/
|
||||
+struct grub_uuid
|
||||
+{
|
||||
+ grub_uint8_t b[GRUB_UUID_SIZE];
|
||||
+};
|
||||
+
|
||||
#endif /* ! GRUB_TYPES_HEADER */
|
||||
--
|
||||
2.47.0
|
||||
2.48.1
|
||||
|
@@ -1,32 +1,35 @@
|
||||
From 350e8d823db1febc2c81635115ef3c4c0f41f3e7 Mon Sep 17 00:00:00 2001
|
||||
From eb82056864ac03155a9dd18adbf1ca1c60dc69b5 Mon Sep 17 00:00:00 2001
|
||||
From: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Date: Tue, 17 Jan 2023 22:38:05 +0530
|
||||
Subject: [PATCH 3/8] appendedsig: The creation of trusted and distrusted lists
|
||||
Date: Tue, 25 Feb 2025 00:06:18 +0530
|
||||
Subject: [PATCH 4/9] appendedsig: The creation of trusted and distrusted lists
|
||||
|
||||
The trusted certificates and binary hashes, distrusted certificates and
|
||||
binary/certificate hashes will be extracted from the platform keystore buffer
|
||||
if Secure Boot is enabled with PKS.
|
||||
In order to verify the integerity of the kernel, the extracted data
|
||||
would be stored in the buffer db and dbx.
|
||||
|
||||
In order to verify the integrity of the kernel, the extracted data
|
||||
needs to be stored stored in the buffer db and dbx.
|
||||
|
||||
The trusted certificates will be extracted from the grub ELFNOTE if Secure Boot is
|
||||
enabled with static key. In order to verify the integerity of the kernel,
|
||||
the extracted data would be stored in the buffer db.
|
||||
the extracted data needs to be stored in the buffer db.
|
||||
|
||||
Note:-
|
||||
|
||||
if the trusted certificate nor binary hash exists in the distrusted list (DBX),
|
||||
rejected it while extracting it from the platform keystore buffer.
|
||||
If neither the trusted certificate nor binary hash exists in the distrusted list (dbx),
|
||||
rejects it while extracting certificate/binary hash from the platform keystore buffer.
|
||||
|
||||
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
|
||||
Tested-by: Nageswara Sastry <rnsastry@linux.ibm.com>
|
||||
Reviewed-by: Avnish Chouhan <avnish@linux.ibm.com>
|
||||
---
|
||||
grub-core/commands/appendedsig/appendedsig.c | 701 +++++++++++++++++--
|
||||
1 file changed, 635 insertions(+), 66 deletions(-)
|
||||
grub-core/commands/appendedsig/appendedsig.c | 617 +++++++++++++++++--
|
||||
grub-core/kern/file.c | 34 +
|
||||
include/grub/file.h | 1 +
|
||||
3 files changed, 590 insertions(+), 62 deletions(-)
|
||||
|
||||
diff --git a/grub-core/commands/appendedsig/appendedsig.c b/grub-core/commands/appendedsig/appendedsig.c
|
||||
index e63ad1ac6..5bb09e349 100644
|
||||
index e63ad1ac64..3df950c00b 100644
|
||||
--- a/grub-core/commands/appendedsig/appendedsig.c
|
||||
+++ b/grub-core/commands/appendedsig/appendedsig.c
|
||||
@@ -33,7 +33,7 @@
|
||||
@@ -34,7 +37,7 @@ index e63ad1ac6..5bb09e349 100644
|
||||
#include <grub/env.h>
|
||||
#include <grub/lockdown.h>
|
||||
-
|
||||
+#include <grub/platform_keystore.h>
|
||||
+#include <grub/powerpc/ieee1275/platform_keystore.h>
|
||||
#include "appendedsig.h"
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
@@ -55,30 +58,30 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+};
|
||||
+
|
||||
+/* Trusted list */
|
||||
+struct grub_database grub_db = {.keys = NULL, .key_entries = 0, .signatures = NULL,
|
||||
+ .signature_size = NULL, .signature_entries = 0};
|
||||
+struct grub_database db = {.keys = NULL, .key_entries = 0, .signatures = NULL,
|
||||
+ .signature_size = NULL, .signature_entries = 0};
|
||||
+
|
||||
+/* Distrusted list */
|
||||
+struct grub_database grub_dbx = {.signatures = NULL, .signature_size = NULL,
|
||||
+ .signature_entries = 0};
|
||||
+struct grub_database dbx = {.signatures = NULL, .signature_size = NULL,
|
||||
+ .signature_entries = 0};
|
||||
|
||||
/*
|
||||
* Force gcry_rsa to be a module dependency.
|
||||
@@ -90,12 +105,263 @@ struct x509_certificate *grub_trusted_key;
|
||||
@@ -89,6 +104,13 @@ struct x509_certificate *grub_trusted_key;
|
||||
* also resolves our concerns about loading from the filesystem.
|
||||
*/
|
||||
extern gcry_pk_spec_t _gcry_pubkey_spec_rsa;
|
||||
|
||||
+extern gcry_md_spec_t _gcry_digest_spec_sha224;
|
||||
+extern gcry_md_spec_t _gcry_digest_spec_sha384;
|
||||
+
|
||||
+/* releasing trusted list memory */
|
||||
+static void grub_release_trusted_list (void);
|
||||
+/* releasing distrusted list memory */
|
||||
+static void grub_release_distrusted_list (void);
|
||||
+
|
||||
+/* Free trusted list memory */
|
||||
+static void free_trusted_list (void);
|
||||
+/* Free distrusted list memory */
|
||||
+static void free_distrusted_list (void);
|
||||
|
||||
static enum
|
||||
{ check_sigs_no = 0,
|
||||
check_sigs_enforce = 1,
|
||||
@@ -96,6 +118,204 @@ static enum
|
||||
check_sigs_forced = 2
|
||||
} check_sigs = check_sigs_no;
|
||||
|
||||
@@ -87,16 +90,16 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+ * generate the hash using determined hashing function.
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_get_hash (const grub_uuid_t *guid, const grub_uint8_t *data, const grub_size_t data_size,
|
||||
+ grub_uint8_t *hash, grub_size_t *hash_size)
|
||||
+get_hash (const grub_uuid_t *guid, const grub_uint8_t *data, const grub_size_t data_size,
|
||||
+ grub_uint8_t *hash, grub_size_t *hash_size)
|
||||
+{
|
||||
+ gcry_md_spec_t *hash_func = NULL;
|
||||
+
|
||||
+ if (guid == NULL)
|
||||
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, "signature data type is null");
|
||||
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, "GUID is null");
|
||||
+
|
||||
+ if (grub_memcmp (guid, &GRUB_PKS_CERT_SHA256_GUID, GRUB_UUID_SIZE) == 0 ||
|
||||
+ grub_memcmp (guid, &GRUB_PKS_CERT_X509_SHA256_GUID, GRUB_UUID_SIZE) == 0)
|
||||
+ grub_memcmp (guid, &GRUB_PKS_CERT_X509_SHA256_GUID, GRUB_UUID_SIZE) == 0)
|
||||
+ hash_func = &_gcry_digest_spec_sha256;
|
||||
+ else if (grub_memcmp (guid, &GRUB_PKS_CERT_SHA384_GUID, GRUB_UUID_SIZE) == 0 ||
|
||||
+ grub_memcmp (guid, &GRUB_PKS_CERT_X509_SHA384_GUID, GRUB_UUID_SIZE) == 0)
|
||||
@@ -105,20 +108,20 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+ grub_memcmp (guid, &GRUB_PKS_CERT_X509_SHA512_GUID, GRUB_UUID_SIZE) == 0)
|
||||
+ hash_func = &_gcry_digest_spec_sha512;
|
||||
+ else
|
||||
+ return GRUB_ERR_UNKNOWN_COMMAND;
|
||||
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, "Unsupported GUID for hash");
|
||||
+
|
||||
+ grub_memset (hash, 0x00, GRUB_MAX_HASH_SIZE);
|
||||
+ grub_memset (hash, 0, GRUB_MAX_HASH_SIZE);
|
||||
+ grub_crypto_hash (hash_func, hash, data, data_size);
|
||||
+ *hash_size = hash_func->mdlen;
|
||||
+
|
||||
+ return GRUB_ERR_NONE;
|
||||
+}
|
||||
+
|
||||
+/* adding the certificate/binary hash into the trusted/distrusted list */
|
||||
+/* Add the certificate/binary hash into the trusted/distrusted list */
|
||||
+static grub_err_t
|
||||
+grub_add_hash (const grub_uint8_t **data, const grub_size_t data_size,
|
||||
+ grub_uint8_t ***signature_list, grub_size_t **signature_size_list,
|
||||
+ grub_size_t *signature_list_entries)
|
||||
+add_hash (const grub_uint8_t **data, const grub_size_t data_size,
|
||||
+ grub_uint8_t ***signature_list, grub_size_t **signature_size_list,
|
||||
+ grub_size_t *signature_list_entries)
|
||||
+{
|
||||
+ grub_uint8_t **signatures = *signature_list;
|
||||
+ grub_size_t *signature_size = *signature_size_list;
|
||||
@@ -127,23 +130,15 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+ if (*data == NULL || data_size == 0)
|
||||
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, "certificate/binary hash data/size is null");
|
||||
+
|
||||
+ if (signatures == NULL && signature_size == NULL)
|
||||
+ {
|
||||
+ signatures = grub_zalloc (sizeof (grub_uint8_t *));
|
||||
+ signature_size = grub_zalloc (sizeof (grub_size_t));
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ signatures = grub_realloc (signatures, sizeof (grub_uint8_t *) * (signature_entries + 1));
|
||||
+ signature_size = grub_realloc (signature_size,
|
||||
+ sizeof (grub_size_t) * (signature_entries + 1));
|
||||
+ }
|
||||
+ signatures = grub_realloc (signatures, sizeof (grub_uint8_t *) * (signature_entries + 1));
|
||||
+ signature_size = grub_realloc (signature_size,
|
||||
+ sizeof (grub_size_t) * (signature_entries + 1));
|
||||
+
|
||||
+ if (signatures == NULL || signature_size == NULL)
|
||||
+ {
|
||||
+ /*
|
||||
+ * allocated memory will be freed by
|
||||
+ * grub_release_trusted_list/grub_release_distrusted_list
|
||||
+ * free_trusted_list/free_distrusted_list
|
||||
+ */
|
||||
+ if (signatures != NULL)
|
||||
+ {
|
||||
@@ -169,8 +164,8 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+ return GRUB_ERR_NONE;
|
||||
+}
|
||||
+
|
||||
+static grub_err_t
|
||||
+grub_is_x509 (const grub_uuid_t *guid)
|
||||
+static int
|
||||
+is_x509 (const grub_uuid_t *guid)
|
||||
+{
|
||||
+ if (grub_memcmp (guid, &GRUB_PKS_CERT_X509_GUID, GRUB_UUID_SIZE) == 0)
|
||||
+ return GRUB_ERR_NONE;
|
||||
@@ -178,9 +173,9 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+ return GRUB_ERR_UNKNOWN_COMMAND;
|
||||
+}
|
||||
+
|
||||
+static grub_err_t
|
||||
+grub_is_cert_match (const struct x509_certificate *distrusted_cert,
|
||||
+ const struct x509_certificate *db_cert)
|
||||
+static int
|
||||
+is_cert_match (const struct x509_certificate *distrusted_cert,
|
||||
+ const struct x509_certificate *db_cert)
|
||||
+{
|
||||
+
|
||||
+ if (grub_memcmp (distrusted_cert->subject, db_cert->subject, db_cert->subject_len) == 0
|
||||
@@ -193,47 +188,44 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * verify the certificate against the certificate from platform keystore buffer's
|
||||
+ * distrusted list, if it is present, return a bad signature.
|
||||
+ * else, no errors.
|
||||
+ * Verify the certificate against the certificate from platform keystore buffer's
|
||||
+ * distrusted list.
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_is_distrusted_cert (const struct x509_certificate *db_cert)
|
||||
+is_distrusted_cert (const struct x509_certificate *db_cert)
|
||||
+{
|
||||
+ grub_err_t rc = GRUB_ERR_NONE;
|
||||
+ grub_size_t i = 0;
|
||||
+ struct x509_certificate *distrusted_cert = NULL;
|
||||
+
|
||||
+ for (i = 0; i < grub_platform_keystore.dbx_entries; i++)
|
||||
+ for (i = 0; i < grub_pks_keystore.dbx_entries; i++)
|
||||
+ {
|
||||
+ if (grub_platform_keystore.dbx[i].data == NULL &&
|
||||
+ grub_platform_keystore.dbx[i].data_size == 0)
|
||||
+ if (grub_pks_keystore.dbx[i].data == NULL)
|
||||
+ continue;
|
||||
+
|
||||
+ if (grub_is_x509 (&grub_platform_keystore.dbx[i].guid) == GRUB_ERR_NONE)
|
||||
+ if (is_x509 (&grub_pks_keystore.dbx[i].guid) == GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ distrusted_cert = grub_zalloc (sizeof (struct x509_certificate));
|
||||
+ if (distrusted_cert == NULL)
|
||||
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
|
||||
+
|
||||
+ rc = parse_x509_certificate (grub_platform_keystore.dbx[i].data,
|
||||
+ grub_platform_keystore.dbx[i].data_size, distrusted_cert);
|
||||
+ rc = parse_x509_certificate (grub_pks_keystore.dbx[i].data,
|
||||
+ grub_pks_keystore.dbx[i].data_size, distrusted_cert);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ grub_free (distrusted_cert);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (grub_is_cert_match (distrusted_cert, db_cert) == GRUB_ERR_NONE)
|
||||
+ if (is_cert_match (distrusted_cert, db_cert) == GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ grub_printf ("Warning: a trusted certificate CN='%s' is ignored "
|
||||
+ "because it is on the distrusted list (dbx).\n", db_cert->subject);
|
||||
+ grub_free (grub_platform_keystore.dbx[i].data);
|
||||
+ grub_memset (&grub_platform_keystore.dbx[i], 0x00,
|
||||
+ sizeof (grub_platform_keystore.dbx[i]));
|
||||
+ grub_free (grub_pks_keystore.dbx[i].data);
|
||||
+ grub_memset (&grub_pks_keystore.dbx[i], 0, sizeof (grub_pks_sd_t));
|
||||
+ certificate_release (distrusted_cert);
|
||||
+ grub_free (distrusted_cert);
|
||||
+ return GRUB_ERR_BAD_SIGNATURE;
|
||||
+ return GRUB_ERR_ACCESS_DENIED;
|
||||
+ }
|
||||
+
|
||||
+ certificate_release (distrusted_cert);
|
||||
@@ -244,10 +236,10 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+ return GRUB_ERR_NONE;
|
||||
+}
|
||||
+
|
||||
+/* adding the certificate into the trusted/distrusted list */
|
||||
+/* Add the certificate into the trusted/distrusted list */
|
||||
+static grub_err_t
|
||||
+grub_add_certificate (const grub_uint8_t *data, const grub_size_t data_size,
|
||||
+ struct grub_database *database, const grub_uint8_t is_db)
|
||||
+add_certificate (const grub_uint8_t *data, const grub_size_t data_size,
|
||||
+ struct grub_database *database, const grub_size_t is_db)
|
||||
+{
|
||||
+ grub_err_t rc = GRUB_ERR_NONE;
|
||||
+ grub_size_t key_entries = database->key_entries;
|
||||
@@ -263,15 +255,15 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+ rc = parse_x509_certificate (data, data_size, cert);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ grub_printf ("Warning: skipping %s certificate (%d)\n",
|
||||
+ (is_db ? "trusted":"distrused"), rc);
|
||||
+ grub_dprintf ("appendedsig", "skipping %s certificate (%d)\n",
|
||||
+ (is_db ? "trusted":"distrusted"), rc);
|
||||
+ grub_free (cert);
|
||||
+ return rc;
|
||||
+ }
|
||||
+
|
||||
+ if (is_db)
|
||||
+ {
|
||||
+ rc = grub_is_distrusted_cert (cert);
|
||||
+ rc = is_distrusted_cert (cert);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ certificate_release (cert);
|
||||
@@ -281,7 +273,7 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+ }
|
||||
+
|
||||
+ grub_dprintf ("appendedsig", "add a %s certificate CN='%s'\n",
|
||||
+ (is_db ? "trusted":"distrused"), cert->subject);
|
||||
+ (is_db ? "trusted":"distrusted"), cert->subject);
|
||||
+
|
||||
+ key_entries++;
|
||||
+ cert->next = database->keys;
|
||||
@@ -290,69 +282,23 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
+static grub_err_t
|
||||
+grub_read_file (const grub_file_t file, grub_uint8_t **data, grub_ssize_t *data_size)
|
||||
+{
|
||||
+ grub_uint8_t *buffer = NULL;
|
||||
+ grub_ssize_t read_size = 0;
|
||||
+ grub_off_t total_read_size = 0;
|
||||
+ grub_off_t file_size = grub_file_size (file);
|
||||
+
|
||||
+ if (file_size == GRUB_FILE_SIZE_UNKNOWN)
|
||||
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
+ N_("could not parse the unknown size of the file."));
|
||||
+
|
||||
+ buffer = grub_zalloc (file_size);
|
||||
+ if (buffer == NULL)
|
||||
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
|
||||
+
|
||||
+ while (total_read_size < file_size)
|
||||
+ {
|
||||
+ read_size = grub_file_read (file, &buffer[total_read_size], file_size - total_read_size);
|
||||
+ if (read_size < 0)
|
||||
+ {
|
||||
+ grub_free (buffer);
|
||||
+ return grub_error (GRUB_ERR_READ_ERROR, N_("unable to read the file"));
|
||||
+ }
|
||||
+
|
||||
+ total_read_size += read_size;
|
||||
+ }
|
||||
+
|
||||
+ *data = buffer;
|
||||
+ *data_size = total_read_size;
|
||||
+
|
||||
+ return GRUB_ERR_NONE;
|
||||
+}
|
||||
+
|
||||
static const char *
|
||||
grub_env_read_sec (struct grub_env_var *var __attribute__((unused)),
|
||||
const char *val __attribute__((unused)))
|
||||
@@ -153,10 +419,7 @@ file_read_all (grub_file_t file, grub_uint8_t **buf, grub_size_t *len)
|
||||
|
||||
while (total_read_size < file_size)
|
||||
{
|
||||
- read_size =
|
||||
- grub_file_read (file, *buf + total_read_size,
|
||||
- file_size - total_read_size);
|
||||
-
|
||||
+ read_size = grub_file_read (file, *buf + total_read_size, file_size - total_read_size);
|
||||
if (read_size < 0)
|
||||
{
|
||||
grub_free (*buf);
|
||||
@@ -267,9 +530,8 @@ grub_verify_appended_signature (const grub_uint8_t *buf, grub_size_t bufsize)
|
||||
@@ -267,9 +487,8 @@ grub_verify_appended_signature (const grub_uint8_t *buf, grub_size_t bufsize)
|
||||
struct pkcs7_signerInfo *si;
|
||||
int i;
|
||||
|
||||
- if (!grub_trusted_key)
|
||||
- return grub_error (GRUB_ERR_BAD_SIGNATURE,
|
||||
- N_("No trusted keys to verify against"));
|
||||
+ if (!grub_db.key_entries)
|
||||
+ if (!db.key_entries)
|
||||
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("No trusted keys to verify against"));
|
||||
|
||||
err = extract_appended_signature (buf, bufsize, &sig);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
@@ -299,17 +561,16 @@ grub_verify_appended_signature (const grub_uint8_t *buf, grub_size_t bufsize)
|
||||
@@ -299,17 +518,16 @@ grub_verify_appended_signature (const grub_uint8_t *buf, grub_size_t bufsize)
|
||||
datasize, i, hash[0], hash[1], hash[2], hash[3]);
|
||||
|
||||
err = GRUB_ERR_BAD_SIGNATURE;
|
||||
@@ -367,7 +313,7 @@ index e63ad1ac6..5bb09e349 100644
|
||||
- grub_free (context);
|
||||
- goto cleanup;
|
||||
- }
|
||||
+ for (pk = grub_db.keys; pk; pk = pk->next)
|
||||
+ for (pk = db.keys; pk; pk = pk->next)
|
||||
+ {
|
||||
+ rc = grub_crypto_rsa_pad (&hashmpi, hash, si->hash, pk->mpis[0]);
|
||||
+ if (rc)
|
||||
@@ -380,14 +326,14 @@ index e63ad1ac6..5bb09e349 100644
|
||||
|
||||
rc = _gcry_pubkey_spec_rsa.verify (0, hashmpi, &si->sig_mpi,
|
||||
pk->mpis, NULL, NULL);
|
||||
@@ -402,16 +663,16 @@ grub_cmd_distrust (grub_command_t cmd __attribute__((unused)),
|
||||
@@ -402,16 +620,16 @@ grub_cmd_distrust (grub_command_t cmd __attribute__((unused)),
|
||||
|
||||
if (cert_num == 1)
|
||||
{
|
||||
- cert = grub_trusted_key;
|
||||
- grub_trusted_key = cert->next;
|
||||
+ cert = grub_db.keys;
|
||||
+ grub_db.keys = cert->next;
|
||||
+ cert = db.keys;
|
||||
+ db.keys = cert->next;
|
||||
|
||||
certificate_release (cert);
|
||||
grub_free (cert);
|
||||
@@ -396,42 +342,41 @@ index e63ad1ac6..5bb09e349 100644
|
||||
i = 2;
|
||||
- prev = grub_trusted_key;
|
||||
- cert = grub_trusted_key->next;
|
||||
+ prev = grub_db.keys;
|
||||
+ cert = grub_db.keys->next;
|
||||
+ prev = db.keys;
|
||||
+ cert = db.keys->next;
|
||||
while (cert)
|
||||
{
|
||||
if (i == cert_num)
|
||||
@@ -464,8 +725,8 @@ grub_cmd_trust (grub_command_t cmd __attribute__((unused)),
|
||||
@@ -464,8 +682,8 @@ grub_cmd_trust (grub_command_t cmd __attribute__((unused)),
|
||||
grub_dprintf ("appendedsig", "Loaded certificate with CN: %s\n",
|
||||
cert->subject);
|
||||
|
||||
- cert->next = grub_trusted_key;
|
||||
- grub_trusted_key = cert;
|
||||
+ cert->next = grub_db.keys;
|
||||
+ grub_db.keys = cert;
|
||||
+ cert->next = db.keys;
|
||||
+ db.keys = cert;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
@@ -479,7 +740,7 @@ grub_cmd_list (grub_command_t cmd __attribute__((unused)),
|
||||
@@ -479,7 +697,7 @@ grub_cmd_list (grub_command_t cmd __attribute__((unused)),
|
||||
int cert_num = 1;
|
||||
grub_size_t i;
|
||||
|
||||
- for (cert = grub_trusted_key; cert; cert = cert->next)
|
||||
+ for (cert = grub_db.keys; cert; cert = cert->next)
|
||||
+ for (cert = db.keys; cert; cert = cert->next)
|
||||
{
|
||||
grub_printf (N_("Certificate %d:\n"), cert_num);
|
||||
|
||||
@@ -577,6 +838,305 @@ static struct grub_fs pseudo_fs = {
|
||||
.fs_read = pseudo_read
|
||||
};
|
||||
@@ -579,6 +797,274 @@ static struct grub_fs pseudo_fs = {
|
||||
|
||||
static grub_command_t cmd_verify, cmd_list, cmd_distrust, cmd_trust;
|
||||
|
||||
+/*
|
||||
+ * verify the trusted certificate against the certificate hashes from platform keystore buffer's
|
||||
+ * distrusted list, if it is present, return a bad signature.
|
||||
+ * else, no errors.
|
||||
+ * Verify the trusted certificate against the certificate hashes from platform keystore buffer's
|
||||
+ * distrusted list.
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_is_distrusted_cert_hash (const grub_uint8_t *data, const grub_size_t data_size)
|
||||
+is_distrusted_cert_hash (const grub_uint8_t *data, const grub_size_t data_size)
|
||||
+{
|
||||
+ grub_err_t rc = GRUB_ERR_NONE;
|
||||
+ grub_size_t i = 0, cert_hash_size = 0;
|
||||
@@ -440,26 +385,25 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+ if (data == NULL || data_size == 0)
|
||||
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, "trusted certificate data/size is null");
|
||||
+
|
||||
+ for (i = 0; i < grub_platform_keystore.dbx_entries; i++)
|
||||
+ for (i = 0; i < grub_pks_keystore.dbx_entries; i++)
|
||||
+ {
|
||||
+ if (grub_platform_keystore.dbx[i].data == NULL &&
|
||||
+ grub_platform_keystore.dbx[i].data_size == 0)
|
||||
+ if (grub_pks_keystore.dbx[i].data == NULL ||
|
||||
+ grub_pks_keystore.dbx[i].data_size == 0)
|
||||
+ continue;
|
||||
+
|
||||
+ rc = grub_get_hash (&grub_platform_keystore.dbx[i].guid, data, data_size,
|
||||
+ cert_hash, &cert_hash_size);
|
||||
+ rc = get_hash (&grub_pks_keystore.dbx[i].guid, data, data_size,
|
||||
+ cert_hash, &cert_hash_size);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ continue;
|
||||
+
|
||||
+ if (cert_hash_size == grub_platform_keystore.dbx[i].data_size &&
|
||||
+ grub_memcmp (grub_platform_keystore.dbx[i].data, cert_hash, cert_hash_size) == 0)
|
||||
+ if (cert_hash_size == grub_pks_keystore.dbx[i].data_size &&
|
||||
+ grub_memcmp (grub_pks_keystore.dbx[i].data, cert_hash, cert_hash_size) == 0)
|
||||
+ {
|
||||
+ grub_printf ("Warning: a trusted certificate (%02x%02x%02x%02x) is ignored "
|
||||
+ "because this certificate hash is on the distrusted list (dbx).\n",
|
||||
+ cert_hash[0], cert_hash[1], cert_hash[2], cert_hash[3]);
|
||||
+ grub_free (grub_platform_keystore.dbx[i].data);
|
||||
+ grub_memset (&grub_platform_keystore.dbx[i], 0x00,
|
||||
+ sizeof (grub_platform_keystore.dbx[i]));
|
||||
+ grub_free (grub_pks_keystore.dbx[i].data);
|
||||
+ grub_memset (&grub_pks_keystore.dbx[i], 0, sizeof (grub_pks_keystore.dbx[i]));
|
||||
+ return GRUB_ERR_BAD_SIGNATURE;
|
||||
+ }
|
||||
+ }
|
||||
@@ -468,31 +412,29 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * verify the trusted binary hash against the platform keystore buffer's
|
||||
+ * distrusted list, if it is present, return a bad signature.
|
||||
+ * else, no errors.
|
||||
+ * Verify the trusted binary hash against the platform keystore buffer's
|
||||
+ * distrusted list.
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_is_distrusted_binary_hash (const grub_uint8_t *binary_hash,
|
||||
+ const grub_size_t binary_hash_size)
|
||||
+is_distrusted_binary_hash (const grub_uint8_t *binary_hash,
|
||||
+ const grub_size_t binary_hash_size)
|
||||
+{
|
||||
+ grub_size_t i = 0;
|
||||
+
|
||||
+ for (i = 0; i < grub_platform_keystore.dbx_entries; i++)
|
||||
+ for (i = 0; i < grub_pks_keystore.dbx_entries; i++)
|
||||
+ {
|
||||
+ if (grub_platform_keystore.dbx[i].data == NULL &&
|
||||
+ grub_platform_keystore.dbx[i].data_size == 0)
|
||||
+ if (grub_pks_keystore.dbx[i].data == NULL ||
|
||||
+ grub_pks_keystore.dbx[i].data_size == 0)
|
||||
+ continue;
|
||||
+
|
||||
+ if (binary_hash_size == grub_platform_keystore.dbx[i].data_size &&
|
||||
+ grub_memcmp (grub_platform_keystore.dbx[i].data, binary_hash, binary_hash_size) == 0)
|
||||
+ if (binary_hash_size == grub_pks_keystore.dbx[i].data_size &&
|
||||
+ grub_memcmp (grub_pks_keystore.dbx[i].data, binary_hash, binary_hash_size) == 0)
|
||||
+ {
|
||||
+ grub_printf ("Warning: a trusted binary hash (%02x%02x%02x%02x) is ignored"
|
||||
+ " because it is on the distrusted list (dbx).\n",
|
||||
+ binary_hash[0], binary_hash[1], binary_hash[2], binary_hash[3]);
|
||||
+ grub_free (grub_platform_keystore.dbx[i].data);
|
||||
+ grub_memset (&grub_platform_keystore.dbx[i], 0x00,
|
||||
+ sizeof (grub_platform_keystore.dbx[i]));
|
||||
+ grub_free (grub_pks_keystore.dbx[i].data);
|
||||
+ grub_memset (&grub_pks_keystore.dbx[i], 0, sizeof(grub_pks_keystore.dbx[i]));
|
||||
+ return GRUB_ERR_BAD_SIGNATURE;
|
||||
+ }
|
||||
+ }
|
||||
@@ -501,28 +443,28 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * extracts the binary hashes from the platform keystore buffer,
|
||||
+ * and adds it to the trusted list if not exists in distrusted list.
|
||||
+ * Extract the binary hashes from the platform keystore buffer,
|
||||
+ * and add it to the trusted list if it does not exist in the distrusted list.
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_add_trusted_binary_hash (const grub_uint8_t **data, const grub_size_t data_size)
|
||||
+add_trusted_binary_hash (const grub_uint8_t **data, const grub_size_t data_size)
|
||||
+{
|
||||
+ grub_err_t rc = GRUB_ERR_NONE;
|
||||
+
|
||||
+ if (*data == NULL || data_size == 0)
|
||||
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, "trusted binary hash data/size is null");
|
||||
+
|
||||
+ rc = grub_is_distrusted_binary_hash (*data, data_size);
|
||||
+ rc = is_distrusted_binary_hash (*data, data_size);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ return rc;
|
||||
+
|
||||
+ rc = grub_add_hash (data, data_size, &grub_db.signatures, &grub_db.signature_size,
|
||||
+ &grub_db.signature_entries);
|
||||
+ rc = add_hash (data, data_size, &db.signatures, &db.signature_size,
|
||||
+ &db.signature_entries);
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
+static grub_err_t
|
||||
+grub_is_hash (const grub_uuid_t *guid)
|
||||
+static int
|
||||
+is_hash (const grub_uuid_t *guid)
|
||||
+{
|
||||
+ /* GUID type of the binary hash */
|
||||
+ if (grub_memcmp (guid, &GRUB_PKS_CERT_SHA256_GUID, GRUB_UUID_SIZE) == 0 ||
|
||||
@@ -540,84 +482,81 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * extracts the x509 certificates/binary hashes from the platform keystore buffer,
|
||||
+ * parses it, and adds it to the trusted list.
|
||||
+ * Extract the x509 certificates/binary hashes from the platform keystore buffer,
|
||||
+ * parse it, and add it to the trusted list.
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_create_trusted_list (void)
|
||||
+create_trusted_list (void)
|
||||
+{
|
||||
+ grub_err_t rc = GRUB_ERR_NONE;
|
||||
+ grub_size_t i = 0;
|
||||
+
|
||||
+ for (i = 0; i < grub_platform_keystore.db_entries; i++)
|
||||
+ for (i = 0; i < grub_pks_keystore.db_entries; i++)
|
||||
+ {
|
||||
+ if (grub_is_hash (&grub_platform_keystore.db[i].guid) == GRUB_ERR_NONE)
|
||||
+ if (is_hash (&grub_pks_keystore.db[i].guid) == GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ rc = grub_add_trusted_binary_hash ((const grub_uint8_t **)
|
||||
+ &grub_platform_keystore.db[i].data,
|
||||
+ grub_platform_keystore.db[i].data_size);
|
||||
+ rc = add_trusted_binary_hash ((const grub_uint8_t **)
|
||||
+ &grub_pks_keystore.db[i].data,
|
||||
+ grub_pks_keystore.db[i].data_size);
|
||||
+ if (rc == GRUB_ERR_OUT_OF_MEMORY)
|
||||
+ return rc;
|
||||
+
|
||||
+ continue;
|
||||
+ }
|
||||
+ else if (grub_is_x509 (&grub_platform_keystore.db[i].guid) == GRUB_ERR_NONE)
|
||||
+ else if (is_x509 (&grub_pks_keystore.db[i].guid) == GRUB_ERR_NONE)
|
||||
+ {
|
||||
+
|
||||
+ rc = grub_is_distrusted_cert_hash (grub_platform_keystore.db[i].data,
|
||||
+ grub_platform_keystore.db[i].data_size);
|
||||
+ rc = is_distrusted_cert_hash (grub_pks_keystore.db[i].data,
|
||||
+ grub_pks_keystore.db[i].data_size);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ continue;
|
||||
+
|
||||
+ rc = grub_add_certificate (grub_platform_keystore.db[i].data,
|
||||
+ grub_platform_keystore.db[i].data_size, &grub_db, 1);
|
||||
+ rc = add_certificate (grub_pks_keystore.db[i].data,
|
||||
+ grub_pks_keystore.db[i].data_size, &db, 1);
|
||||
+ if (rc == GRUB_ERR_OUT_OF_MEMORY)
|
||||
+ return rc;
|
||||
+ else if (rc != GRUB_ERR_NONE)
|
||||
+ continue;
|
||||
+ }
|
||||
+ else
|
||||
+ grub_printf ("Warning: unsupported signature data type and "
|
||||
+ "skipping trusted data (%" PRIuGRUB_SIZE ")\n", i + 1);
|
||||
+ grub_dprintf ("appendedsig", "unsupported signature data type and "
|
||||
+ "skipping trusted data (%" PRIuGRUB_SIZE ")\n", i + 1);
|
||||
+ }
|
||||
+
|
||||
+ return GRUB_ERR_NONE;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * extracts the certificates, certificate/binary hashes out of the platform keystore buffer,
|
||||
+ * and adds it to the distrusted list.
|
||||
+ * Extract the certificates, certificate/binary hashes out of the platform keystore buffer,
|
||||
+ * and add it to the distrusted list.
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_create_distrusted_list (void)
|
||||
+create_distrusted_list (void)
|
||||
+{
|
||||
+ grub_err_t rc = GRUB_ERR_NONE;
|
||||
+ grub_size_t i = 0;
|
||||
+
|
||||
+ for (i = 0; i < grub_platform_keystore.dbx_entries; i++)
|
||||
+ for (i = 0; i < grub_pks_keystore.dbx_entries; i++)
|
||||
+ {
|
||||
+ if (grub_platform_keystore.dbx[i].data != NULL &&
|
||||
+ grub_platform_keystore.dbx[i].data_size > 0)
|
||||
+ if (grub_pks_keystore.dbx[i].data != NULL ||
|
||||
+ grub_pks_keystore.dbx[i].data_size > 0)
|
||||
+ {
|
||||
+ if (grub_is_x509 (&grub_platform_keystore.dbx[i].guid))
|
||||
+ if (is_x509 (&grub_pks_keystore.dbx[i].guid) == GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ rc = grub_add_certificate (grub_platform_keystore.dbx[i].data,
|
||||
+ grub_platform_keystore.dbx[i].data_size, &grub_dbx, 0);
|
||||
+ rc = add_certificate (grub_pks_keystore.dbx[i].data,
|
||||
+ grub_pks_keystore.dbx[i].data_size, &dbx, 0);
|
||||
+ if (rc == GRUB_ERR_OUT_OF_MEMORY)
|
||||
+ return rc;
|
||||
+ }
|
||||
+ else if (grub_is_hash (&grub_platform_keystore.dbx[i].guid) == GRUB_ERR_NONE)
|
||||
+ else if (is_hash (&grub_pks_keystore.dbx[i].guid) == GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ rc = grub_add_hash ((const grub_uint8_t **) &grub_platform_keystore.dbx[i].data,
|
||||
+ grub_platform_keystore.dbx[i].data_size,
|
||||
+ &grub_dbx.signatures, &grub_dbx.signature_size,
|
||||
+ &grub_dbx.signature_entries);
|
||||
+ rc = add_hash ((const grub_uint8_t **) &grub_pks_keystore.dbx[i].data,
|
||||
+ grub_pks_keystore.dbx[i].data_size,
|
||||
+ &dbx.signatures, &dbx.signature_size,
|
||||
+ &dbx.signature_entries);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ return rc;
|
||||
+ }
|
||||
+ else
|
||||
+ grub_printf ("Warning: unsupported signature data type and "
|
||||
+ "skipping distrusted data (%" PRIuGRUB_SIZE ")\n", i + 1);
|
||||
+ grub_dprintf ("appendedsig", "unsupported signature data type and "
|
||||
+ "skipping distrusted data (%" PRIuGRUB_SIZE ")\n", i + 1);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@@ -625,11 +564,11 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * extracts the x509 certificates from the ELF note header,
|
||||
+ * parses it, and adds it to the trusted list.
|
||||
+ * Extract the x509 certificates from the ELF note header,
|
||||
+ * parse it, and add it to the trusted list.
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_build_static_trusted_list (const struct grub_module_header *header, bool mode)
|
||||
+build_static_trusted_list (const struct grub_module_header *header)
|
||||
+{
|
||||
+ grub_err_t err = GRUB_ERR_NONE;
|
||||
+ struct grub_file pseudo_file;
|
||||
@@ -648,86 +587,62 @@ index e63ad1ac6..5bb09e349 100644
|
||||
+ if (err != GRUB_ERR_NONE)
|
||||
+ return err;
|
||||
+
|
||||
+ if (mode)
|
||||
+ {
|
||||
+ err = grub_is_distrusted_cert_hash (cert_data, cert_data_size);
|
||||
+ if (err != GRUB_ERR_NONE)
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ err = grub_add_certificate (cert_data, cert_data_size, &grub_db, mode);
|
||||
+ if (cert_data != NULL)
|
||||
+ grub_free (cert_data);
|
||||
+ err = add_certificate (cert_data, cert_data_size, &db, 1);
|
||||
+ grub_free (cert_data);
|
||||
+
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+/* releasing memory */
|
||||
+static void
|
||||
+grub_release_trusted_list (void)
|
||||
+free_trusted_list (void)
|
||||
+{
|
||||
+ struct x509_certificate *cert;
|
||||
+ grub_size_t i = 0;
|
||||
+
|
||||
+ while (grub_db.keys != NULL)
|
||||
+ while (db.keys != NULL)
|
||||
+ {
|
||||
+ cert = grub_db.keys;
|
||||
+ grub_db.keys = grub_db.keys->next;
|
||||
+ cert = db.keys;
|
||||
+ db.keys = db.keys->next;
|
||||
+ certificate_release (cert);
|
||||
+ grub_free (cert);
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < grub_db.signature_entries; i++)
|
||||
+ grub_free (grub_db.signatures[i]);
|
||||
+ for (i = 0; i < db.signature_entries; i++)
|
||||
+ grub_free (db.signatures[i]);
|
||||
+
|
||||
+ grub_free (grub_db.signatures);
|
||||
+ grub_free (grub_db.signature_size);
|
||||
+ grub_memset (&grub_db, 0x00, sizeof (grub_db));
|
||||
+ grub_free (db.signatures);
|
||||
+ grub_free (db.signature_size);
|
||||
+ grub_memset (&db, 0, sizeof (db));
|
||||
+}
|
||||
+
|
||||
+/* releasing memory */
|
||||
+static void
|
||||
+grub_release_distrusted_list (void)
|
||||
+free_distrusted_list (void)
|
||||
+{
|
||||
+ struct x509_certificate *cert;
|
||||
+ grub_size_t i = 0;
|
||||
+
|
||||
+ while (grub_dbx.keys != NULL)
|
||||
+ while (dbx.keys != NULL)
|
||||
+ {
|
||||
+ cert = grub_dbx.keys;
|
||||
+ grub_dbx.keys = grub_dbx.keys->next;
|
||||
+ cert = dbx.keys;
|
||||
+ dbx.keys = dbx.keys->next;
|
||||
+ certificate_release (cert);
|
||||
+ grub_free (cert);
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < grub_dbx.signature_entries; i++)
|
||||
+ grub_free (grub_dbx.signatures[i]);
|
||||
+ for (i = 0; i < dbx.signature_entries; i++)
|
||||
+ grub_free (dbx.signatures[i]);
|
||||
+
|
||||
+ grub_free (grub_dbx.signatures);
|
||||
+ grub_free (grub_dbx.signature_size);
|
||||
+ grub_memset (&grub_dbx, 0x00, sizeof (grub_dbx));
|
||||
+ grub_free (dbx.signatures);
|
||||
+ grub_free (dbx.signature_size);
|
||||
+ grub_memset (&dbx, 0, sizeof (dbx));
|
||||
+}
|
||||
+
|
||||
+static grub_err_t
|
||||
+grub_load_static_keys (struct grub_module_header *header, bool mode)
|
||||
+{
|
||||
+ int rc = GRUB_ERR_NONE;
|
||||
+
|
||||
+ FOR_MODULES (header)
|
||||
+ {
|
||||
+ /* Not an ELF module, skip. */
|
||||
+ if (header->type != OBJ_TYPE_X509_PUBKEY)
|
||||
+ continue;
|
||||
+ rc = grub_build_static_trusted_list (header, mode);
|
||||
+ }
|
||||
+
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
static grub_command_t cmd_verify, cmd_list, cmd_distrust, cmd_trust;
|
||||
|
||||
GRUB_MOD_INIT (appendedsig)
|
||||
@@ -588,10 +1148,7 @@ GRUB_MOD_INIT (appendedsig)
|
||||
{
|
||||
int rc;
|
||||
@@ -588,10 +1074,7 @@ GRUB_MOD_INIT (appendedsig)
|
||||
if (grub_is_lockdown () == GRUB_LOCKDOWN_ENABLED)
|
||||
check_sigs = check_sigs_forced;
|
||||
|
||||
@@ -739,7 +654,7 @@ index e63ad1ac6..5bb09e349 100644
|
||||
grub_env_export ("check_appended_signatures");
|
||||
|
||||
rc = asn1_init ();
|
||||
@@ -599,40 +1156,52 @@ GRUB_MOD_INIT (appendedsig)
|
||||
@@ -599,40 +1082,50 @@ GRUB_MOD_INIT (appendedsig)
|
||||
grub_fatal ("Error initing ASN.1 data structures: %d: %s\n", rc,
|
||||
asn1_strerror (rc));
|
||||
|
||||
@@ -777,55 +692,107 @@ index e63ad1ac6..5bb09e349 100644
|
||||
- pk->next = grub_trusted_key;
|
||||
- grub_trusted_key = pk;
|
||||
- }
|
||||
+ if (!grub_use_platform_keystore && check_sigs == check_sigs_forced)
|
||||
+ if (!grub_pks_use_keystore && check_sigs == check_sigs_forced)
|
||||
+ {
|
||||
+ rc = grub_load_static_keys (header, 0);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ FOR_MODULES (header)
|
||||
+ {
|
||||
+ grub_release_trusted_list ();
|
||||
+ grub_error (rc, "static trusted list creation failed");
|
||||
+ }
|
||||
+ else
|
||||
+ grub_printf ("appendedsig: the trusted list now has %" PRIuGRUB_SIZE " static keys\n",
|
||||
+ grub_db.key_entries);
|
||||
+ }
|
||||
+ else if (grub_use_platform_keystore && check_sigs == check_sigs_forced)
|
||||
+ {
|
||||
+ if (grub_platform_keystore.use_static_keys == 1)
|
||||
+ {
|
||||
+ grub_printf ("Warning: db variable not available and using a static key"
|
||||
+ "as a default key in trusted list");
|
||||
+ rc = grub_load_static_keys (header, 1);
|
||||
+ }
|
||||
+ else
|
||||
+ rc = grub_create_trusted_list ();
|
||||
+ /* Not an ELF module, skip. */
|
||||
+ if (header->type != OBJ_TYPE_X509_PUBKEY)
|
||||
+ continue;
|
||||
+
|
||||
+ rc = build_static_trusted_list (header);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ free_trusted_list ();
|
||||
+ grub_error (rc, "static trusted list creation failed");
|
||||
+ }
|
||||
+ else
|
||||
+ grub_printf ("appendedsig: the trusted list now has %" PRIuGRUB_SIZE " static keys\n",
|
||||
+ db.key_entries);
|
||||
+ }
|
||||
+ }
|
||||
+ else if (grub_pks_use_keystore && check_sigs == check_sigs_forced)
|
||||
+ {
|
||||
+ rc = create_trusted_list ();
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ grub_release_trusted_list ();
|
||||
+ free_trusted_list ();
|
||||
+ grub_error (rc, "trusted list creation failed");
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ rc = grub_create_distrusted_list ();
|
||||
+ rc = create_distrusted_list ();
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ grub_release_trusted_list ();
|
||||
+ grub_release_distrusted_list ();
|
||||
+ free_trusted_list ();
|
||||
+ free_distrusted_list ();
|
||||
+ grub_error (rc, "distrusted list creation failed");
|
||||
+ }
|
||||
+ else
|
||||
+ grub_printf ("appendedsig: the trusted list now has %" PRIuGRUB_SIZE " keys.\n"
|
||||
+ "appendedsig: the distrusted list now has %" PRIuGRUB_SIZE " keys.\n",
|
||||
+ grub_db.signature_entries + grub_db.key_entries,
|
||||
+ grub_dbx.signature_entries);
|
||||
+ db.signature_entries + db.key_entries, dbx.signature_entries);
|
||||
+ }
|
||||
+
|
||||
+ grub_release_platform_keystore ();
|
||||
+ grub_pks_free_keystore ();
|
||||
+ }
|
||||
|
||||
cmd_trust =
|
||||
grub_register_command ("trust_certificate", grub_cmd_trust,
|
||||
diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c
|
||||
index 6e7efe89ab..7217a6ea7f 100644
|
||||
--- a/grub-core/kern/file.c
|
||||
+++ b/grub-core/kern/file.c
|
||||
@@ -231,3 +231,37 @@ grub_file_seek (grub_file_t file, grub_off_t offset)
|
||||
|
||||
return old;
|
||||
}
|
||||
+
|
||||
+grub_err_t
|
||||
+grub_read_file (const grub_file_t file, grub_uint8_t **data, grub_ssize_t *data_size)
|
||||
+{
|
||||
+ grub_uint8_t *buffer = NULL;
|
||||
+ grub_ssize_t read_size = 0;
|
||||
+ grub_off_t total_read_size = 0;
|
||||
+ grub_off_t file_size = grub_file_size (file);
|
||||
+
|
||||
+ if (file_size == GRUB_FILE_SIZE_UNKNOWN)
|
||||
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
+ N_("could not determine the size of the file."));
|
||||
+
|
||||
+ buffer = grub_zalloc (file_size);
|
||||
+ if (buffer == NULL)
|
||||
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
|
||||
+
|
||||
+ while (total_read_size < file_size)
|
||||
+ {
|
||||
+ read_size = grub_file_read (file, &buffer[total_read_size], file_size - total_read_size);
|
||||
+ if (read_size < 0)
|
||||
+ {
|
||||
+ grub_free (buffer);
|
||||
+ return grub_error (GRUB_ERR_READ_ERROR, N_("unable to read the file"));
|
||||
+ }
|
||||
+
|
||||
+ total_read_size += read_size;
|
||||
+ }
|
||||
+
|
||||
+ *data = buffer;
|
||||
+ *data_size = total_read_size;
|
||||
+
|
||||
+ return GRUB_ERR_NONE;
|
||||
+}
|
||||
diff --git a/include/grub/file.h b/include/grub/file.h
|
||||
index f9484f8d69..804d512231 100644
|
||||
--- a/include/grub/file.h
|
||||
+++ b/include/grub/file.h
|
||||
@@ -219,6 +219,7 @@ grub_ssize_t EXPORT_FUNC(grub_file_read) (grub_file_t file, void *buf,
|
||||
grub_size_t len);
|
||||
grub_off_t EXPORT_FUNC(grub_file_seek) (grub_file_t file, grub_off_t offset);
|
||||
grub_err_t EXPORT_FUNC(grub_file_close) (grub_file_t file);
|
||||
+grub_err_t EXPORT_FUNC(grub_read_file) (const grub_file_t file, grub_uint8_t **data, grub_ssize_t *data_size);
|
||||
|
||||
/* Return value of grub_file_size() in case file size is unknown. */
|
||||
#define GRUB_FILE_SIZE_UNKNOWN 0xffffffffffffffffULL
|
||||
--
|
||||
2.47.0
|
||||
2.48.1
|
||||
|
@@ -1,28 +0,0 @@
|
||||
From 7717cd9c27f18703287403af1a955588e3d0261f Mon Sep 17 00:00:00 2001
|
||||
From: mamatha <mainamdar@in.ibm.com>
|
||||
Date: Sat, 24 Sep 2022 11:22:39 +0530
|
||||
Subject: [PATCH 4/4] ofpath controller name update
|
||||
|
||||
patch to update ofpath controller name
|
||||
|
||||
Signed-off-by: mamatha <mainamdar@in.ibm.com>
|
||||
---
|
||||
grub-core/osdep/linux/ofpath.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c
|
||||
index 212782d3f..7d31cfd0f 100644
|
||||
--- a/grub-core/osdep/linux/ofpath.c
|
||||
+++ b/grub-core/osdep/linux/ofpath.c
|
||||
@@ -483,6 +483,8 @@ of_path_get_nvmeof_adapter_info(char* sysfs_path,
|
||||
buf3=strchr(buf2,'-')+1;
|
||||
buf3=strchr(buf3,'-')+1;
|
||||
nvmeof_info->target_wwpn = buf3;
|
||||
+ buf3=strchr(buf3,'x')+1;
|
||||
+ nvmeof_info->target_wwpn = buf3;
|
||||
buf3 = strchr(nvmeof_info->target_wwpn,',');
|
||||
*buf3 = '\0';
|
||||
|
||||
--
|
||||
2.35.3
|
||||
|
@@ -1,51 +1,40 @@
|
||||
From 5bff27911bb6575b80b5decf5364b7e6bde801d3 Mon Sep 17 00:00:00 2001
|
||||
From bd776f35de3afbbe818c0531be9c9754797f2c08 Mon Sep 17 00:00:00 2001
|
||||
From: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Date: Wed, 18 Jan 2023 23:04:38 +0530
|
||||
Subject: [PATCH 4/8] appendedsig: While verifying the kernel, use trusted and
|
||||
Date: Tue, 25 Feb 2025 01:18:35 +0530
|
||||
Subject: [PATCH 5/9] appendedsig: While verifying the kernel, use trusted and
|
||||
distrusted lists
|
||||
|
||||
To verify the kernel's, the trusted key will be used from
|
||||
the trusted key list. If it fails, verify it against the list of hashes
|
||||
that are distrusted and trusted.
|
||||
To verify the kernel's signature: verify the kernel binary against lists of binary hashes
|
||||
that are either distrusted or trusted. If it is not list in either trusted or distrusted hashes list
|
||||
then the trusted keys from the trusted key list are used to verify the signature.
|
||||
|
||||
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
|
||||
Tested-by: Nageswara Sastry <rnsastry@linux.ibm.com>
|
||||
Reviewed-by: Avnish Chouhan <avnish@linux.ibm.com>
|
||||
---
|
||||
grub-core/commands/appendedsig/appendedsig.c | 187 +++++++++++++------
|
||||
1 file changed, 131 insertions(+), 56 deletions(-)
|
||||
grub-core/commands/appendedsig/appendedsig.c | 199 +++++++++++++------
|
||||
1 file changed, 139 insertions(+), 60 deletions(-)
|
||||
|
||||
diff --git a/grub-core/commands/appendedsig/appendedsig.c b/grub-core/commands/appendedsig/appendedsig.c
|
||||
index 5bb09e349..f9638220e 100644
|
||||
index 3df950c00b..b6daccd3d7 100644
|
||||
--- a/grub-core/commands/appendedsig/appendedsig.c
|
||||
+++ b/grub-core/commands/appendedsig/appendedsig.c
|
||||
@@ -36,6 +36,10 @@
|
||||
#include <grub/platform_keystore.h>
|
||||
#include "appendedsig.h"
|
||||
|
||||
+#define SHA256_LEN 32
|
||||
+#define SHA384_LEN 48
|
||||
+#define SHA512_LEN 64
|
||||
+
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
const char magic[] = "~Module signature appended~\n";
|
||||
@@ -516,6 +520,80 @@ extract_appended_signature (const grub_uint8_t *buf, grub_size_t bufsize,
|
||||
@@ -473,6 +473,83 @@ extract_appended_signature (const grub_uint8_t *buf, grub_size_t bufsize,
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
+static grub_err_t
|
||||
+grub_get_binary_hash (const grub_size_t binary_hash_size, const grub_uint8_t *data,
|
||||
+ const grub_size_t data_size, grub_uint8_t *hash, grub_size_t *hash_size)
|
||||
+get_binary_hash (const grub_size_t binary_hash_size, const grub_uint8_t *data,
|
||||
+ const grub_size_t data_size, grub_uint8_t *hash, grub_size_t *hash_size)
|
||||
+{
|
||||
+ grub_uuid_t guid = { 0 };
|
||||
+
|
||||
+ /* support SHA256, SHA384 and SHA512 for binary hash */
|
||||
+ if (binary_hash_size == SHA256_LEN)
|
||||
+ if (binary_hash_size == 32)
|
||||
+ grub_memcpy (&guid, &GRUB_PKS_CERT_SHA256_GUID, GRUB_UUID_SIZE);
|
||||
+ else if (binary_hash_size == SHA384_LEN)
|
||||
+ else if (binary_hash_size == 48)
|
||||
+ grub_memcpy (&guid, &GRUB_PKS_CERT_SHA384_GUID, GRUB_UUID_SIZE);
|
||||
+ else if (binary_hash_size == SHA512_LEN)
|
||||
+ else if (binary_hash_size == 64)
|
||||
+ grub_memcpy (&guid, &GRUB_PKS_CERT_SHA512_GUID, GRUB_UUID_SIZE);
|
||||
+ else
|
||||
+ {
|
||||
@@ -54,48 +43,50 @@ index 5bb09e349..f9638220e 100644
|
||||
+ return GRUB_ERR_UNKNOWN_COMMAND;
|
||||
+ }
|
||||
+
|
||||
+ return grub_get_hash (&guid, data, data_size, hash, hash_size);
|
||||
+ return get_hash (&guid, data, data_size, hash, hash_size);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * verify binary hash against the list of binary hashes that are distrusted
|
||||
+ * Verify binary hash against the list of binary hashes that are distrusted
|
||||
+ * and trusted.
|
||||
+ * The following errors can occur:
|
||||
+ * - GRUB_ERR_BAD_SIGNATURE: indicates that the hash is distrusted.
|
||||
+ * - GRUB_ERR_NONE: the hash is trusted, since it was found in the trusted hashes list
|
||||
+ * - GRUB_ERR_EOF: the hash could not be found in the hashes list
|
||||
+ */
|
||||
+static grub_err_t
|
||||
+grub_verify_binary_hash (const grub_uint8_t *data, const grub_size_t data_size)
|
||||
+verify_binary_hash (const grub_uint8_t *data, const grub_size_t data_size)
|
||||
+{
|
||||
+ grub_err_t rc = GRUB_ERR_NONE;
|
||||
+ grub_size_t i = 0, hash_size = 0;
|
||||
+ grub_uint8_t hash[GRUB_MAX_HASH_SIZE] = { 0 };
|
||||
+
|
||||
+ for (i = 0; i < grub_dbx.signature_entries; i++)
|
||||
+ for (i = 0; i < dbx.signature_entries; i++)
|
||||
+ {
|
||||
+ rc = grub_get_binary_hash (grub_dbx.signature_size[i], data, data_size,
|
||||
+ hash, &hash_size);
|
||||
+ rc = get_binary_hash (dbx.signature_size[i], data, data_size, hash, &hash_size);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ continue;
|
||||
+
|
||||
+ if (hash_size == grub_dbx.signature_size[i] &&
|
||||
+ grub_memcmp (grub_dbx.signatures[i], hash, hash_size) == 0)
|
||||
+ if (hash_size == dbx.signature_size[i] &&
|
||||
+ grub_memcmp (dbx.signatures[i], hash, hash_size) == 0)
|
||||
+ {
|
||||
+ grub_dprintf ("appendedsig", "the binary hash (%02x%02x%02x%02x) was listed "
|
||||
+ "as distrusted\n", hash[0], hash[1], hash[2], hash[3]);
|
||||
+ grub_dprintf ("appendedsig", "the binary hash (%02x%02x%02x%02x) was listed as distrusted\n",
|
||||
+ hash[0], hash[1], hash[2], hash[3]);
|
||||
+ return GRUB_ERR_BAD_SIGNATURE;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < grub_db.signature_entries; i++)
|
||||
+ for (i = 0; i < db.signature_entries; i++)
|
||||
+ {
|
||||
+ rc = grub_get_binary_hash (grub_db.signature_size[i], data, data_size,
|
||||
+ hash, &hash_size);
|
||||
+ rc = get_binary_hash (db.signature_size[i], data, data_size, hash, &hash_size);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ continue;
|
||||
+
|
||||
+ if (hash_size == grub_db.signature_size[i] &&
|
||||
+ grub_memcmp (grub_db.signatures[i], hash, hash_size) == 0)
|
||||
+ if (hash_size == db.signature_size[i] &&
|
||||
+ grub_memcmp (db.signatures[i], hash, hash_size) == 0)
|
||||
+ {
|
||||
+ grub_dprintf ("appendedsig", "verified with a trusted binary hash "
|
||||
+ "(%02x%02x%02x%02x)\n", hash[0], hash[1], hash[2], hash[3]);
|
||||
+ grub_dprintf ("appendedsig", "verified with a trusted binary hash (%02x%02x%02x%02x)\n",
|
||||
+ hash[0], hash[1], hash[2], hash[3]);
|
||||
+ return GRUB_ERR_NONE;
|
||||
+ }
|
||||
+ }
|
||||
@@ -103,15 +94,16 @@ index 5bb09e349..f9638220e 100644
|
||||
+ return GRUB_ERR_EOF;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * verify the kernel's integrity, the trusted key will be used from
|
||||
+ * Verify the kernel's integrity, the trusted key will be used from
|
||||
+ * the trusted key list. If it fails, verify it against the list of binary hashes
|
||||
+ * that are distrusted and trusted.
|
||||
+ */
|
||||
static grub_err_t
|
||||
grub_verify_appended_signature (const grub_uint8_t *buf, grub_size_t bufsize)
|
||||
{
|
||||
@@ -525,12 +603,12 @@ grub_verify_appended_signature (const grub_uint8_t *buf, grub_size_t bufsize)
|
||||
@@ -482,12 +559,12 @@ grub_verify_appended_signature (const grub_uint8_t *buf, grub_size_t bufsize)
|
||||
unsigned char *hash;
|
||||
gcry_mpi_t hashmpi;
|
||||
gcry_err_code_t rc;
|
||||
@@ -121,20 +113,24 @@ index 5bb09e349..f9638220e 100644
|
||||
struct pkcs7_signerInfo *si;
|
||||
int i;
|
||||
|
||||
- if (!grub_db.key_entries)
|
||||
+ if (!grub_db.key_entries && !grub_db.signature_entries)
|
||||
- if (!db.key_entries)
|
||||
+ if (!db.key_entries && !db.signature_entries)
|
||||
return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("No trusted keys to verify against"));
|
||||
|
||||
err = extract_appended_signature (buf, bufsize, &sig);
|
||||
@@ -538,70 +616,67 @@ grub_verify_appended_signature (const grub_uint8_t *buf, grub_size_t bufsize)
|
||||
@@ -495,71 +572,73 @@ grub_verify_appended_signature (const grub_uint8_t *buf, grub_size_t bufsize)
|
||||
return err;
|
||||
|
||||
datasize = bufsize - sig.signature_len;
|
||||
-
|
||||
- for (i = 0; i < sig.pkcs7.signerInfo_count; i++)
|
||||
+ /* checking kernel binary hash is presents in trusted list (db)/distrusted list (dbx) */
|
||||
+ err = grub_verify_binary_hash (buf, datasize);
|
||||
+ if (err == GRUB_ERR_EOF)
|
||||
+ err = verify_binary_hash (buf, datasize);
|
||||
+ if (err != GRUB_ERR_EOF && err != GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ err = grub_error (err, N_("failed to verify binary-hash/signature with any trusted binary-hash/key\n"));
|
||||
+ return err;
|
||||
+ }
|
||||
+ else if (err == GRUB_ERR_EOF)
|
||||
{
|
||||
- /* This could be optimised in a couple of ways:
|
||||
- - we could only compute hashes once per hash type
|
||||
@@ -156,15 +152,21 @@ index 5bb09e349..f9638220e 100644
|
||||
- datasize, i, hash[0], hash[1], hash[2], hash[3]);
|
||||
-
|
||||
- err = GRUB_ERR_BAD_SIGNATURE;
|
||||
- for (pk = grub_db.keys; pk; pk = pk->next)
|
||||
+ /* verifying kernel binary signature using trusted keys from trusted list (db) */
|
||||
- for (pk = db.keys; pk; pk = pk->next)
|
||||
+ /* Binary hash was not found in trusted and distrusted list: check signature now */
|
||||
+ for (i = 0; i < sig.pkcs7.signerInfo_count; i++)
|
||||
{
|
||||
- rc = grub_crypto_rsa_pad (&hashmpi, hash, si->hash, pk->mpis[0]);
|
||||
- if (rc)
|
||||
+ /*
|
||||
+ * This could be optimised in a couple of ways:
|
||||
+ * - we could only compute hashes once per hash type
|
||||
+ * - we could track signer information and only verify where IDs match
|
||||
+ * For now we do the naive O(db.keys * pkcs7 signers) approach.
|
||||
+ */
|
||||
+ si = &sig.pkcs7.signerInfos[i];
|
||||
+ context = grub_zalloc (si->hash->contextsize);
|
||||
+ if (!context)
|
||||
+ if (context == NULL)
|
||||
+ return grub_errno;
|
||||
+
|
||||
+ si->hash->init (context);
|
||||
@@ -177,14 +179,14 @@ index 5bb09e349..f9638220e 100644
|
||||
+ datasize, i, hash[0], hash[1], hash[2], hash[3]);
|
||||
+
|
||||
+ err = GRUB_ERR_BAD_SIGNATURE;
|
||||
+ for (cert = grub_db.keys; cert; cert = cert->next)
|
||||
+ for (cert = db.keys; cert; cert = cert->next)
|
||||
{
|
||||
- err = grub_error (GRUB_ERR_BAD_SIGNATURE,
|
||||
- N_("Error padding hash for RSA verification: %d"), rc);
|
||||
- grub_free (context);
|
||||
- goto cleanup;
|
||||
+ rc = grub_crypto_rsa_pad (&hashmpi, hash, si->hash, cert->mpis[0]);
|
||||
+ if (rc)
|
||||
+ if (rc != 0)
|
||||
+ {
|
||||
+ err = grub_error (GRUB_ERR_BAD_SIGNATURE,
|
||||
+ N_("Error padding hash for RSA verification: %d"), rc);
|
||||
@@ -195,7 +197,6 @@ index 5bb09e349..f9638220e 100644
|
||||
+
|
||||
+ rc = _gcry_pubkey_spec_rsa.verify (0, hashmpi, &si->sig_mpi, cert->mpis, NULL, NULL);
|
||||
+ gcry_mpi_release (hashmpi);
|
||||
+
|
||||
+ if (rc == 0)
|
||||
+ {
|
||||
+ grub_dprintf ("appendedsig", "verify signer %d with key '%s' succeeded\n",
|
||||
@@ -207,7 +208,7 @@ index 5bb09e349..f9638220e 100644
|
||||
+ grub_dprintf ("appendedsig", "verify signer %d with key '%s' failed with %d\n",
|
||||
+ i, cert->subject, rc);
|
||||
}
|
||||
|
||||
-
|
||||
- rc = _gcry_pubkey_spec_rsa.verify (0, hashmpi, &si->sig_mpi,
|
||||
- pk->mpis, NULL, NULL);
|
||||
- gcry_mpi_release (hashmpi);
|
||||
@@ -227,27 +228,28 @@ index 5bb09e349..f9638220e 100644
|
||||
- }
|
||||
-
|
||||
- grub_free (context);
|
||||
+ grub_free (context);
|
||||
|
||||
-
|
||||
- if (err == GRUB_ERR_NONE)
|
||||
- break;
|
||||
+ grub_free (context);
|
||||
+ if (err == GRUB_ERR_NONE)
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
- /* If we didn't verify, provide a neat message */
|
||||
if (err != GRUB_ERR_NONE)
|
||||
- err = grub_error (GRUB_ERR_BAD_SIGNATURE,
|
||||
- N_("Failed to verify signature against a trusted key"));
|
||||
+ grub_printf ("appendedsig: failed to verify signature with any trusted key\n");
|
||||
-
|
||||
-cleanup:
|
||||
- pkcs7_signedData_release (&sig.pkcs7);
|
||||
+ err = grub_error (err, N_("failed to verify signature with any trusted key\n"));
|
||||
+ else
|
||||
+ grub_printf ("appendedsig: successfully verified the signature with a trusted key\n");
|
||||
|
||||
-cleanup:
|
||||
pkcs7_signedData_release (&sig.pkcs7);
|
||||
|
||||
return err;
|
||||
}
|
||||
--
|
||||
2.47.0
|
||||
2.48.1
|
||||
|
109
0006-powerpc_ieee1275-set-use_static_keys-flag.patch
Normal file
109
0006-powerpc_ieee1275-set-use_static_keys-flag.patch
Normal file
@@ -0,0 +1,109 @@
|
||||
From eeb78a4bd82a1c83e3bbe5a4faf9b2c2e8023445 Mon Sep 17 00:00:00 2001
|
||||
From: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Date: Tue, 25 Feb 2025 01:45:35 +0530
|
||||
Subject: [PATCH 6/9] powerpc_ieee1275: set use_static_keys flag
|
||||
|
||||
Introduce the use_static_keys flag to indicate that static keys are to be used
|
||||
rather than keys from the PKS storage's DB variable. This variable is set when
|
||||
Secure Boot is enabled with PKS but the DB variable is not present in the PKS storage.
|
||||
The appendedsig module would use this variable to extract the default DB keys from
|
||||
the ELF note and store the keys found there in the trustedlist.
|
||||
|
||||
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
|
||||
Reviewed-by: Avnish Chouhan <avnish@linux.ibm.com>
|
||||
---
|
||||
.../kern/powerpc/ieee1275/platform_keystore.c | 15 ++++++++++++++-
|
||||
grub-core/term/tparm.c | 1 -
|
||||
include/grub/powerpc/ieee1275/platform_keystore.h | 11 ++++++-----
|
||||
include/grub/types.h | 2 ++
|
||||
4 files changed, 22 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/grub-core/kern/powerpc/ieee1275/platform_keystore.c b/grub-core/kern/powerpc/ieee1275/platform_keystore.c
|
||||
index ea9f27eb22..81e40632b2 100644
|
||||
--- a/grub-core/kern/powerpc/ieee1275/platform_keystore.c
|
||||
+++ b/grub-core/kern/powerpc/ieee1275/platform_keystore.c
|
||||
@@ -34,7 +34,11 @@
|
||||
/* Platform Keystore */
|
||||
static grub_size_t pks_max_object_size;
|
||||
grub_uint8_t grub_pks_use_keystore = 0;
|
||||
-grub_pks_t grub_pks_keystore = { .db = NULL, .dbx = NULL, .db_entries = 0, .dbx_entries = 0 };
|
||||
+grub_pks_t grub_pks_keystore = { .db = NULL,
|
||||
+ .dbx = NULL,
|
||||
+ .db_entries = 0,
|
||||
+ .dbx_entries = 0,
|
||||
+ .use_static_keys = false };
|
||||
|
||||
/* Convert the esl data into the ESL */
|
||||
static grub_esl_t *
|
||||
@@ -315,6 +319,15 @@ grub_pks_keystore_init (void)
|
||||
grub_memset (&grub_pks_keystore, 0, sizeof (grub_pks_t));
|
||||
/* DB */
|
||||
rc = read_secure_boot_variables (0, DB, &grub_pks_keystore.db, &grub_pks_keystore.db_entries);
|
||||
+ if (rc == PKS_OBJECT_NOT_FOUND)
|
||||
+ {
|
||||
+ rc = GRUB_ERR_NONE;
|
||||
+ /*
|
||||
+ * DB variable won't be available by default in PKS.
|
||||
+ * So, it will load the Default Keys from ELF Note */
|
||||
+ grub_pks_keystore.use_static_keys = true;
|
||||
+ }
|
||||
+
|
||||
if (rc == GRUB_ERR_NONE)
|
||||
{
|
||||
/* DBX */
|
||||
diff --git a/grub-core/term/tparm.c b/grub-core/term/tparm.c
|
||||
index fb5b15a88d..f2db325f6e 100644
|
||||
--- a/grub-core/term/tparm.c
|
||||
+++ b/grub-core/term/tparm.c
|
||||
@@ -46,7 +46,6 @@
|
||||
/*
|
||||
* Common/troublesome character definitions
|
||||
*/
|
||||
-typedef char grub_bool_t;
|
||||
#ifndef FALSE
|
||||
# define FALSE (0)
|
||||
#endif
|
||||
diff --git a/include/grub/powerpc/ieee1275/platform_keystore.h b/include/grub/powerpc/ieee1275/platform_keystore.h
|
||||
index 0641adb0f1..870fb8cc51 100644
|
||||
--- a/include/grub/powerpc/ieee1275/platform_keystore.h
|
||||
+++ b/include/grub/powerpc/ieee1275/platform_keystore.h
|
||||
@@ -199,10 +199,11 @@ struct grub_pks_sd
|
||||
/* The structure of a PKS.*/
|
||||
struct grub_pks
|
||||
{
|
||||
- grub_pks_sd_t *db; /* signature database */
|
||||
- grub_pks_sd_t *dbx; /* forbidden signature database */
|
||||
- grub_size_t db_entries; /* size of signature database */
|
||||
- grub_size_t dbx_entries; /* size of forbidden signature database */
|
||||
+ grub_pks_sd_t *db; /* signature database */
|
||||
+ grub_pks_sd_t *dbx; /* forbidden signature database */
|
||||
+ grub_size_t db_entries; /* size of signature database */
|
||||
+ grub_size_t dbx_entries; /* size of forbidden signature database */
|
||||
+ grub_bool_t use_static_keys;/* flag to indicate use of static keys */
|
||||
} GRUB_PACKED;
|
||||
|
||||
#ifdef __powerpc__
|
||||
@@ -217,7 +218,7 @@ extern grub_pks_t EXPORT_VAR(grub_pks_keystore);
|
||||
#else
|
||||
|
||||
#define grub_pks_use_keystore 0
|
||||
-grub_pks_t grub_pks_keystore = {NULL, NULL, 0, 0};
|
||||
+grub_pks_t grub_pks_keystore = {NULL, NULL, 0, 0, false};
|
||||
void grub_pks_free_keystore (void);
|
||||
|
||||
#endif
|
||||
diff --git a/include/grub/types.h b/include/grub/types.h
|
||||
index 5542b9aa09..573a614fa6 100644
|
||||
--- a/include/grub/types.h
|
||||
+++ b/include/grub/types.h
|
||||
@@ -397,4 +397,6 @@ struct grub_uuid
|
||||
grub_uint8_t b[GRUB_UUID_SIZE];
|
||||
};
|
||||
|
||||
+typedef char grub_bool_t;
|
||||
+
|
||||
#endif /* ! GRUB_TYPES_HEADER */
|
||||
--
|
||||
2.48.1
|
||||
|
111
0007-appendedsig-Reads-the-default-DB-keys-from-ELF-Note.patch
Normal file
111
0007-appendedsig-Reads-the-default-DB-keys-from-ELF-Note.patch
Normal file
@@ -0,0 +1,111 @@
|
||||
From 9dce8958d674c09a93c893a5ef36807e6f286c45 Mon Sep 17 00:00:00 2001
|
||||
From: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Date: Tue, 25 Feb 2025 02:20:20 +0530
|
||||
Subject: [PATCH 7/9] appendedsig: Reads the default DB keys from ELF Note
|
||||
|
||||
If Secure Boot is enabled with PKS and the use_static_keys flag is set,
|
||||
then read the DB default keys from the ELF note and store them in the trusted list buffer.
|
||||
|
||||
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
|
||||
Reviewed-by: Avnish Chouhan <avnish@linux.ibm.com>
|
||||
---
|
||||
grub-core/commands/appendedsig/appendedsig.c | 56 ++++++++++++++------
|
||||
1 file changed, 40 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/grub-core/commands/appendedsig/appendedsig.c b/grub-core/commands/appendedsig/appendedsig.c
|
||||
index b6daccd3d7..3cbe51ec13 100644
|
||||
--- a/grub-core/commands/appendedsig/appendedsig.c
|
||||
+++ b/grub-core/commands/appendedsig/appendedsig.c
|
||||
@@ -1073,7 +1073,7 @@ create_distrusted_list (void)
|
||||
* parse it, and add it to the trusted list.
|
||||
*/
|
||||
static grub_err_t
|
||||
-build_static_trusted_list (const struct grub_module_header *header)
|
||||
+build_static_trusted_list (const struct grub_module_header *header, const grub_bool_t is_pks)
|
||||
{
|
||||
grub_err_t err = GRUB_ERR_NONE;
|
||||
struct grub_file pseudo_file;
|
||||
@@ -1092,6 +1092,13 @@ build_static_trusted_list (const struct grub_module_header *header)
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
|
||||
+ if (is_pks)
|
||||
+ {
|
||||
+ err = is_distrusted_cert_hash (cert_data, cert_data_size);
|
||||
+ if (err != GRUB_ERR_NONE)
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
err = add_certificate (cert_data, cert_data_size, &db, 1);
|
||||
grub_free (cert_data);
|
||||
|
||||
@@ -1144,6 +1151,22 @@ free_distrusted_list (void)
|
||||
grub_memset (&dbx, 0, sizeof (dbx));
|
||||
}
|
||||
|
||||
+static grub_err_t
|
||||
+load_static_keys (const struct grub_module_header *header, const grub_bool_t is_pks)
|
||||
+{
|
||||
+ int rc = GRUB_ERR_NONE;
|
||||
+ FOR_MODULES (header)
|
||||
+ {
|
||||
+ /* Not an ELF module, skip. */
|
||||
+ if (header->type != OBJ_TYPE_X509_PUBKEY)
|
||||
+ continue;
|
||||
+ rc = build_static_trusted_list (header, is_pks);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ return rc;
|
||||
+ }
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
GRUB_MOD_INIT (appendedsig)
|
||||
{
|
||||
int rc;
|
||||
@@ -1163,26 +1186,27 @@ GRUB_MOD_INIT (appendedsig)
|
||||
|
||||
if (!grub_pks_use_keystore && check_sigs == check_sigs_forced)
|
||||
{
|
||||
- FOR_MODULES (header)
|
||||
+ rc = load_static_keys (header, false);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
{
|
||||
- /* Not an ELF module, skip. */
|
||||
- if (header->type != OBJ_TYPE_X509_PUBKEY)
|
||||
- continue;
|
||||
-
|
||||
- rc = build_static_trusted_list (header);
|
||||
- if (rc != GRUB_ERR_NONE)
|
||||
- {
|
||||
- free_trusted_list ();
|
||||
- grub_error (rc, "static trusted list creation failed");
|
||||
- }
|
||||
- else
|
||||
- grub_printf ("appendedsig: the trusted list now has %" PRIuGRUB_SIZE " static keys\n",
|
||||
- db.key_entries);
|
||||
+ free_trusted_list ();
|
||||
+ grub_error (rc, "static trusted list creation failed");
|
||||
}
|
||||
+ else
|
||||
+ grub_printf ("appendedsig: the trusted list now has %" PRIuGRUB_SIZE " static keys\n",
|
||||
+ db.key_entries);
|
||||
}
|
||||
else if (grub_pks_use_keystore && check_sigs == check_sigs_forced)
|
||||
{
|
||||
- rc = create_trusted_list ();
|
||||
+ if (grub_pks_keystore.use_static_keys)
|
||||
+ {
|
||||
+ grub_printf ("Warning: db variable is not available at PKS and using a static keys "
|
||||
+ "as a default key in trusted list\n");
|
||||
+ rc = load_static_keys (header, grub_pks_keystore.use_static_keys);
|
||||
+ }
|
||||
+ else
|
||||
+ rc = create_trusted_list ();
|
||||
+
|
||||
if (rc != GRUB_ERR_NONE)
|
||||
{
|
||||
free_trusted_list ();
|
||||
--
|
||||
2.48.1
|
||||
|
@@ -1,7 +1,7 @@
|
||||
From f05acf089fb80fc44112a7feec3529af494a41f7 Mon Sep 17 00:00:00 2001
|
||||
From 964b7ef5695ac925e8cdcf3381d5cfb45dc5d140 Mon Sep 17 00:00:00 2001
|
||||
From: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Date: Wed, 1 Feb 2023 21:42:36 +0530
|
||||
Subject: [PATCH 5/8] appendedsig: The grub command's trusted and distrusted
|
||||
Date: Tue, 25 Feb 2025 02:33:17 +0530
|
||||
Subject: [PATCH 8/9] appendedsig: The grub command's trusted and distrusted
|
||||
support
|
||||
|
||||
To support the following trusted and distrusted commands
|
||||
@@ -24,17 +24,16 @@ Note:-
|
||||
are not allowed in grub command prompt while secure boot is enabled.
|
||||
|
||||
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
|
||||
Tested-by: Nageswara Sastry <rnsastry@linux.ibm.com>
|
||||
Reviewed-by: Avnish Chouhan <avnish@linux.ibm.com>
|
||||
---
|
||||
grub-core/commands/appendedsig/appendedsig.c | 547 ++++++++++++-------
|
||||
1 file changed, 361 insertions(+), 186 deletions(-)
|
||||
grub-core/commands/appendedsig/appendedsig.c | 545 ++++++++++++-------
|
||||
1 file changed, 354 insertions(+), 191 deletions(-)
|
||||
|
||||
diff --git a/grub-core/commands/appendedsig/appendedsig.c b/grub-core/commands/appendedsig/appendedsig.c
|
||||
index f9638220e..7d2bba079 100644
|
||||
index 3cbe51ec13..6ccfdb4c6e 100644
|
||||
--- a/grub-core/commands/appendedsig/appendedsig.c
|
||||
+++ b/grub-core/commands/appendedsig/appendedsig.c
|
||||
@@ -123,6 +123,38 @@ static enum
|
||||
@@ -118,6 +118,36 @@ static enum
|
||||
check_sigs_forced = 2
|
||||
} check_sigs = check_sigs_no;
|
||||
|
||||
@@ -52,10 +51,9 @@ index f9638220e..7d2bba079 100644
|
||||
+};
|
||||
+
|
||||
+static void
|
||||
+grub_printhex (const grub_uint8_t *data, const grub_size_t length)
|
||||
+print_hex (const grub_uint8_t *data, const grub_size_t length)
|
||||
+{
|
||||
+ grub_size_t i, count = 0;
|
||||
+
|
||||
+ for (i = 0; i < length-1; i++)
|
||||
+ {
|
||||
+ grub_printf ("%02x:", data[i]);
|
||||
@@ -66,14 +64,13 @@ index f9638220e..7d2bba079 100644
|
||||
+ count = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ grub_printf ("%02x\n", data[i]);
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* GUID can be used to determine the hashing function and
|
||||
* generate the hash using determined hashing function.
|
||||
@@ -396,75 +428,6 @@ grub_env_write_sec (struct grub_env_var *var __attribute__((unused)),
|
||||
@@ -346,78 +376,6 @@ grub_env_write_sec (struct grub_env_var *var __attribute__((unused)),
|
||||
return grub_strdup (grub_env_read_sec (NULL, NULL));
|
||||
}
|
||||
|
||||
@@ -104,7 +101,10 @@ index f9638220e..7d2bba079 100644
|
||||
-
|
||||
- while (total_read_size < file_size)
|
||||
- {
|
||||
- read_size = grub_file_read (file, *buf + total_read_size, file_size - total_read_size);
|
||||
- read_size =
|
||||
- grub_file_read (file, *buf + total_read_size,
|
||||
- file_size - total_read_size);
|
||||
-
|
||||
- if (read_size < 0)
|
||||
- {
|
||||
- grub_free (*buf);
|
||||
@@ -149,7 +149,7 @@ index f9638220e..7d2bba079 100644
|
||||
static grub_err_t
|
||||
extract_appended_signature (const grub_uint8_t *buf, grub_size_t bufsize,
|
||||
struct grub_appended_signature *sig)
|
||||
@@ -686,159 +649,357 @@ static grub_err_t
|
||||
@@ -647,159 +605,351 @@ static grub_err_t
|
||||
grub_cmd_verify_signature (grub_command_t cmd __attribute__((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
@@ -160,7 +160,9 @@ index f9638220e..7d2bba079 100644
|
||||
+ grub_file_t signed_file = NULL;
|
||||
+ grub_uint8_t *signed_data = NULL;
|
||||
+ grub_ssize_t signed_data_size = 0;
|
||||
+
|
||||
|
||||
- if (argc < 1)
|
||||
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
|
||||
+ if (argc != 1)
|
||||
+ {
|
||||
+ grub_printf (N_("a signed file is expected\n"
|
||||
@@ -168,11 +170,6 @@ index f9638220e..7d2bba079 100644
|
||||
+ return GRUB_ERR_BAD_ARGUMENT;
|
||||
+ }
|
||||
|
||||
- if (argc < 1)
|
||||
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
|
||||
+ if (grub_strlen (args[0]) == 0)
|
||||
+ return grub_error (GRUB_ERR_BAD_FILENAME, N_("missing signed file"));
|
||||
|
||||
grub_dprintf ("appendedsig", "verifying %s\n", args[0]);
|
||||
|
||||
- f = grub_file_open (args[0], GRUB_FILE_TYPE_VERIFY_SIGNATURE);
|
||||
@@ -183,11 +180,14 @@ index f9638220e..7d2bba079 100644
|
||||
+
|
||||
+ err = grub_read_file (signed_file, &signed_data, &signed_data_size);
|
||||
+ if (err != GRUB_ERR_NONE)
|
||||
+ {
|
||||
{
|
||||
- err = grub_errno;
|
||||
- goto cleanup;
|
||||
+ grub_file_close (signed_file);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
- err = file_read_all (f, &data, &file_size);
|
||||
+ grub_file_close (signed_file);
|
||||
+ err = grub_verify_appended_signature (signed_data, signed_data_size);
|
||||
+ grub_free (signed_data);
|
||||
@@ -202,7 +202,7 @@ index f9638220e..7d2bba079 100644
|
||||
+ struct x509_certificate *cert = NULL;
|
||||
+ grub_size_t i = 0, cert_num = 1;
|
||||
+
|
||||
+ for (cert = grub_db.keys; cert; cert = cert->next)
|
||||
+ for (cert = db.keys; cert; cert = cert->next)
|
||||
+ {
|
||||
+ grub_printf (N_("trusted certificate %" PRIuGRUB_SIZE ":\n"), cert_num);
|
||||
+ grub_printf (N_("\tserial: "));
|
||||
@@ -216,16 +216,13 @@ index f9638220e..7d2bba079 100644
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < grub_db.signature_entries; i++)
|
||||
{
|
||||
- err = grub_errno;
|
||||
- goto cleanup;
|
||||
+ for (i = 0; i < db.signature_entries; i++)
|
||||
+ {
|
||||
+ grub_printf (N_("trusted binary hash %" PRIuGRUB_SIZE ":\n"), i+1);
|
||||
+ grub_printf (N_("\thash: "));
|
||||
+ grub_printhex (grub_db.signatures[i], grub_db.signature_size[i]);
|
||||
}
|
||||
|
||||
- err = file_read_all (f, &data, &file_size);
|
||||
+ print_hex (db.signatures[i], db.signature_size[i]);
|
||||
+ }
|
||||
+
|
||||
+ return GRUB_ERR_NONE;
|
||||
+}
|
||||
+
|
||||
@@ -237,7 +234,7 @@ index f9638220e..7d2bba079 100644
|
||||
+ struct x509_certificate *cert = NULL;
|
||||
+ grub_size_t i = 0, cert_num = 1;
|
||||
+
|
||||
+ for (cert = grub_dbx.keys; cert; cert = cert->next)
|
||||
+ for (cert = dbx.keys; cert; cert = cert->next)
|
||||
+ {
|
||||
+ grub_printf (N_("distrusted certificate %" PRIuGRUB_SIZE ":\n"), cert_num);
|
||||
+ grub_printf (N_("\tserial: "));
|
||||
@@ -250,11 +247,11 @@ index f9638220e..7d2bba079 100644
|
||||
+ cert_num++;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < grub_dbx.signature_entries; i++)
|
||||
+ for (i = 0; i < dbx.signature_entries; i++)
|
||||
+ {
|
||||
+ grub_printf (N_("distrusted certificate/binary hash %" PRIuGRUB_SIZE ":\n"), i+1);
|
||||
+ grub_printf (N_("\thash: "));
|
||||
+ grub_printhex (grub_dbx.signatures[i], grub_dbx.signature_size[i]);
|
||||
+ print_hex (dbx.signatures[i], dbx.signature_size[i]);
|
||||
+ }
|
||||
+
|
||||
+ return GRUB_ERR_NONE;
|
||||
@@ -303,11 +300,11 @@ index f9638220e..7d2bba079 100644
|
||||
|
||||
- err = grub_verify_appended_signature (data, file_size);
|
||||
+ grub_file_close (cert_file);
|
||||
+ err = grub_add_certificate (cert_data, cert_data_size, &grub_db, 1);
|
||||
+ err = add_certificate (cert_data, cert_data_size, &db, 1);
|
||||
+ if (err != GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ grub_release_trusted_list ();
|
||||
+ grub_release_distrusted_list ();
|
||||
+ free_trusted_list ();
|
||||
+ free_distrusted_list ();
|
||||
+ grub_error (err, "adding of trusted certificate failed");
|
||||
+ }
|
||||
|
||||
@@ -359,8 +356,8 @@ index f9638220e..7d2bba079 100644
|
||||
|
||||
- if (cert_num == 1)
|
||||
- {
|
||||
- cert = grub_db.keys;
|
||||
- grub_db.keys = cert->next;
|
||||
- cert = db.keys;
|
||||
- db.keys = cert->next;
|
||||
+ hash_file = grub_file_open (args[0], GRUB_FILE_TYPE_TO_HASH | GRUB_FILE_TYPE_NO_DECOMPRESS);
|
||||
+ if (hash_file == NULL)
|
||||
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND,
|
||||
@@ -376,22 +373,21 @@ index f9638220e..7d2bba079 100644
|
||||
+ return rc;
|
||||
}
|
||||
- i = 2;
|
||||
- prev = grub_db.keys;
|
||||
- cert = grub_db.keys->next;
|
||||
- prev = db.keys;
|
||||
- cert = db.keys->next;
|
||||
- while (cert)
|
||||
+
|
||||
+ grub_file_close (hash_file);
|
||||
+
|
||||
+ grub_dprintf ("appendedsig", "adding a trusted binary hash %s\n with size of %" PRIdGRUB_SSIZE "\n",
|
||||
+ grub_dprintf ("appendedsig", "adding a trusted binary hash %s\n with size of %" PRIuGRUB_SIZE "\n",
|
||||
+ hash_data, hash_data_size);
|
||||
+
|
||||
+ /* only accept SHA256, SHA384 and SHA512 binary hash */
|
||||
+ if (hash_data_size != SHA256_LEN && hash_data_size != SHA384_LEN &&
|
||||
+ hash_data_size != SHA512_LEN)
|
||||
+ if (hash_data_size != 32 && hash_data_size != 48 && hash_data_size != 64)
|
||||
+ return grub_error (GRUB_ERR_BAD_SIGNATURE, N_("unacceptable trusted binary hash type"));
|
||||
+
|
||||
+ rc = grub_add_hash ((const grub_uint8_t **) &hash_data, hash_data_size, &grub_db.signatures,
|
||||
+ &grub_db.signature_size, &grub_db.signature_entries);
|
||||
+ rc = add_hash ((const grub_uint8_t **) &hash_data, hash_data_size, &db.signatures,
|
||||
+ &db.signature_size, &db.signature_entries);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
{
|
||||
- if (i == cert_num)
|
||||
@@ -404,8 +400,8 @@ index f9638220e..7d2bba079 100644
|
||||
- i++;
|
||||
- prev = cert;
|
||||
- cert = cert->next;
|
||||
+ grub_release_trusted_list ();
|
||||
+ grub_release_distrusted_list ();
|
||||
+ free_trusted_list ();
|
||||
+ free_distrusted_list ();
|
||||
+ grub_error (rc, "adding of trusted binary hash failed");
|
||||
}
|
||||
|
||||
@@ -426,8 +422,8 @@ index f9638220e..7d2bba079 100644
|
||||
- struct x509_certificate *cert = NULL;
|
||||
- grub_err_t err;
|
||||
+ grub_size_t cert_num = 0, i = 1;
|
||||
+ struct x509_certificate *current_cert = grub_db.keys;
|
||||
+ struct x509_certificate *previous_cert = grub_db.keys;
|
||||
+ struct x509_certificate *current_cert = db.keys;
|
||||
+ struct x509_certificate *previous_cert = db.keys;
|
||||
|
||||
if (argc != 1)
|
||||
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
|
||||
@@ -458,18 +454,18 @@ index f9638220e..7d2bba079 100644
|
||||
- if (!cert)
|
||||
- return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
||||
- N_("Could not allocate memory for certificate"));
|
||||
+ if (cert_num > grub_db.key_entries)
|
||||
+ if (cert_num > db.key_entries)
|
||||
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
+ N_("trusted certificate number should not exceed %" PRIuGRUB_SIZE),
|
||||
+ grub_db.key_entries);
|
||||
+ else if (cert_num < grub_db.key_entries)
|
||||
+ N_("trusted certificate number should not exceed %" PRIuGRUB_SIZE ""),
|
||||
+ db.key_entries);
|
||||
+ else if (cert_num < db.key_entries)
|
||||
+ return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
+ N_("there is no certificate on the trusted list. so, not permitted"));
|
||||
|
||||
- err = read_cert_from_file (certf, cert);
|
||||
- grub_file_close (certf);
|
||||
- if (err != GRUB_ERR_NONE)
|
||||
+ for (i = 1; i < grub_db.key_entries; i++)
|
||||
+ for (i = 1; i < db.key_entries; i++)
|
||||
{
|
||||
- grub_free (cert);
|
||||
- return err;
|
||||
@@ -490,8 +486,8 @@ index f9638220e..7d2bba079 100644
|
||||
- grub_dprintf ("appendedsig", "Loaded certificate with CN: %s\n",
|
||||
- cert->subject);
|
||||
|
||||
- cert->next = grub_db.keys;
|
||||
- grub_db.keys = cert;
|
||||
- cert->next = db.keys;
|
||||
- db.keys = cert;
|
||||
+ certificate_release (current_cert);
|
||||
+ grub_free (current_cert);
|
||||
|
||||
@@ -512,7 +508,7 @@ index f9638220e..7d2bba079 100644
|
||||
+ grub_uint8_t *hash_data = NULL;
|
||||
+ grub_ssize_t hash_data_size = 0;
|
||||
|
||||
- for (cert = grub_db.keys; cert; cert = cert->next)
|
||||
- for (cert = db.keys; cert; cert = cert->next)
|
||||
+ if (argc != 2)
|
||||
{
|
||||
- grub_printf (N_("Certificate %d:\n"), cert_num);
|
||||
@@ -561,31 +557,29 @@ index f9638220e..7d2bba079 100644
|
||||
+ grub_file_close (hash_file);
|
||||
+
|
||||
+ grub_dprintf ("appendedsig", "adding a distrusted certificate/binary hash %s\n"
|
||||
+ " with size of %" PRIdGRUB_SSIZE "\n", hash_data, hash_data_size);
|
||||
+ " with size of %" PRIuGRUB_SIZE "\n", hash_data, hash_data_size);
|
||||
+
|
||||
+ if (ctxt->state[OPTION_BINARY_HASH].set)
|
||||
+ {
|
||||
+ /* only accept SHA256, SHA384 and SHA512 binary hash */
|
||||
+ if (hash_data_size != SHA256_LEN && hash_data_size != SHA384_LEN &&
|
||||
+ hash_data_size != SHA512_LEN)
|
||||
+ if (hash_data_size != 32 && hash_data_size != 48 && hash_data_size != 64)
|
||||
+ return grub_error (GRUB_ERR_BAD_SIGNATURE,
|
||||
+ N_("unacceptable distrusted binary hash type"));
|
||||
+ }
|
||||
+ else if (ctxt->state[OPTION_CERT_HASH].set)
|
||||
+ {
|
||||
+ /* only accept SHA256, SHA384 and SHA512 certificate hash */
|
||||
+ if (hash_data_size != SHA256_LEN && hash_data_size != SHA384_LEN &&
|
||||
+ hash_data_size != SHA512_LEN)
|
||||
+ if (hash_data_size != 32 && hash_data_size != 48 && hash_data_size != 64)
|
||||
+ return grub_error (GRUB_ERR_BAD_SIGNATURE,
|
||||
+ N_("unacceptable distrusted certificate hash type"));
|
||||
+ }
|
||||
+
|
||||
+ rc = grub_add_hash ((const grub_uint8_t **) &hash_data, hash_data_size, &grub_dbx.signatures,
|
||||
+ &grub_dbx.signature_size, &grub_dbx.signature_entries);
|
||||
+ rc = add_hash ((const grub_uint8_t **) &hash_data, hash_data_size, &dbx.signatures,
|
||||
+ &dbx.signature_size, &dbx.signature_entries);
|
||||
+ if (rc != GRUB_ERR_NONE)
|
||||
+ {
|
||||
+ grub_release_trusted_list ();
|
||||
+ grub_release_distrusted_list ();
|
||||
+ free_trusted_list ();
|
||||
+ free_distrusted_list ();
|
||||
+ grub_error (rc, "adding of distrusted binary/certificate hash failed");
|
||||
+ }
|
||||
+
|
||||
@@ -604,21 +598,31 @@ index f9638220e..7d2bba079 100644
|
||||
{
|
||||
if (check_sigs == check_sigs_no)
|
||||
{
|
||||
@@ -1212,7 +1373,9 @@ grub_load_static_keys (struct grub_module_header *header, bool mode)
|
||||
@@ -874,8 +1024,6 @@ static struct grub_fs pseudo_fs = {
|
||||
.fs_read = pseudo_read
|
||||
};
|
||||
|
||||
-static grub_command_t cmd_verify, cmd_list, cmd_distrust, cmd_trust;
|
||||
-
|
||||
/*
|
||||
* Verify the trusted certificate against the certificate hashes from platform keystore buffer's
|
||||
* distrusted list.
|
||||
@@ -1167,6 +1315,10 @@ load_static_keys (const struct grub_module_header *header, const grub_bool_t is_
|
||||
return rc;
|
||||
}
|
||||
|
||||
-static grub_command_t cmd_verify, cmd_list, cmd_distrust, cmd_trust;
|
||||
+static grub_extcmd_t cmd_distrusted_hash;
|
||||
+static grub_command_t cmd_verify, cmd_trusted_list, cmd_trusted_cert, cmd_trusted_hash,
|
||||
+ cmd_distrusted_list, cmd_distrusted_cert;
|
||||
|
||||
+
|
||||
GRUB_MOD_INIT (appendedsig)
|
||||
{
|
||||
@@ -1278,21 +1441,31 @@ GRUB_MOD_INIT (appendedsig)
|
||||
grub_release_platform_keystore ();
|
||||
}
|
||||
int rc;
|
||||
@@ -1229,22 +1381,31 @@ GRUB_MOD_INIT (appendedsig)
|
||||
|
||||
grub_pks_free_keystore ();
|
||||
}
|
||||
-
|
||||
- cmd_trust =
|
||||
- grub_register_command ("trust_certificate", grub_cmd_trust,
|
||||
- N_("X509_CERTIFICATE"),
|
||||
@@ -662,7 +666,7 @@ index f9638220e..7d2bba079 100644
|
||||
|
||||
grub_verifier_register (&grub_appendedsig_verifier);
|
||||
grub_dl_set_persistent (mod);
|
||||
@@ -1304,10 +1477,12 @@ GRUB_MOD_FINI (appendedsig)
|
||||
@@ -1256,10 +1417,12 @@ GRUB_MOD_FINI (appendedsig)
|
||||
* grub_dl_set_persistent should prevent this from actually running, but
|
||||
* it does still run under emu.
|
||||
*/
|
||||
@@ -680,5 +684,5 @@ index f9638220e..7d2bba079 100644
|
||||
+ grub_unregister_extcmd (cmd_distrusted_hash);
|
||||
}
|
||||
--
|
||||
2.47.0
|
||||
2.48.1
|
||||
|
@@ -1,19 +1,19 @@
|
||||
From 87831c6ce3536e5e2eeb3e2cd8a6184b9509ee04 Mon Sep 17 00:00:00 2001
|
||||
From e57bcf83765291da62ad92f330cc1ffb535d4017 Mon Sep 17 00:00:00 2001
|
||||
From: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Date: Wed, 17 Apr 2024 23:04:43 +0530
|
||||
Subject: [PATCH 6/8] appendedsig: documentation
|
||||
Date: Tue, 25 Feb 2025 02:47:03 +0530
|
||||
Subject: [PATCH 9/9] appendedsig: documentation
|
||||
|
||||
This explains appended signatures static key and dynamic key,
|
||||
and documents the commands and variables introduced.
|
||||
This explains how static and dynamic key appended signatures can be used to form part of
|
||||
a secure boot chain, and documents the commands and variables introduced.
|
||||
|
||||
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
|
||||
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
|
||||
Reviewed-by: Avnish Chouhan <avnish@linux.ibm.com>
|
||||
---
|
||||
docs/grub.texi | 115 ++++++++++++++++++++++++++++++++++---------------
|
||||
1 file changed, 80 insertions(+), 35 deletions(-)
|
||||
docs/grub.texi | 113 +++++++++++++++++++++++++++++++++----------------
|
||||
1 file changed, 76 insertions(+), 37 deletions(-)
|
||||
|
||||
diff --git a/docs/grub.texi b/docs/grub.texi
|
||||
index 00c5fdc44..68d7cbb90 100644
|
||||
index e89007920c..9aaea72826 100644
|
||||
--- a/docs/grub.texi
|
||||
+++ b/docs/grub.texi
|
||||
@@ -4373,7 +4373,9 @@ you forget a command, you can run the command @command{help}
|
||||
@@ -46,15 +46,16 @@ index 00c5fdc44..68d7cbb90 100644
|
||||
* unset:: Unset an environment variable
|
||||
@comment * vbeinfo:: List available video modes
|
||||
* verify_appended:: Verify appended digital signature
|
||||
@@ -4776,15 +4779,15 @@ GPG-style digital signatures}, for more information.
|
||||
@@ -4775,16 +4778,15 @@ These keys are used to validate signatures when environment variable
|
||||
GPG-style digital signatures}, for more information.
|
||||
@end deffn
|
||||
|
||||
|
||||
-@node distrust_certificate
|
||||
-@subsection distrust_certificate
|
||||
+@node distrusted_certificate
|
||||
+@subsection distrusted_certificate
|
||||
|
||||
-@node distrust_certificate
|
||||
-@subsection distrust_certificate
|
||||
-
|
||||
-@deffn Command distrust_certificate cert_number
|
||||
+@deffn Command distrusted_certificate cert_number
|
||||
Remove the x509 certificate numbered @var{cert_number} from GRUB's keyring of
|
||||
@@ -66,7 +67,7 @@ index 00c5fdc44..68d7cbb90 100644
|
||||
|
||||
These certificates are used to validate appended signatures when environment
|
||||
variable @code{check_appended_signatures} is set to @code{enforce}
|
||||
@@ -4793,6 +4796,27 @@ variable @code{check_appended_signatures} is set to @code{enforce}
|
||||
@@ -4793,6 +4795,27 @@ variable @code{check_appended_signatures} is set to @code{enforce}
|
||||
information.
|
||||
@end deffn
|
||||
|
||||
@@ -94,7 +95,7 @@ index 00c5fdc44..68d7cbb90 100644
|
||||
|
||||
@node drivemap
|
||||
@subsection drivemap
|
||||
@@ -5069,22 +5093,6 @@ without any options, the @command{keystatus} command returns true if and
|
||||
@@ -5069,22 +5092,6 @@ without any options, the @command{keystatus} command returns true if and
|
||||
only if checking key modifier status is supported.
|
||||
@end deffn
|
||||
|
||||
@@ -117,19 +118,20 @@ index 00c5fdc44..68d7cbb90 100644
|
||||
@node list_env
|
||||
@subsection list_env
|
||||
|
||||
@@ -5935,9 +5943,8 @@ and manual booting. @xref{Using GPG-style digital signatures}, for more
|
||||
information.
|
||||
@@ -5936,17 +5943,17 @@ information.
|
||||
@end deffn
|
||||
|
||||
-
|
||||
|
||||
-@node trust_certificate
|
||||
-@subsection trust_certificate
|
||||
+@node trusted_certificate
|
||||
+@subsection trusted_certificate
|
||||
|
||||
@deffn Command trust_certificate x509_certificate
|
||||
-@deffn Command trust_certificate x509_certificate
|
||||
+@deffn Command trusted_certificate x509_certificate
|
||||
Read a DER-formatted x509 certificate from the file @var{x509_certificate}
|
||||
@@ -5946,7 +5953,7 @@ certificates are used to validate appended signatures when the environment
|
||||
and add it to GRUB's internal list of trusted x509 certificates. These
|
||||
certificates are used to validate appended signatures when the environment
|
||||
variable @code{check_appended_signatures} is set to @code{enforce}.
|
||||
|
||||
Note that if @code{check_appended_signatures} is set to @code{enforce}
|
||||
@@ -171,23 +173,20 @@ index 00c5fdc44..68d7cbb90 100644
|
||||
|
||||
@node unset
|
||||
@subsection unset
|
||||
@@ -5979,8 +6012,8 @@ only on PC BIOS platforms.
|
||||
@@ -5979,9 +6012,8 @@ only on PC BIOS platforms.
|
||||
|
||||
@deffn Command verify_appended file
|
||||
Verifies an appended signature on @var{file} against the trusted certificates
|
||||
-known to GRUB (See @pxref{list_certificates}, @pxref{trust_certificate}, and
|
||||
-@pxref{distrust_certificate}).
|
||||
-
|
||||
+known to GRUB (See @pxref{trusted_list}, @pxref{trusted_certificate}, and
|
||||
+@pxref{distrusted_certificate}).
|
||||
|
||||
Exit code @code{$?} is set to 0 if the signature validates
|
||||
successfully. If validation fails, it is set to a non-zero value.
|
||||
@@ -6664,17 +6697,29 @@ with an appended signature ends with the magic string:
|
||||
where @code{\n} represents the carriage-return character, @code{0x0a}.
|
||||
|
||||
To enable appended signature verification, load the appendedsig module and an
|
||||
-x509 certificate for verification. Building the appendedsig module into the
|
||||
+trusted keys for verification. Building the appendedsig module into the
|
||||
See @xref{Using appended signatures}, for more information.
|
||||
@@ -6669,14 +6701,21 @@ To enable appended signature verification, load the appendedsig module and an
|
||||
x509 certificate for verification. Building the appendedsig module into the
|
||||
core grub image is recommended.
|
||||
|
||||
-Certificates can be managed at boot time using the @pxref{trust_certificate},
|
||||
@@ -205,19 +204,15 @@ index 00c5fdc44..68d7cbb90 100644
|
||||
+the trusted certificates and binary hashes at boot time using @pxref{trusted_list}
|
||||
+and list distrusted certificates and binary/certificate hashes at boot time using
|
||||
+@pxref{distrusted_list} commands.
|
||||
+
|
||||
+Also, it will not allow to manage add/delete of certificates/signature at boot time using
|
||||
+@pxref{trusted_certificate} and @pxref{trusted_signature}, @pxref{distrusted_certificate}
|
||||
+and @pxref{distrusted_signature} commands when the environment variable
|
||||
+@code{check_appended_signatures} is set to @code{enforce}.
|
||||
|
||||
A file can be explictly verified using the @pxref{verify_appended} command.
|
||||
-A file can be explictly verified using the @pxref{verify_appended} command.
|
||||
+A file can be explicitly verified using the @pxref{verify_appended} command.
|
||||
|
||||
-Only signatures made with the SHA-256 or SHA-512 hash algorithm are supported,
|
||||
+Only signatures made with the SHA-256, SH-384 and SHA-512 hash algorithm are supported,
|
||||
+Only signatures made with the SHA-256, SHA-384 and SHA-512 hash algorithm are supported,
|
||||
and only RSA signatures are supported.
|
||||
|
||||
A file can be signed with the @command{sign-file} utility supplied with the
|
||||
--
|
||||
2.47.0
|
||||
2.48.1
|
||||
|
@@ -1,3 +1,79 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Mar 17 08:27:29 UTC 2025 - Michael Chang <mchang@suse.com>
|
||||
|
||||
- Refresh PPC NVMEoF ofpath related patches to newer revision
|
||||
* 0002-ieee1275-ofpath-enable-NVMeoF-logical-device-transla.patch
|
||||
- Patch refreshed
|
||||
* 0001-ieee1275-support-added-for-multiple-nvme-bootpaths.patch
|
||||
- Patch obseleted
|
||||
* 0004-ofpath-controller-name-update.patch
|
||||
* 0001-squash-ieee1275-ofpath-enable-NVMeoF-logical-device-.patch
|
||||
- Fix segmentation fault error in grub2-probe with target=hints_string
|
||||
(bsc#1235971) (bsc#1235958) (bsc#1239651)
|
||||
* 0001-ofpath-Add-error-check-in-NVMEoF-device-translation.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Mar 13 06:50:37 UTC 2025 - Gary Ching-Pang Lin <glin@suse.com>
|
||||
|
||||
- Update the patch to fix "SRK not matched" errors when unsealing
|
||||
the key (bsc#1232411)
|
||||
* 0001-tpm2-Add-extra-RSA-SRK-types.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 11 07:11:42 UTC 2025 - Michael Chang <mchang@suse.com>
|
||||
|
||||
- Update patches for Power guest secure boot with key management (jsc#PED-3520)
|
||||
(jsc#PED-9892)
|
||||
* 0001-ieee1275-adding-failure-check-condition-on-ibm-secur.patch
|
||||
* 0002-ieee1275-Platform-Keystore-PKS-Support.patch
|
||||
* 0003-ieee1275-Read-the-DB-and-DBX-secure-boot-variables.patch
|
||||
* 0004-appendedsig-The-creation-of-trusted-and-distrusted-l.patch
|
||||
* 0005-appendedsig-While-verifying-the-kernel-use-trusted-a.patch
|
||||
* 0006-powerpc_ieee1275-set-use_static_keys-flag.patch
|
||||
* 0007-appendedsig-Reads-the-default-DB-keys-from-ELF-Note.patch
|
||||
* 0008-appendedsig-The-grub-command-s-trusted-and-distruste.patch
|
||||
* 0009-appendedsig-documentation.patch
|
||||
- Remove patches
|
||||
* 0001-ieee1275-Platform-Keystore-PKS-Support.patch
|
||||
* 0002-ieee1275-Read-the-DB-and-DBX-secure-boot-variables.patch
|
||||
* 0003-appendedsig-The-creation-of-trusted-and-distrusted-l.patch
|
||||
* 0004-appendedsig-While-verifying-the-kernel-use-trusted-a.patch
|
||||
* 0005-appendedsig-The-grub-command-s-trusted-and-distruste.patch
|
||||
* 0006-appendedsig-documentation.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 7 09:04:38 UTC 2025 - Michael Chang <mchang@suse.com>
|
||||
|
||||
- Pass through PAES cipher as AES on s390x-emu (jsc#PED-10950)
|
||||
* 0001-s390x-emu-Pass-through-PAES-cipher-as-AES.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 7 06:59:04 UTC 2025 - Michael Chang <mchang@suse.com>
|
||||
|
||||
- Fix zfs.mo not found message when booting on legacy BIOS (bsc#1237865)
|
||||
* 0001-autofs-Ignore-zfs-not-found.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Mar 3 04:30:51 UTC 2025 - Michael Chang <mchang@suse.com>
|
||||
|
||||
- Cherry-pick upstream XFS fixes
|
||||
* 0001-fs-xfs-Add-new-superblock-features-added-in-Linux-6..patch
|
||||
* 0002-fs-xfs-Fix-grub_xfs_iterate_dir-return-value-in-case.patch
|
||||
- Fix "attempt to read of write outside of partition" error message (bsc#1237844)
|
||||
* 0003-fs-xfs-fix-large-extent-counters-incompat-feature-su.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Feb 25 02:46:36 UTC 2025 - Michael Chang <mchang@suse.com>
|
||||
|
||||
- Make SLFO/SLE-16 and openSUSE have identical package structures
|
||||
- Provide grub2-<CPUARCH>-efi-bls for SLFO/SLE-16
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Feb 19 07:12:23 UTC 2025 - Michael Chang <mchang@suse.com>
|
||||
|
||||
- Fix grub-bls does not rollback via setting new default (bsc#1237198)
|
||||
* 0001-bls-Accept-.conf-suffix-in-setting-default-entry.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Feb 14 03:49:09 UTC 2025 - Michael Chang <mchang@suse.com>
|
||||
|
||||
|
62
grub2.spec
62
grub2.spec
@@ -353,7 +353,6 @@ Patch161: safe_tpm_pcr_snapshot.patch
|
||||
Patch162: 0001-ieee1275-add-support-for-NVMeoFC.patch
|
||||
Patch163: 0002-ieee1275-ofpath-enable-NVMeoF-logical-device-transla.patch
|
||||
Patch164: 0003-ieee1275-change-the-logic-of-ieee1275_get_devargs.patch
|
||||
Patch165: 0004-ofpath-controller-name-update.patch
|
||||
Patch166: 0002-Mark-environmet-blocks-as-used-for-image-embedding.patch
|
||||
Patch167: grub2-increase-crypttab-path-buffer.patch
|
||||
Patch170: 0001-tpm2_key_protector-Support-authorized-policy.patch
|
||||
@@ -382,7 +381,6 @@ Patch195: 0004-Key-revocation-on-out-of-bound-file-access.patch
|
||||
Patch196: fix_no_extra_deps_in_release_tarball.patch
|
||||
Patch197: 0001-fs-xfs-always-verify-the-total-number-of-entries-is-.patch
|
||||
Patch198: 0001-loader-arm64-efi-linux-Remove-magic-number-header-fi.patch
|
||||
Patch199: 0001-squash-ieee1275-ofpath-enable-NVMeoF-logical-device-.patch
|
||||
Patch200: 0001-ofdisk-enhance-boot-time-by-focusing-on-boot-disk-re.patch
|
||||
Patch201: 0002-ofdisk-add-early_log-support.patch
|
||||
Patch202: 0001-disk-Optimize-disk-iteration-by-moving-memdisk-to-th.patch
|
||||
@@ -402,12 +400,6 @@ Patch220: 0001-Streamline-BLS-and-improve-PCR-stability.patch
|
||||
Patch221: 0001-fix-grub-screen-filled-with-post-screen-artifects.patch
|
||||
Patch222: 0001-efinet-Skip-virtual-VLAN-devices-during-card-enumera.patch
|
||||
Patch223: 0001-tpm-Skip-loopback-image-measurement.patch
|
||||
Patch224: 0001-ieee1275-Platform-Keystore-PKS-Support.patch
|
||||
Patch225: 0002-ieee1275-Read-the-DB-and-DBX-secure-boot-variables.patch
|
||||
Patch226: 0003-appendedsig-The-creation-of-trusted-and-distrusted-l.patch
|
||||
Patch227: 0004-appendedsig-While-verifying-the-kernel-use-trusted-a.patch
|
||||
Patch228: 0005-appendedsig-The-grub-command-s-trusted-and-distruste.patch
|
||||
Patch229: 0006-appendedsig-documentation.patch
|
||||
Patch230: 0007-grub-mkimage-Create-new-ELF-note-for-SBAT.patch
|
||||
Patch231: 0008-grub-mkimage-Add-SBAT-metadata-into-ELF-note-for-Pow.patch
|
||||
Patch232: 0001-ieee1275-support-added-for-multiple-nvme-bootpaths.patch
|
||||
@@ -437,8 +429,24 @@ Patch255: 0017-commands-minicmd-Block-the-dump-command-in-lockdown-.patch
|
||||
Patch256: 0018-fs-bfs-Disable-under-lockdown.patch
|
||||
Patch257: 0019-fs-Disable-many-filesystems-under-lockdown.patch
|
||||
Patch258: 0020-fs-Prevent-overflows-when-allocating-memory-for-arra.patch
|
||||
Patch259: 0001-bls-Accept-.conf-suffix-in-setting-default-entry.patch
|
||||
Patch260: 0001-fs-xfs-Add-new-superblock-features-added-in-Linux-6..patch
|
||||
Patch261: 0002-fs-xfs-Fix-grub_xfs_iterate_dir-return-value-in-case.patch
|
||||
Patch262: 0003-fs-xfs-fix-large-extent-counters-incompat-feature-su.patch
|
||||
Patch263: 0001-autofs-Ignore-zfs-not-found.patch
|
||||
Patch264: 0001-s390x-emu-Pass-through-PAES-cipher-as-AES.patch
|
||||
Patch265: 0001-ieee1275-adding-failure-check-condition-on-ibm-secur.patch
|
||||
Patch266: 0002-ieee1275-Platform-Keystore-PKS-Support.patch
|
||||
Patch267: 0003-ieee1275-Read-the-DB-and-DBX-secure-boot-variables.patch
|
||||
Patch268: 0004-appendedsig-The-creation-of-trusted-and-distrusted-l.patch
|
||||
Patch269: 0005-appendedsig-While-verifying-the-kernel-use-trusted-a.patch
|
||||
Patch270: 0006-powerpc_ieee1275-set-use_static_keys-flag.patch
|
||||
Patch271: 0007-appendedsig-Reads-the-default-DB-keys-from-ELF-Note.patch
|
||||
Patch272: 0008-appendedsig-The-grub-command-s-trusted-and-distruste.patch
|
||||
Patch273: 0009-appendedsig-documentation.patch
|
||||
Patch274: 0001-ofpath-Add-error-check-in-NVMEoF-device-translation.patch
|
||||
|
||||
%if 0%{?suse_version} <= 1600
|
||||
%if 0%{?suse_version} < 1600
|
||||
Requires: gettext-runtime
|
||||
%if 0%{?suse_version} >= 1140
|
||||
%ifnarch s390x
|
||||
@@ -466,7 +474,7 @@ Recommends: memtest86+
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
# Always requires a default cpu-platform package
|
||||
Requires: grub2-%{grubarch} = %{version}-%{release}
|
||||
%else
|
||||
@@ -487,7 +495,7 @@ highly configurable and customizable bootloader with modular
|
||||
architecture. It support rich scale of kernel formats, file systems,
|
||||
computer architectures and hardware devices.
|
||||
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
%package common
|
||||
Summary: Utilies to manage grub
|
||||
Group: System/Boot
|
||||
@@ -524,7 +532,7 @@ This package includes user space utlities to manage GRUB on your system.
|
||||
Summary: Upstream branding for GRUB2's graphical console
|
||||
Group: System/Fhs
|
||||
BuildArch: noarch
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
Requires: %{name}-common = %{version}
|
||||
%else
|
||||
Requires: %{name} = %{version}
|
||||
@@ -541,7 +549,7 @@ Group: System/Boot
|
||||
%if "%{platform}" != "emu"
|
||||
BuildArch: noarch
|
||||
%endif
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
Requires: %{name}-common = %{version}
|
||||
Requires(post): %{name}-common = %{version}
|
||||
%else
|
||||
@@ -595,7 +603,7 @@ BuildArch: noarch
|
||||
# Without it grub-install is broken so break the package as well if unavailable
|
||||
Requires: efibootmgr
|
||||
Requires(post): efibootmgr
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
Requires: %{name}-common = %{version}
|
||||
Requires(post): %{name}-common = %{version}
|
||||
%else
|
||||
@@ -613,7 +621,7 @@ bootloader with modular architecture. It supports rich variety of kernel format
|
||||
file systems, computer architectures and hardware devices. This subpackage
|
||||
provides support for EFI systems.
|
||||
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
%package %{grubefiarch}-bls
|
||||
Summary: Image for Boot Loader Specification (BLS) support on %{grubefiarch}
|
||||
Group: System/Boot
|
||||
@@ -699,7 +707,7 @@ https://www.cnblogs.com/coryxie/archive/2013/03/12/2956807.html
|
||||
Summary: Grub2's snapper plugin
|
||||
Group: System/Fhs
|
||||
Requires: libxml2-tools
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
Requires: (grub2 or grub2-common)
|
||||
Supplements: ((grub2 or grub2-common) and snapper)
|
||||
%else
|
||||
@@ -717,7 +725,7 @@ Grub2's snapper plugin for advanced btrfs snapshot boot menu management
|
||||
Summary: Grub2's systemd-sleep plugin
|
||||
Group: System/Fhs
|
||||
Requires: util-linux
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
Requires: (grub2 or grub2-common)
|
||||
Supplements: ((grub2 or grub2-common) and systemd)
|
||||
%else
|
||||
@@ -872,7 +880,7 @@ mksquashfs ./fonts memdisk.sqsh -keep-as-directory -comp xz -quiet -no-progress
|
||||
./grub-mkimage -O %{grubefiarch} -o grub.efi --memdisk=./memdisk.sqsh --prefix= %{?sbat_generation:--sbat sbat.csv} \
|
||||
-d grub-core ${GRUB_MODULES}
|
||||
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
rm memdisk.sqsh
|
||||
|
||||
# Building grubbls.efi
|
||||
@@ -1133,7 +1141,7 @@ install -m 644 grub.efi %{buildroot}/%{_datadir}/%{name}/%{grubefiarch}/.
|
||||
%ifarch x86_64
|
||||
ln -srf %{buildroot}/%{_datadir}/%{name}/%{grubefiarch}/grub.efi %{buildroot}/%{_datadir}/%{name}/%{grubefiarch}/grub-tpm.efi
|
||||
%endif
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
install -m 644 grubbls.efi %{buildroot}/%{_datadir}/%{name}/%{grubefiarch}/.
|
||||
%endif
|
||||
|
||||
@@ -1157,7 +1165,7 @@ EoM
|
||||
%endif
|
||||
|
||||
%ifarch x86_64 aarch64
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
export BRP_PESIGN_FILES="%{_datadir}/%{name}/%{grubefiarch}/grub.efi %{_datadir}/%{name}/%{grubefiarch}/grubbls.efi"
|
||||
%else
|
||||
export BRP_PESIGN_FILES="%{_datadir}/%{name}/%{grubefiarch}/grub.efi"
|
||||
@@ -1298,7 +1306,7 @@ grep -E ${EXTRA_PATTERN} %{grubarch}-mod-all.lst > %{grubarch}-mod-extras.lst
|
||||
%fdupes %buildroot%{_libdir}
|
||||
%fdupes %buildroot%{_datadir}
|
||||
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
%pre common
|
||||
%else
|
||||
|
||||
@@ -1306,7 +1314,7 @@ grep -E ${EXTRA_PATTERN} %{grubarch}-mod-all.lst > %{grubarch}-mod-extras.lst
|
||||
%endif
|
||||
%service_add_pre grub2-once.service
|
||||
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
%post common
|
||||
%else
|
||||
|
||||
@@ -1339,7 +1347,7 @@ grep -E ${EXTRA_PATTERN} %{grubarch}-mod-all.lst > %{grubarch}-mod-extras.lst
|
||||
|
||||
%endif
|
||||
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
%preun common
|
||||
%else
|
||||
|
||||
@@ -1347,7 +1355,7 @@ grep -E ${EXTRA_PATTERN} %{grubarch}-mod-all.lst > %{grubarch}-mod-extras.lst
|
||||
%endif
|
||||
%service_del_preun grub2-once.service
|
||||
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
%postun common
|
||||
%else
|
||||
|
||||
@@ -1355,7 +1363,7 @@ grep -E ${EXTRA_PATTERN} %{grubarch}-mod-all.lst > %{grubarch}-mod-extras.lst
|
||||
%endif
|
||||
%service_del_postun grub2-once.service
|
||||
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
%files
|
||||
%else
|
||||
|
||||
@@ -1370,7 +1378,7 @@ grep -E ${EXTRA_PATTERN} %{grubarch}-mod-all.lst > %{grubarch}-mod-extras.lst
|
||||
%doc README.ibm3215
|
||||
%endif
|
||||
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
%files common -f %{name}.lang
|
||||
%defattr(-,root,root,-)
|
||||
%endif
|
||||
@@ -1567,7 +1575,7 @@ grep -E ${EXTRA_PATTERN} %{grubarch}-mod-all.lst > %{grubarch}-mod-extras.lst
|
||||
%{sysefidir}/grub.der
|
||||
%endif
|
||||
|
||||
%if 0%{?suse_version} > 1600
|
||||
%if 0%{?suse_version} >= 1600
|
||||
%files %{grubefiarch}-bls
|
||||
%defattr(-,root,root,-)
|
||||
%{_datadir}/%{name}/%{grubefiarch}/grubbls.efi
|
||||
|
Reference in New Issue
Block a user