diff options
author | Yi Zhao <yi.zhao@windriver.com> | 2021-01-08 09:01:29 +0800 |
---|---|---|
committer | Jia Zhang <zhang.jia@linux.alibaba.com> | 2021-01-19 17:44:02 +0800 |
commit | 2d1fb96206acfd5b85084304af1760a4f598741a (patch) | |
tree | ca6fb35d30a32280dd8b37f3c817dd08d213df72 | |
parent | f1447e38968d116f5ea0a331ca0d5ec64ebc57c8 (diff) | |
download | meta-secure-core-2d1fb96206acfd5b85084304af1760a4f598741a.tar.gz |
grub: fix the file not found error when sysmlink filesize is 60
We encountered a file not found error when the symlink filesize is 60:
$ ls -l initrd
lrwxrwxrwx 1 root root 60 Jan 6 16:37 initrd -> secure-core-image-initramfs-5.10.2-yoctodev-standard.cpio.gz
When booting, we got the following error in grub:
error: file `/initrd' not found
The root cause is although the size of diro->inode.symlink is 60, it
includes the trailing '\0'. So if the symlink filesize is exactly 60, it
is also stored in a separate block rather than in the inode.
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2 files changed, 41 insertions, 0 deletions
diff --git a/meta-efi-secure-boot/recipes-bsp/grub/grub-efi-efi-secure-boot.inc b/meta-efi-secure-boot/recipes-bsp/grub/grub-efi-efi-secure-boot.inc index c944207..6feee6c 100644 --- a/meta-efi-secure-boot/recipes-bsp/grub/grub-efi-efi-secure-boot.inc +++ b/meta-efi-secure-boot/recipes-bsp/grub/grub-efi-efi-secure-boot.inc | |||
@@ -26,6 +26,7 @@ SRC_URI += "\ | |||
26 | file://Grub-get-and-set-efi-variables.patch \ | 26 | file://Grub-get-and-set-efi-variables.patch \ |
27 | file://uefi_verify.patch \ | 27 | file://uefi_verify.patch \ |
28 | file://0001-grub-verify-Add-strict_security-variable.patch \ | 28 | file://0001-grub-verify-Add-strict_security-variable.patch \ |
29 | file://0001-fs-ext2-fix-the-file-not-found-error-when-symlink-fi.patch \ | ||
29 | file://grub-efi.cfg \ | 30 | file://grub-efi.cfg \ |
30 | file://boot-menu.inc \ | 31 | file://boot-menu.inc \ |
31 | ${@d.getVar('GRUB_MOKVERIFY_PATCH', True) if d.getVar('UEFI_SELOADER', True) == '1' else ''} \ | 32 | ${@d.getVar('GRUB_MOKVERIFY_PATCH', True) if d.getVar('UEFI_SELOADER', True) == '1' else ''} \ |
diff --git a/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/0001-fs-ext2-fix-the-file-not-found-error-when-symlink-fi.patch b/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/0001-fs-ext2-fix-the-file-not-found-error-when-symlink-fi.patch new file mode 100644 index 0000000..a9b3693 --- /dev/null +++ b/meta-efi-secure-boot/recipes-bsp/grub/grub-efi/0001-fs-ext2-fix-the-file-not-found-error-when-symlink-fi.patch | |||
@@ -0,0 +1,40 @@ | |||
1 | From 5fe53d80b7294198687a96e72471ddb968c7de34 Mon Sep 17 00:00:00 2001 | ||
2 | From: Yi Zhao <yi.zhao@windriver.com> | ||
3 | Date: Wed, 6 Jan 2021 17:07:26 +0800 | ||
4 | Subject: [PATCH] fs/ext2: fix the file not found error when symlink filesize | ||
5 | is 60 | ||
6 | |||
7 | We encountered a file not found error when the symlink filesize is 60: | ||
8 | $ ls -l initrd | ||
9 | lrwxrwxrwx 1 root root 60 Jan 6 16:37 initrd -> secure-core-image-initramfs-5.10.2-yoctodev-standard.cpio.gz | ||
10 | |||
11 | When booting, we got the following error in grub: | ||
12 | error: file `/initrd' not found | ||
13 | |||
14 | The root cause is although the size of diro->inode.symlink is 60, it | ||
15 | includes the trailing '\0'. So if the symlink filesize is exactly 60, it | ||
16 | is also stored in a separate block rather than in the inode. | ||
17 | |||
18 | Upstream-Status: Submitted [https://lists.gnu.org/archive/html/grub-devel/2021-01/msg00018.html] | ||
19 | |||
20 | Signed-off-by: Yi Zhao <yi.zhao@windriver.com> | ||
21 | --- | ||
22 | grub-core/fs/ext2.c | 2 +- | ||
23 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
24 | |||
25 | diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c | ||
26 | index ac33bcd68..cb5058e8b 100644 | ||
27 | --- a/grub-core/fs/ext2.c | ||
28 | +++ b/grub-core/fs/ext2.c | ||
29 | @@ -732,7 +732,7 @@ grub_ext2_read_symlink (grub_fshelp_node_t node) | ||
30 | /* If the filesize of the symlink is bigger than | ||
31 | 60 the symlink is stored in a separate block, | ||
32 | otherwise it is stored in the inode. */ | ||
33 | - if (grub_le_to_cpu32 (diro->inode.size) <= sizeof (diro->inode.symlink)) | ||
34 | + if (grub_le_to_cpu32 (diro->inode.size) < sizeof (diro->inode.symlink)) | ||
35 | grub_memcpy (symlink, | ||
36 | diro->inode.symlink, | ||
37 | grub_le_to_cpu32 (diro->inode.size)); | ||
38 | -- | ||
39 | 2.25.1 | ||
40 | |||