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
1diff --git a/debian/.git-dpm b/debian/.git-dpm
2index 77b21d2..89761e2 100644
3--- a/debian/.git-dpm
4+++ b/debian/.git-dpm
5@@ -1,6 +1,6 @@
6 # see git-dpm(1) from git-dpm package
7-3fd849d69e8213885f3fe4b6ad88cf6a41a7b863
8-3fd849d69e8213885f3fe4b6ad88cf6a41a7b863
9+79d4ae1df7b63ef106a85ad18bfedb6d709ef29a
10+79d4ae1df7b63ef106a85ad18bfedb6d709ef29a
11 578bb115fbd47e1c464696f1f8d6183e5443975d
12 578bb115fbd47e1c464696f1f8d6183e5443975d
13 grub2_2.04.orig.tar.xz
14diff --git a/debian/changelog b/debian/changelog
15index e36f7a8..aa3f194 100644
16--- a/debian/changelog
17+++ b/debian/changelog
18@@ -1,3 +1,9 @@
19+grub2 (2.04-1ubuntu22) UNRELEASED; urgency=medium
20+
21+ * smbios: Add a --linux argument to apply linux modalias-like filtering
22+
23+ -- Julian Andres Klode <juliank@ubuntu.com> Wed, 11 Mar 2020 14:16:40 +0100
24+
25 grub2 (2.04-1ubuntu21) focal; urgency=medium
26
27 * Make ZFS menu generation depending on new zsysd binary instead of eoan
28diff --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
29new file mode 100644
30index 0000000..f656509
31--- /dev/null
32+++ b/debian/patches/0076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch
33@@ -0,0 +1,86 @@
34+From 79d4ae1df7b63ef106a85ad18bfedb6d709ef29a Mon Sep 17 00:00:00 2001
35+From: Julian Andres Klode <julian.klode@canonical.com>
36+Date: Tue, 3 Mar 2020 16:06:34 +0100
37+Subject: smbios: Add a --linux argument to apply linux modalias-like filtering
38+
39+Linux creates modalias strings by filtering out non-ASCII, space,
40+and colon characters. Provide an option that does the same filtering
41+so people can create a modalias string in GRUB, and then match their
42+modalias patterns against it.
43+
44+Signed-off-by: Julian Andres Klode <julian.klode@canonical.com>
45+Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
46+Origin: upstream, https://git.savannah.gnu.org/cgit/grub.git/commit/?id=87049f9716fb095aecb595fb8f45497bbbb1b4a2
47+---
48+ grub-core/commands/smbios.c | 24 ++++++++++++++++++++++++
49+ 1 file changed, 24 insertions(+)
50+
51+diff --git a/grub-core/commands/smbios.c b/grub-core/commands/smbios.c
52+index 7a6a391fc..1a9086ddd 100644
53+--- a/grub-core/commands/smbios.c
54++++ b/grub-core/commands/smbios.c
55+@@ -64,6 +64,21 @@ grub_smbios_get_eps3 (void)
56+ return eps;
57+ }
58+
59++static char *
60++linux_string (const char *value)
61++{
62++ char *out = grub_malloc( grub_strlen (value) + 1);
63++ const char *src = value;
64++ char *dst = out;
65++
66++ for (; *src; src++)
67++ if (*src > ' ' && *src < 127 && *src != ':')
68++ *dst++ = *src;
69++
70++ *dst = 0;
71++ return out;
72++}
73++
74+ /*
75+ * These functions convert values from the various SMBIOS structure field types
76+ * into a string formatted to be returned to the user. They expect that the
77+@@ -176,6 +191,7 @@ static const struct {
78+ /* List command options, with structure field getters ordered as above. */
79+ #define FIRST_GETTER_OPT (3)
80+ #define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors))
81++#define LINUX_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors) + 1)
82+
83+ static const struct grub_arg_option options[] = {
84+ {"type", 't', 0, N_("Match structures with the given type."),
85+@@ -198,6 +214,8 @@ static const struct grub_arg_option options[] = {
86+ N_("offset"), ARG_TYPE_INT},
87+ {"set", '\0', 0, N_("Store the value in the given variable name."),
88+ N_("variable"), ARG_TYPE_STRING},
89++ {"linux", '\0', 0, N_("Filter the result like linux does."),
90++ N_("variable"), ARG_TYPE_NONE},
91+ {0, 0, 0, 0, 0, 0}
92+ };
93+
94+@@ -261,6 +279,7 @@ grub_cmd_smbios (grub_extcmd_context_t ctxt,
95+
96+ const grub_uint8_t *structure;
97+ const char *value;
98++ char *modified_value = NULL;
99+ grub_int32_t option;
100+ grub_int8_t field_type = -1;
101+ grub_uint8_t i;
102+@@ -334,12 +353,17 @@ grub_cmd_smbios (grub_extcmd_context_t ctxt,
103+ return grub_error (GRUB_ERR_IO,
104+ N_("failed to retrieve the structure field"));
105+
106++ if (state[LINUX_OPT].set)
107++ value = modified_value = linux_string (value);
108++
109+ /* Store or print the formatted value. */
110+ if (state[SETTER_OPT].set)
111+ grub_env_set (state[SETTER_OPT].arg, value);
112+ else
113+ grub_printf ("%s\n", value);
114+
115++ grub_free(modified_value);
116++
117+ return GRUB_ERR_NONE;
118+ }
119+
120diff --git a/debian/patches/series b/debian/patches/series
121index bb417c4..4666699 100644
122--- a/debian/patches/series
123+++ b/debian/patches/series
124@@ -73,3 +73,4 @@ cherrypick-lsefisystab-define-smbios3.patch
125 cherrypick-smbios-module.patch
126 cherrypick-lsefisystab-show-dtb.patch
127 0075-uefi-firmware-rename-fwsetup-menuentry-to-UEFI-Firmw.patch
128+0076-smbios-Add-a-linux-argument-to-apply-linux-modalias-.patch
129diff --git a/grub-core/commands/smbios.c b/grub-core/commands/smbios.c
130index 7a6a391..1a9086d 100644
131--- a/grub-core/commands/smbios.c
132+++ b/grub-core/commands/smbios.c
133@@ -64,6 +64,21 @@ grub_smbios_get_eps3 (void)
134 return eps;
135 }
136
137+static char *
138+linux_string (const char *value)
139+{
140+ char *out = grub_malloc( grub_strlen (value) + 1);
141+ const char *src = value;
142+ char *dst = out;
143+
144+ for (; *src; src++)
145+ if (*src > ' ' && *src < 127 && *src != ':')
146+ *dst++ = *src;
147+
148+ *dst = 0;
149+ return out;
150+}
151+
152 /*
153 * These functions convert values from the various SMBIOS structure field types
154 * into a string formatted to be returned to the user. They expect that the
155@@ -176,6 +191,7 @@ static const struct {
156 /* List command options, with structure field getters ordered as above. */
157 #define FIRST_GETTER_OPT (3)
158 #define SETTER_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors))
159+#define LINUX_OPT (FIRST_GETTER_OPT + ARRAY_SIZE(field_extractors) + 1)
160
161 static const struct grub_arg_option options[] = {
162 {"type", 't', 0, N_("Match structures with the given type."),
163@@ -198,6 +214,8 @@ static const struct grub_arg_option options[] = {
164 N_("offset"), ARG_TYPE_INT},
165 {"set", '\0', 0, N_("Store the value in the given variable name."),
166 N_("variable"), ARG_TYPE_STRING},
167+ {"linux", '\0', 0, N_("Filter the result like linux does."),
168+ N_("variable"), ARG_TYPE_NONE},
169 {0, 0, 0, 0, 0, 0}
170 };
171
172@@ -261,6 +279,7 @@ grub_cmd_smbios (grub_extcmd_context_t ctxt,
173
174 const grub_uint8_t *structure;
175 const char *value;
176+ char *modified_value = NULL;
177 grub_int32_t option;
178 grub_int8_t field_type = -1;
179 grub_uint8_t i;
180@@ -334,12 +353,17 @@ grub_cmd_smbios (grub_extcmd_context_t ctxt,
181 return grub_error (GRUB_ERR_IO,
182 N_("failed to retrieve the structure field"));
183
184+ if (state[LINUX_OPT].set)
185+ value = modified_value = linux_string (value);
186+
187 /* Store or print the formatted value. */
188 if (state[SETTER_OPT].set)
189 grub_env_set (state[SETTER_OPT].arg, value);
190 else
191 grub_printf ("%s\n", value);
192
193+ grub_free(modified_value);
194+
195 return GRUB_ERR_NONE;
196 }
197

Subscribers

People subscribed via source and target branches