Merge ~juliank/grub/+git/ubuntu:ubuntu into ~ubuntu-core-dev/grub/+git/ubuntu:ubuntu

Proposed by Julian Andres Klode
Status: Merged
Merged at revision: ab6f97c7c85cfdc0558dc0af95a6ce0b2050653e
Proposed branch: ~juliank/grub/+git/ubuntu:ubuntu
Merge into: ~ubuntu-core-dev/grub/+git/ubuntu:ubuntu
Diff against target: 196 lines (+119/-2)
5 files modified
debian/.git-dpm (+2/-2)
debian/changelog (+6/-0)
debian/patches/0076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch (+86/-0)
debian/patches/series (+1/-0)
grub-core/commands/smbios.c (+24/-0)
Reviewer Review Type Date Requested Status
Chris Coulson (community) Approve
Dimitri John Ledkov Approve
Review via email: mp+380548@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Julian Andres Klode (juliank) wrote :

This goes into signed grub image and is needed for OEM work.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

One could have implemented the filtering without a new memory allocation; but that has been discussed on the upstream mailing list and this implementation is more trivial.

review: Approve
Revision history for this message
Chris Coulson (chrisccoulson) wrote :

This looks ok to me.

review: Approve
Revision history for this message
Seth Arnold (seth-arnold) wrote :

I've marked a spot where a char comparison may not necessarily be useful on systems with signed-by-default chars like the s390. Does this code ever run on any of those architectures?

Thanks

Revision history for this message
Dimitri John Ledkov (xnox) wrote :
Download full text (4.5 KiB)

No, s390x does not use grub. It uses zipl (z itial program load).

PowerPC uses prep partitions & petiboot.

Some armhf, arm64, riscv64 use grub.

Amd64 uses grub.

i386 is dead to us.

On Wed, 11 Mar 2020, 17:00 Seth Arnold, <email address hidden> wrote:

> I've marked a spot where a char comparison may not necessarily be useful
> on systems with signed-by-default chars like the s390. Does this code ever
> run on any of those architectures?
>
> Thanks
>
> Diff comments:
>
> > diff --git
> a/debian/patches/0076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch
> b/debian/patches/0076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch
> > new file mode 100644
> > index 0000000..f656509
> > --- /dev/null
> > +++
> b/debian/patches/0076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch
> > @@ -0,0 +1,86 @@
> > +From 79d4ae1df7b63ef106a85ad18bfedb6d709ef29a Mon Sep 17 00:00:00 2001
> > +From: Julian Andres Klode <email address hidden>
> > +Date: Tue, 3 Mar 2020 16:06:34 +0100
> > +Subject: smbios: Add a --linux argument to apply linux modalias-like
> filtering
> > +
> > +Linux creates modalias strings by filtering out non-ASCII, space,
> > +and colon characters. Provide an option that does the same filtering
> > +so people can create a modalias string in GRUB, and then match their
> > +modalias patterns against it.
> > +
> > +Signed-off-by: Julian Andres Klode <email address hidden>
> > +Reviewed-by: Daniel Kiper <email address hidden>
> > +Origin: upstream,
> https://git.savannah.gnu.org/cgit/grub.git/commit/?id=87049f9716fb095aecb595fb8f45497bbbb1b4a2
> > +---
> > + grub-core/commands/smbios.c | 24 ++++++++++++++++++++++++
> > + 1 file changed, 24 insertions(+)
> > +
> > +diff --git a/grub-core/commands/smbios.c b/grub-core/commands/smbios.c
> > +index 7a6a391fc..1a9086ddd 100644
> > +--- a/grub-core/commands/smbios.c
> > ++++ b/grub-core/commands/smbios.c
> > +@@ -64,6 +64,21 @@ grub_smbios_get_eps3 (void)
> > + return eps;
> > + }
> > +
> > ++static char *
> > ++linux_string (const char *value)
> > ++{
> > ++ char *out = grub_malloc( grub_strlen (value) + 1);
> > ++ const char *src = value;
> > ++ char *dst = out;
> > ++
> > ++ for (; *src; src++)
> > ++ if (*src > ' ' && *src < 127 && *src != ':')
>
> Is grub ever used on architectures with signed-by-default chars like
> s390x? (Are there others?)
>
> > ++ *dst++ = *src;
> > ++
> > ++ *dst = 0;
> > ++ return out;
> > ++}
> > ++
> > + /*
> > + * These functions convert values from the various SMBIOS structure
> field types
> > + * into a string formatted to be returned to the user. They expect
> that the
> > +@@ -176,6 +191,7 @@ static const struct {
> > + /* List command options, with structure field getters ordered as
> above. */
> > + #define FIRST_GETTER_OPT (3)
> > + #define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors))
> > ++#define LINUX_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors) + 1)
> > +
> > + static const struct grub_arg_option options[] = {
> > + {"type", 't', 0, N_("Match structures with the given type."),
> > +@@ -198,6 +214,8 @@ static const struct grub_arg_option options[] = {
> >...

Read more...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/.git-dpm b/debian/.git-dpm
index 77b21d2..89761e2 100644
--- a/debian/.git-dpm
+++ b/debian/.git-dpm
@@ -1,6 +1,6 @@
1# see git-dpm(1) from git-dpm package1# see git-dpm(1) from git-dpm package
23fd849d69e8213885f3fe4b6ad88cf6a41a7b863279d4ae1df7b63ef106a85ad18bfedb6d709ef29a
33fd849d69e8213885f3fe4b6ad88cf6a41a7b863379d4ae1df7b63ef106a85ad18bfedb6d709ef29a
4578bb115fbd47e1c464696f1f8d6183e5443975d4578bb115fbd47e1c464696f1f8d6183e5443975d
5578bb115fbd47e1c464696f1f8d6183e5443975d5578bb115fbd47e1c464696f1f8d6183e5443975d
6grub2_2.04.orig.tar.xz6grub2_2.04.orig.tar.xz
diff --git a/debian/changelog b/debian/changelog
index e36f7a8..aa3f194 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
1grub2 (2.04-1ubuntu22) UNRELEASED; urgency=medium
2
3 * smbios: Add a --linux argument to apply linux modalias-like filtering
4
5 -- Julian Andres Klode <juliank@ubuntu.com> Wed, 11 Mar 2020 14:16:40 +0100
6
1grub2 (2.04-1ubuntu21) focal; urgency=medium7grub2 (2.04-1ubuntu21) focal; urgency=medium
28
3 * Make ZFS menu generation depending on new zsysd binary instead of eoan9 * Make ZFS menu generation depending on new zsysd binary instead of eoan
diff --git a/debian/patches/0076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch b/debian/patches/0076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch
4new file mode 10064410new file mode 100644
index 0000000..f656509
--- /dev/null
+++ b/debian/patches/0076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch
@@ -0,0 +1,86 @@
1From 79d4ae1df7b63ef106a85ad18bfedb6d709ef29a Mon Sep 17 00:00:00 2001
2From: Julian Andres Klode <julian.klode@canonical.com>
3Date: Tue, 3 Mar 2020 16:06:34 +0100
4Subject: smbios: Add a --linux argument to apply linux modalias-like filtering
5
6Linux creates modalias strings by filtering out non-ASCII, space,
7and colon characters. Provide an option that does the same filtering
8so people can create a modalias string in GRUB, and then match their
9modalias patterns against it.
10
11Signed-off-by: Julian Andres Klode <julian.klode@canonical.com>
12Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
13Origin: upstream, https://git.savannah.gnu.org/cgit/grub.git/commit/?id=87049f9716fb095aecb595fb8f45497bbbb1b4a2
14---
15 grub-core/commands/smbios.c | 24 ++++++++++++++++++++++++
16 1 file changed, 24 insertions(+)
17
18diff --git a/grub-core/commands/smbios.c b/grub-core/commands/smbios.c
19index 7a6a391fc..1a9086ddd 100644
20--- a/grub-core/commands/smbios.c
21+++ b/grub-core/commands/smbios.c
22@@ -64,6 +64,21 @@ grub_smbios_get_eps3 (void)
23 return eps;
24 }
25
26+static char *
27+linux_string (const char *value)
28+{
29+ char *out = grub_malloc( grub_strlen (value) + 1);
30+ const char *src = value;
31+ char *dst = out;
32+
33+ for (; *src; src++)
34+ if (*src > ' ' && *src < 127 && *src != ':')
35+ *dst++ = *src;
36+
37+ *dst = 0;
38+ return out;
39+}
40+
41 /*
42 * These functions convert values from the various SMBIOS structure field types
43 * into a string formatted to be returned to the user. They expect that the
44@@ -176,6 +191,7 @@ static const struct {
45 /* List command options, with structure field getters ordered as above. */
46 #define FIRST_GETTER_OPT (3)
47 #define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors))
48+#define LINUX_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors) + 1)
49
50 static const struct grub_arg_option options[] = {
51 {"type", 't', 0, N_("Match structures with the given type."),
52@@ -198,6 +214,8 @@ static const struct grub_arg_option options[] = {
53 N_("offset"), ARG_TYPE_INT},
54 {"set", '\0', 0, N_("Store the value in the given variable name."),
55 N_("variable"), ARG_TYPE_STRING},
56+ {"linux", '\0', 0, N_("Filter the result like linux does."),
57+ N_("variable"), ARG_TYPE_NONE},
58 {0, 0, 0, 0, 0, 0}
59 };
60
61@@ -261,6 +279,7 @@ grub_cmd_smbios (grub_extcmd_context_t ctxt,
62
63 const grub_uint8_t *structure;
64 const char *value;
65+ char *modified_value = NULL;
66 grub_int32_t option;
67 grub_int8_t field_type = -1;
68 grub_uint8_t i;
69@@ -334,12 +353,17 @@ grub_cmd_smbios (grub_extcmd_context_t ctxt,
70 return grub_error (GRUB_ERR_IO,
71 N_("failed to retrieve the structure field"));
72
73+ if (state[LINUX_OPT].set)
74+ value = modified_value = linux_string (value);
75+
76 /* Store or print the formatted value. */
77 if (state[SETTER_OPT].set)
78 grub_env_set (state[SETTER_OPT].arg, value);
79 else
80 grub_printf ("%s\n", value);
81
82+ grub_free(modified_value);
83+
84 return GRUB_ERR_NONE;
85 }
86
diff --git a/debian/patches/series b/debian/patches/series
index bb417c4..4666699 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -73,3 +73,4 @@ cherrypick-lsefisystab-define-smbios3.patch
73cherrypick-smbios-module.patch73cherrypick-smbios-module.patch
74cherrypick-lsefisystab-show-dtb.patch74cherrypick-lsefisystab-show-dtb.patch
750075-uefi-firmware-rename-fwsetup-menuentry-to-UEFI-Firmw.patch750075-uefi-firmware-rename-fwsetup-menuentry-to-UEFI-Firmw.patch
760076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch
diff --git a/grub-core/commands/smbios.c b/grub-core/commands/smbios.c
index 7a6a391..1a9086d 100644
--- a/grub-core/commands/smbios.c
+++ b/grub-core/commands/smbios.c
@@ -64,6 +64,21 @@ grub_smbios_get_eps3 (void)
64 return eps;64 return eps;
65}65}
6666
67static char *
68linux_string (const char *value)
69{
70 char *out = grub_malloc( grub_strlen (value) + 1);
71 const char *src = value;
72 char *dst = out;
73
74 for (; *src; src++)
75 if (*src > ' ' && *src < 127 && *src != ':')
76 *dst++ = *src;
77
78 *dst = 0;
79 return out;
80}
81
67/*82/*
68 * These functions convert values from the various SMBIOS structure field types83 * These functions convert values from the various SMBIOS structure field types
69 * into a string formatted to be returned to the user. They expect that the84 * into a string formatted to be returned to the user. They expect that the
@@ -176,6 +191,7 @@ static const struct {
176/* List command options, with structure field getters ordered as above. */191/* List command options, with structure field getters ordered as above. */
177#define FIRST_GETTER_OPT (3)192#define FIRST_GETTER_OPT (3)
178#define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors))193#define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors))
194#define LINUX_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors) + 1)
179195
180static const struct grub_arg_option options[] = {196static const struct grub_arg_option options[] = {
181 {"type", 't', 0, N_("Match structures with the given type."),197 {"type", 't', 0, N_("Match structures with the given type."),
@@ -198,6 +214,8 @@ static const struct grub_arg_option options[] = {
198 N_("offset"), ARG_TYPE_INT},214 N_("offset"), ARG_TYPE_INT},
199 {"set", '\0', 0, N_("Store the value in the given variable name."),215 {"set", '\0', 0, N_("Store the value in the given variable name."),
200 N_("variable"), ARG_TYPE_STRING},216 N_("variable"), ARG_TYPE_STRING},
217 {"linux", '\0', 0, N_("Filter the result like linux does."),
218 N_("variable"), ARG_TYPE_NONE},
201 {0, 0, 0, 0, 0, 0}219 {0, 0, 0, 0, 0, 0}
202};220};
203221
@@ -261,6 +279,7 @@ grub_cmd_smbios (grub_extcmd_context_t ctxt,
261279
262 const grub_uint8_t *structure;280 const grub_uint8_t *structure;
263 const char *value;281 const char *value;
282 char *modified_value = NULL;
264 grub_int32_t option;283 grub_int32_t option;
265 grub_int8_t field_type = -1;284 grub_int8_t field_type = -1;
266 grub_uint8_t i;285 grub_uint8_t i;
@@ -334,12 +353,17 @@ grub_cmd_smbios (grub_extcmd_context_t ctxt,
334 return grub_error (GRUB_ERR_IO,353 return grub_error (GRUB_ERR_IO,
335 N_("failed to retrieve the structure field"));354 N_("failed to retrieve the structure field"));
336355
356 if (state[LINUX_OPT].set)
357 value = modified_value = linux_string (value);
358
337 /* Store or print the formatted value. */359 /* Store or print the formatted value. */
338 if (state[SETTER_OPT].set)360 if (state[SETTER_OPT].set)
339 grub_env_set (state[SETTER_OPT].arg, value);361 grub_env_set (state[SETTER_OPT].arg, value);
340 else362 else
341 grub_printf ("%s\n", value);363 grub_printf ("%s\n", value);
342364
365 grub_free(modified_value);
366
343 return GRUB_ERR_NONE;367 return GRUB_ERR_NONE;
344}368}
345369

Subscribers

People subscribed via source and target branches