* [OE-core][PATCH] grub: update search parameter
@ 2026-02-26 8:19 Xiangyu Chen
2026-03-05 11:49 ` Paul Barker
0 siblings, 1 reply; 7+ messages in thread
From: Xiangyu Chen @ 2026-02-26 8:19 UTC (permalink / raw)
To: openembedded-core, arindam.nath
From: Xiangyu Chen <xiangyu.chen@windriver.com>
Grub would report an error message in boot stage as below:
"error: no such device: ((hd0,gpt1)/EFI/BOOT)/EFI/BOOT/grub.cfg"
Consequently, the root variable is not set, and the intended protection
against cross-device configuration loading (the purpose of the original 2014 commit)
is lost.
The most robust fix is to use the --hint parameter.
This separates the search target from the device hint, avoiding
fragile string concatenation and supporting both prefixed and
non-prefixed $cmdpath formats.
Fixes: 5ce73b6055ac ("grub: add cmdpath to grub configuration file")
Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
---
meta/recipes-bsp/grub/files/cfg | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meta/recipes-bsp/grub/files/cfg b/meta/recipes-bsp/grub/files/cfg
index 8ca53d24d7..8fe1a8d0c7 100644
--- a/meta/recipes-bsp/grub/files/cfg
+++ b/meta/recipes-bsp/grub/files/cfg
@@ -1,2 +1,2 @@
-search.file ($cmdpath)/EFI/BOOT/grub.cfg root
+search --file --set=root --hint-efi=$cmdpath /EFI/BOOT/grub.cfg
set prefix=($root)/EFI/BOOT
--
2.39.4
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [OE-core][PATCH] grub: update search parameter 2026-02-26 8:19 [OE-core][PATCH] grub: update search parameter Xiangyu Chen @ 2026-03-05 11:49 ` Paul Barker 2026-03-31 2:57 ` Xiangyu Chen 0 siblings, 1 reply; 7+ messages in thread From: Paul Barker @ 2026-03-05 11:49 UTC (permalink / raw) To: xiangyu.chen, openembedded-core, arindam.nath [-- Attachment #1: Type: text/plain, Size: 1541 bytes --] On Thu, 2026-02-26 at 16:19 +0800, Xiangyu Chen via lists.openembedded.org wrote: > From: Xiangyu Chen <xiangyu.chen@windriver.com> > > Grub would report an error message in boot stage as below: > > "error: no such device: ((hd0,gpt1)/EFI/BOOT)/EFI/BOOT/grub.cfg" > > Consequently, the root variable is not set, and the intended protection > against cross-device configuration loading (the purpose of the original 2014 commit) > is lost. > > The most robust fix is to use the --hint parameter. > This separates the search target from the device hint, avoiding > fragile string concatenation and supporting both prefixed and > non-prefixed $cmdpath formats. > > Fixes: 5ce73b6055ac ("grub: add cmdpath to grub configuration file") > Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com> > --- > meta/recipes-bsp/grub/files/cfg | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/meta/recipes-bsp/grub/files/cfg b/meta/recipes-bsp/grub/files/cfg > index 8ca53d24d7..8fe1a8d0c7 100644 > --- a/meta/recipes-bsp/grub/files/cfg > +++ b/meta/recipes-bsp/grub/files/cfg > @@ -1,2 +1,2 @@ > -search.file ($cmdpath)/EFI/BOOT/grub.cfg root > +search --file --set=root --hint-efi=$cmdpath /EFI/BOOT/grub.cfg I'm not sure that this can work for all use cases. The grub documentatation for hints says "First try the device HINT" (i.e. it's explicitly a device), whereas the documentation for cmdpath says that it is "an absolute directory name". Best regards, -- Paul Barker [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 252 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [OE-core][PATCH] grub: update search parameter 2026-03-05 11:49 ` Paul Barker @ 2026-03-31 2:57 ` Xiangyu Chen 2026-04-23 6:04 ` Xiangyu Chen 0 siblings, 1 reply; 7+ messages in thread From: Xiangyu Chen @ 2026-03-31 2:57 UTC (permalink / raw) To: Paul Barker, xiangyu.chen, openembedded-core, arindam.nath Hi Paul, On 3/5/26 19:49, Paul Barker wrote: > I'm not sure that this can work for all use cases. The grub > documentatation for hints says "First try the device HINT" (i.e. it's > explicitly a device), whereas the documentation for cmdpath says that it > is "an absolute directory name". While the documentation defines $cmdpath as a directory and hints as devices, grub’s internal implementation of grub_disk_open (grub-core/kern/disk.c [1]) is designed to handle this exact "device+path" format. When a hint like (hd0,gpt1)/EFI/BOOT/ is passed, grub_disk_open calls find_part_sep to locate the partition/path delimiter. It then uses grub_memcpy to extract only the device part (e.g., (hd0) into the raw buffer for the disk driver. The remaining string (gpt1)/EFI/BOOT/) is passed to grub_partition_probe, which identifies the partition and gracefully ignores the trailing directory path. The current syntax ($cmdpath) results in double parentheses ((hd0...)) if the variable is already populated. In grub_disk_open, this extracts a malformed device name ((hd0 which no driver can open, triggering a hard no such device error. Ref: [1] https://elixir.bootlin.com/grub/grub-2.14/source/grub-core/kern/disk.c#L192 Br, Xiangyu ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [OE-core][PATCH] grub: update search parameter 2026-03-31 2:57 ` Xiangyu Chen @ 2026-04-23 6:04 ` Xiangyu Chen 2026-04-23 6:38 ` Yoann Congal 0 siblings, 1 reply; 7+ messages in thread From: Xiangyu Chen @ 2026-04-23 6:04 UTC (permalink / raw) To: openembedded-core, Richard Purdie; +Cc: Paul Barker, xiangyu.chen, arindam.nath Hi Richard, Since the behavior was found in OE scarthgap branch, could you please help to cherry-pick this commit: 42b530581f72 ("grub: update search parameter") to whinlatter and scarthgap branch? Thanks. Br, Xiangyu 在 2026/3/31 10:57, Xiangyu Chen 写道: > Hi Paul, > > > On 3/5/26 19:49, Paul Barker wrote: >> I'm not sure that this can work for all use cases. The grub >> documentatation for hints says "First try the device HINT" (i.e. it's >> explicitly a device), whereas the documentation for cmdpath says that it >> is "an absolute directory name". > While the documentation defines $cmdpath as a directory and hints as > devices, grub’s internal implementation of > grub_disk_open (grub-core/kern/disk.c [1]) is designed to handle this > exact "device+path" format. > > When a hint like (hd0,gpt1)/EFI/BOOT/ is passed, grub_disk_open calls > find_part_sep to locate the partition/path delimiter. > It then uses grub_memcpy to extract only the device part (e.g., (hd0) > into the raw buffer for the disk driver. > > The remaining string (gpt1)/EFI/BOOT/) is passed to > grub_partition_probe, which identifies the partition and gracefully > ignores the trailing directory path. > > The current syntax ($cmdpath) results in double parentheses ((hd0...)) > if the variable is already populated. > In grub_disk_open, this extracts a malformed device name ((hd0 which > no driver can open, triggering a hard no such device error. > > > Ref: > > [1] > https://elixir.bootlin.com/grub/grub-2.14/source/grub-core/kern/disk.c#L192 > > > Br, > > Xiangyu > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [OE-core][PATCH] grub: update search parameter 2026-04-23 6:04 ` Xiangyu Chen @ 2026-04-23 6:38 ` Yoann Congal 2026-04-23 7:18 ` Xiangyu Chen 0 siblings, 1 reply; 7+ messages in thread From: Yoann Congal @ 2026-04-23 6:38 UTC (permalink / raw) To: xiangyu.chen, openembedded-core, Richard Purdie; +Cc: Paul Barker, arindam.nath On Thu Apr 23, 2026 at 8:04 AM CEST, Xiangyu Chen via lists.openembedded.org wrote: > Hi Richard, > > > Since the behavior was found in OE scarthgap branch, could you please > help to cherry-pick this > > commit: 42b530581f72 ("grub: update search parameter") to whinlatter and > scarthgap branch? Hello, For whinlatter, that will be too late (the last build has already left for QA). For scarthgap, I would need to look into it (change does not look trivial). Can you send a rebased patch targeting scarthgap? Thanks! > > > Thanks. > > > Br, > > Xiangyu > > 在 2026/3/31 10:57, Xiangyu Chen 写道: >> Hi Paul, >> >> >> On 3/5/26 19:49, Paul Barker wrote: >>> I'm not sure that this can work for all use cases. The grub >>> documentatation for hints says "First try the device HINT" (i.e. it's >>> explicitly a device), whereas the documentation for cmdpath says that it >>> is "an absolute directory name". >> While the documentation defines $cmdpath as a directory and hints as >> devices, grub’s internal implementation of >> grub_disk_open (grub-core/kern/disk.c [1]) is designed to handle this >> exact "device+path" format. >> >> When a hint like (hd0,gpt1)/EFI/BOOT/ is passed, grub_disk_open calls >> find_part_sep to locate the partition/path delimiter. >> It then uses grub_memcpy to extract only the device part (e.g., (hd0) >> into the raw buffer for the disk driver. >> >> The remaining string (gpt1)/EFI/BOOT/) is passed to >> grub_partition_probe, which identifies the partition and gracefully >> ignores the trailing directory path. >> >> The current syntax ($cmdpath) results in double parentheses ((hd0...)) >> if the variable is already populated. >> In grub_disk_open, this extracts a malformed device name ((hd0 which >> no driver can open, triggering a hard no such device error. >> >> >> Ref: >> >> [1] >> https://elixir.bootlin.com/grub/grub-2.14/source/grub-core/kern/disk.c#L192 >> >> >> Br, >> >> Xiangyu >> -- Yoann Congal Smile ECS ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [OE-core][PATCH] grub: update search parameter 2026-04-23 6:38 ` Yoann Congal @ 2026-04-23 7:18 ` Xiangyu Chen 2026-04-23 7:29 ` Yoann Congal 0 siblings, 1 reply; 7+ messages in thread From: Xiangyu Chen @ 2026-04-23 7:18 UTC (permalink / raw) To: yoann.congal, xiangyu.chen, openembedded-core, Richard Purdie Cc: Paul Barker, arindam.nath 在 2026/4/23 14:38, Yoann Congal via lists.openembedded.org 写道: > CAUTION: This email comes from a non Wind River email account! > Do not click links or open attachments unless you recognize the sender and know the content is safe. > > On Thu Apr 23, 2026 at 8:04 AM CEST, Xiangyu Chen via lists.openembedded.org wrote: >> Hi Richard, >> >> >> Since the behavior was found in OE scarthgap branch, could you please >> help to cherry-pick this >> >> commit: 42b530581f72 ("grub: update search parameter") to whinlatter and >> scarthgap branch? > Hello, > > For whinlatter, that will be too late (the last build has already left for > QA). > > For scarthgap, I would need to look into it (change does not look > trivial). Can you send a rebased patch targeting scarthgap? > > Thanks! Thanks for your info, a rebased patch will be sent later. Br, Xiangyu > >> >> Thanks. >> >> >> Br, >> >> Xiangyu >> >> 在 2026/3/31 10:57, Xiangyu Chen 写道: >>> Hi Paul, >>> >>> >>> On 3/5/26 19:49, Paul Barker wrote: >>>> I'm not sure that this can work for all use cases. The grub >>>> documentatation for hints says "First try the device HINT" (i.e. it's >>>> explicitly a device), whereas the documentation for cmdpath says that it >>>> is "an absolute directory name". >>> While the documentation defines $cmdpath as a directory and hints as >>> devices, grub’s internal implementation of >>> grub_disk_open (grub-core/kern/disk.c [1]) is designed to handle this >>> exact "device+path" format. >>> >>> When a hint like (hd0,gpt1)/EFI/BOOT/ is passed, grub_disk_open calls >>> find_part_sep to locate the partition/path delimiter. >>> It then uses grub_memcpy to extract only the device part (e.g., (hd0) >>> into the raw buffer for the disk driver. >>> >>> The remaining string (gpt1)/EFI/BOOT/) is passed to >>> grub_partition_probe, which identifies the partition and gracefully >>> ignores the trailing directory path. >>> >>> The current syntax ($cmdpath) results in double parentheses ((hd0...)) >>> if the variable is already populated. >>> In grub_disk_open, this extracts a malformed device name ((hd0 which >>> no driver can open, triggering a hard no such device error. >>> >>> >>> Ref: >>> >>> [1] >>> https://elixir.bootlin.com/grub/grub-2.14/source/grub-core/kern/disk.c#L192 >>> >>> >>> Br, >>> >>> Xiangyu >>> > > -- > Yoann Congal > Smile ECS > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#235740): https://lists.openembedded.org/g/openembedded-core/message/235740 > Mute This Topic: https://lists.openembedded.org/mt/118009422/7175143 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [xiangyu.chen@eng.windriver.com] > -=-=-=-=-=-=-=-=-=-=-=- > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [OE-core][PATCH] grub: update search parameter 2026-04-23 7:18 ` Xiangyu Chen @ 2026-04-23 7:29 ` Yoann Congal 0 siblings, 0 replies; 7+ messages in thread From: Yoann Congal @ 2026-04-23 7:29 UTC (permalink / raw) To: Xiangyu Chen, openembedded-core, Richard Purdie; +Cc: Paul Barker, arindam.nath On Thu Apr 23, 2026 at 9:18 AM CEST, Xiangyu Chen wrote: > > 在 2026/4/23 14:38, Yoann Congal via lists.openembedded.org 写道: >> CAUTION: This email comes from a non Wind River email account! >> Do not click links or open attachments unless you recognize the sender and know the content is safe. >> >> On Thu Apr 23, 2026 at 8:04 AM CEST, Xiangyu Chen via lists.openembedded.org wrote: >>> Hi Richard, >>> >>> >>> Since the behavior was found in OE scarthgap branch, could you please >>> help to cherry-pick this >>> >>> commit: 42b530581f72 ("grub: update search parameter") to whinlatter and >>> scarthgap branch? >> Hello, >> >> For whinlatter, that will be too late (the last build has already left for >> QA). >> >> For scarthgap, I would need to look into it (change does not look >> trivial). Can you send a rebased patch targeting scarthgap? >> >> Thanks! > > Thanks for your info, a rebased patch will be sent later. Received, thanks! I will consider it for the next review cycle. > > > Br, > > Xiangyu > >> >>> >>> Thanks. >>> >>> >>> Br, >>> >>> Xiangyu >>> >>> 在 2026/3/31 10:57, Xiangyu Chen 写道: >>>> Hi Paul, >>>> >>>> >>>> On 3/5/26 19:49, Paul Barker wrote: >>>>> I'm not sure that this can work for all use cases. The grub >>>>> documentatation for hints says "First try the device HINT" (i.e. it's >>>>> explicitly a device), whereas the documentation for cmdpath says that it >>>>> is "an absolute directory name". >>>> While the documentation defines $cmdpath as a directory and hints as >>>> devices, grub’s internal implementation of >>>> grub_disk_open (grub-core/kern/disk.c [1]) is designed to handle this >>>> exact "device+path" format. >>>> >>>> When a hint like (hd0,gpt1)/EFI/BOOT/ is passed, grub_disk_open calls >>>> find_part_sep to locate the partition/path delimiter. >>>> It then uses grub_memcpy to extract only the device part (e.g., (hd0) >>>> into the raw buffer for the disk driver. >>>> >>>> The remaining string (gpt1)/EFI/BOOT/) is passed to >>>> grub_partition_probe, which identifies the partition and gracefully >>>> ignores the trailing directory path. >>>> >>>> The current syntax ($cmdpath) results in double parentheses ((hd0...)) >>>> if the variable is already populated. >>>> In grub_disk_open, this extracts a malformed device name ((hd0 which >>>> no driver can open, triggering a hard no such device error. >>>> >>>> >>>> Ref: >>>> >>>> [1] >>>> https://elixir.bootlin.com/grub/grub-2.14/source/grub-core/kern/disk.c#L192 >>>> >>>> >>>> Br, >>>> >>>> Xiangyu >>>> >> >> -- >> Yoann Congal >> Smile ECS >> >> >> -=-=-=-=-=-=-=-=-=-=-=- >> Links: You receive all messages sent to this group. >> View/Reply Online (#235740): https://lists.openembedded.org/g/openembedded-core/message/235740 >> Mute This Topic: https://lists.openembedded.org/mt/118009422/7175143 >> Group Owner: openembedded-core+owner@lists.openembedded.org >> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [xiangyu.chen@eng.windriver.com] >> -=-=-=-=-=-=-=-=-=-=-=- >> -- Yoann Congal Smile ECS ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-04-23 7:29 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-02-26 8:19 [OE-core][PATCH] grub: update search parameter Xiangyu Chen 2026-03-05 11:49 ` Paul Barker 2026-03-31 2:57 ` Xiangyu Chen 2026-04-23 6:04 ` Xiangyu Chen 2026-04-23 6:38 ` Yoann Congal 2026-04-23 7:18 ` Xiangyu Chen 2026-04-23 7:29 ` Yoann Congal
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox