[PATCH v2 3/4] fs/hfsplus: Set grub errno to prevent NULL pointer access

2023-05-03 Thread Lidong Chen
When an invalid node size is detected in grub_hfsplus_mount(), data pinter is freed. Thus, file->data is not set. The code should also set the grub error when that happens to indicate an error and to avoid accessing the unintialized file->data in grub_file_close(). Signed-off-by: Lidong Chen ---

[PATCH v2 1/4] fs/hfsplus: Validate btree node size

2023-05-03 Thread Lidong Chen
The invalid btree node size can cause crashes when parsing the btree. The fix is to ensure the btree node size is within the valid range defined in the HFS Plus techical note, TN1150. https://developer.apple.com/library/archive/technotes/tn/tn1150.html Signed-off-by: Lidong Chen --- grub-core/f

[PATCH v2 4/4] fs/hfsplus: Mark error strings for translation

2023-05-03 Thread Lidong Chen
Signed-off-by: Lidong Chen --- grub-core/fs/hfsplus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c index cf13e8a63..793cbdba2 100644 --- a/grub-core/fs/hfsplus.c +++ b/grub-core/fs/hfsplus.c @@ -277,7 +277,7 @@ grub_hfsp

[PATCH v2 0/4] Prevent out-of-bound reads

2023-05-03 Thread Lidong Chen
v2: - patch 4/4: Only mark the informative errors for translation based on the comments. - patch 2/4: Include a reference to the fix in the patch 2/4 commit message. - No changes to the rest of 2 patches. Lidong Chen (4): fs/hfsplus: Validate btree node size fs/hfsplus: Prevent out of bound a

[PATCH v2 2/4] fs/hfsplus: Prevent out of bound access in catalog file

2023-05-03 Thread Lidong Chen
A corrupted hfsplus can have a catalog key that is out of range. This can lead to out of bound access when advancing the pointer to access catalog file info. The valid range of a catalog key is specified in HFS Plus Technical Note TN1150. https://developer.apple.com/library/archive/technotes/tn/tn

[PATCH v7 04/10] grub-core: Make use of guid printf format specifier

2023-05-03 Thread Oliver Steffen
Use the new printf format specifier %pG. Fixes the text representation of GUIDs in the output of the lsefisystab command. Signed-off-by: Oliver Steffen Reviewed-by: Daniel Kiper --- grub-core/commands/efi/lsefi.c | 13 + grub-core/commands/efi/lsefisystab.c | 6 +- grub-

[PATCH v7 07/10] efi: Add grub_efi_set_variable_to_string()

2023-05-03 Thread Oliver Steffen
Add a function that sets an EFI variable to a string value. The string is converted from UTF-8 to UTF-16. Signed-off-by: Oliver Steffen --- grub-core/kern/efi/efi.c | 22 ++ include/grub/efi/efi.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/grub-core/kern/efi/

[PATCH v7 06/10] kern/misc, kern/efi: Extract UTF-8 to UTF-16 code

2023-05-03 Thread Oliver Steffen
Create a new function for UTF-8 to UTF-16 conversion called grub_utf8_to_utf16_alloc() in the grub-code/kern/misc.c and replace charset conversion code used in some places in the EFI code. It is modeled after the grub_utf8_to_ucs4_alloc() like functions in charset.h. It can't live in charset.h, bec

[PATCH v7 09/10] Add a module for the Boot Loader Interface

2023-05-03 Thread Oliver Steffen
Add a new module named bli. It implements a small but quite useful part of the Boot Loader Interface [0]. This interface uses EFI variables for communication between the boot loader and the operating system. When loaded, this module sets two EFI variables under the vendor GUID 4a67b082-0a4c-41cf

[PATCH v7 08/10] docs: Reword section headings

2023-05-03 Thread Oliver Steffen
Reword some section headings, remove "The List of" from titles. While grammatically correct, this phrase can be omitted to increase readability, especially in the table of contents. Signed-off-by: Oliver Steffen --- docs/grub.texi | 20 ++-- 1 file changed, 10 insertions(+), 10

[PATCH v7 03/10] kern/misc: Add a format specifier GUIDs

2023-05-03 Thread Oliver Steffen
Extend the printf format specifier for pointers (%p) to accept a suffix specifier G to print GUIDs: %pG can be used to print grub_guid structs. This does not interfere with the -Wformat checking of gcc. Note that the data type is not checked though (%p accepts void*). Signed-off-by: Oliver Steffe

[PATCH v7 01/10] efi: Add grub_efi_set_variable_with_attributes()

2023-05-03 Thread Oliver Steffen
Add a function to the EFI module that allows setting EFI variables with specific attributes. This is useful for marking variables as volatile, for example. Signed-off-by: Oliver Steffen Reviewed-by: Daniel Kiper --- grub-core/kern/efi/efi.c | 19 +-- include/grub/efi/efi.h |

[PATCH v7 10/10] util/grub.d: Activate bli module on EFI

2023-05-03 Thread Oliver Steffen
Add a new configuration drop-in file that loads the bli module and runs the command if booting on the EFI platform. Signed-off-by: Oliver Steffen --- Makefile.util.def | 6 ++ util/grub.d/25_bli.in | 24 2 files changed, 30 insertions(+) create mode 100644 util

[PATCH v7 00/10] Add basic Boot Loader Interface support

2023-05-03 Thread Oliver Steffen
This is a step towards supporting unified kernel images (UKI) in Grub. Add a new module named bli. It implements a small but quite useful part of the Boot Loader Interface [0]. This interface uses EFI variables for communication between the boot loader and the operating system. This module sets

[PATCH v7 02/10] Unify GUID types

2023-05-03 Thread Oliver Steffen
There are 3 implementations of a GUID in Grub. Replace them with a common one, placed in types.h. It uses the "packed" flavor of the GUID structs, the alignment attribute is dropped, since it is not required. Signed-off-by: Oliver Steffen Reviewed-by: Daniel Kiper --- grub-core/commands/acpi.c

[PATCH v7 05/10] types.h: Add GRUB_SSIZE_MAX

2023-05-03 Thread Oliver Steffen
In the same way as GRUB_SIZE_MAX, add GRUB_SSIZE_MAX. Signed-off-by: Oliver Steffen Reviewed-by: Daniel Kiper --- include/grub/types.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/grub/types.h b/include/grub/types.h index c56ce9820..9f43a5580 100644 --- a/include/grub/types.h +

Re: Installed Fedora 38 (sway) / grub2 on a new HD - boots OK but does not have a menuentry item in grub.cfg ?

2023-05-03 Thread Oliver Steffen
Hi Phil, Quoting Philip Rhoades via Grub-devel (2023-04-22 07:37:45) > People, > > My Fedora WS has 4 drive bays and I access old boot and other HDs in > bays 2-4. I just did a clean install of Fedora Sway to /dev/sda - > everything is fine and the system boots OK but I am confused: > > - cat /et

[PATCH v2 3/3] dns: fix lookup error when no IPv6 is returned

2023-05-03 Thread Renaud Métrich
When trying to resolve DNS names into IP addresses, the DNS code fails from time to time with the following error: 8< 8< 8< 8< error: ../../grub-core/net/dns.c:688:no DNS record found. 8< 8< -

[PATCH v2 2/3] dns: add debugging messages in recv_hook() function

2023-05-03 Thread Renaud Métrich
Signed-off-by: Renaud Métrich --- grub-core/net/dns.c | 5 + 1 file changed, 5 insertions(+) diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c index f28d1099f..6993a4aba 100644 --- a/grub-core/net/dns.c +++ b/grub-core/net/dns.c @@ -355,6 +355,7 @@ recv_hook (grub_net_udp_socket_t sock

[PATCH v2 1/3] dns: simplify error handling of recv_hook() function

2023-05-03 Thread Renaud Métrich
Signed-off-by: Renaud Métrich --- grub-core/net/dns.c | 48 ++--- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c index afa389494..f28d1099f 100644 --- a/grub-core/net/dns.c +++ b/grub-core/net/dns.c