Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package grub2 for openSUSE:Factory checked in at 2026-07-15 16:25:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/grub2 (Old) and /work/SRC/openSUSE:Factory/.grub2.new.1991 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "grub2" Wed Jul 15 16:25:25 2026 rev:395 rq:1365482 version:2.14 Changes: -------- --- /work/SRC/openSUSE:Factory/grub2/grub2.changes 2026-07-12 16:20:57.051579178 +0200 +++ /work/SRC/openSUSE:Factory/.grub2.new.1991/grub2.changes 2026-07-15 16:29:18.345323308 +0200 @@ -1,0 +2,33 @@ +Tue Jul 7 05:52:20 UTC 2026 - Michael Chang <[email protected]> + +- Backport merged upstream patch + * 0001-lvm-allocate-metadata-buffer-from-raw-contents.patch +- Drop local patch + * grub2-lvm-allocate-metadata-buffer-from-raw-contents.patch + +------------------------------------------------------------------- +Tue Jul 7 03:43:38 UTC 2026 - Michael Chang <[email protected]> + +- Backport merged upstream patch + * 0001-net-http-Check-result-of-grub_netbuff_put-in-http_re.patch + * 0002-efinet-Add-structures-for-PXE-messages.patch + * 0003-efinet-bootp-add-net_dhcp6-command-supporting-dhcpv6.patch + * 0004-grub.texi-Add-net_dhcp6-document.patch + * 0005-bootp-Process-DHCPACK-packet-during-HTTP-Boot.patch + * 0006-efinet-Configure-network-from-UEFI-device-path.patch + * 0007-efinet-Set-DNS-server-from-UEFI-protocol.patch + * 0008-kern-efi-efi-Print-URI-and-DNS-device-path-info.patch + * 0009-kern-efi-efi-Correct-endianness-in-IPv6-device-path.patch + * 0010-bootp-Fix-logical-operator-in-DHCP-option-overload-c.patch +- Drop local patch + * 0003-bootp-New-net_bootp6-command.patch + * 0004-efinet-UEFI-IPv6-PXE-support.patch + * 0005-grub.texi-Add-net_bootp6-doument.patch + * 0006-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch + * 0007-efinet-Setting-network-from-UEFI-device-path.patch + * 0008-efinet-Setting-DNS-server-from-UEFI-protocol.patch +- Refreshed patch + * 0001-add-support-for-UEFI-network-protocols.patch + * grub2-bsc1220338-key_protector-implement-the-blocklist.patch + +------------------------------------------------------------------- Old: ---- 0003-bootp-New-net_bootp6-command.patch 0004-efinet-UEFI-IPv6-PXE-support.patch 0005-grub.texi-Add-net_bootp6-doument.patch 0006-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch 0007-efinet-Setting-network-from-UEFI-device-path.patch 0008-efinet-Setting-DNS-server-from-UEFI-protocol.patch grub2-lvm-allocate-metadata-buffer-from-raw-contents.patch New: ---- 0001-lvm-allocate-metadata-buffer-from-raw-contents.patch 0001-net-http-Check-result-of-grub_netbuff_put-in-http_re.patch 0002-efinet-Add-structures-for-PXE-messages.patch 0003-efinet-bootp-add-net_dhcp6-command-supporting-dhcpv6.patch 0004-grub.texi-Add-net_dhcp6-document.patch 0005-bootp-Process-DHCPACK-packet-during-HTTP-Boot.patch 0006-efinet-Configure-network-from-UEFI-device-path.patch 0007-efinet-Set-DNS-server-from-UEFI-protocol.patch 0008-kern-efi-efi-Print-URI-and-DNS-device-path-info.patch 0009-kern-efi-efi-Correct-endianness-in-IPv6-device-path.patch 0010-bootp-Fix-logical-operator-in-DHCP-option-overload-c.patch ----------(Old B)---------- Old:- Drop local patch * 0003-bootp-New-net_bootp6-command.patch * 0004-efinet-UEFI-IPv6-PXE-support.patch Old: * 0003-bootp-New-net_bootp6-command.patch * 0004-efinet-UEFI-IPv6-PXE-support.patch * 0005-grub.texi-Add-net_bootp6-doument.patch Old: * 0004-efinet-UEFI-IPv6-PXE-support.patch * 0005-grub.texi-Add-net_bootp6-doument.patch * 0006-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch Old: * 0005-grub.texi-Add-net_bootp6-doument.patch * 0006-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch * 0007-efinet-Setting-network-from-UEFI-device-path.patch Old: * 0006-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch * 0007-efinet-Setting-network-from-UEFI-device-path.patch * 0008-efinet-Setting-DNS-server-from-UEFI-protocol.patch Old: * 0007-efinet-Setting-network-from-UEFI-device-path.patch * 0008-efinet-Setting-DNS-server-from-UEFI-protocol.patch - Refreshed patch Old:- Drop local patch * grub2-lvm-allocate-metadata-buffer-from-raw-contents.patch ----------(Old E)---------- ----------(New B)---------- New:- Backport merged upstream patch * 0001-lvm-allocate-metadata-buffer-from-raw-contents.patch - Drop local patch New:- Backport merged upstream patch * 0001-net-http-Check-result-of-grub_netbuff_put-in-http_re.patch * 0002-efinet-Add-structures-for-PXE-messages.patch New: * 0001-net-http-Check-result-of-grub_netbuff_put-in-http_re.patch * 0002-efinet-Add-structures-for-PXE-messages.patch * 0003-efinet-bootp-add-net_dhcp6-command-supporting-dhcpv6.patch New: * 0002-efinet-Add-structures-for-PXE-messages.patch * 0003-efinet-bootp-add-net_dhcp6-command-supporting-dhcpv6.patch * 0004-grub.texi-Add-net_dhcp6-document.patch New: * 0003-efinet-bootp-add-net_dhcp6-command-supporting-dhcpv6.patch * 0004-grub.texi-Add-net_dhcp6-document.patch * 0005-bootp-Process-DHCPACK-packet-during-HTTP-Boot.patch New: * 0004-grub.texi-Add-net_dhcp6-document.patch * 0005-bootp-Process-DHCPACK-packet-during-HTTP-Boot.patch * 0006-efinet-Configure-network-from-UEFI-device-path.patch New: * 0005-bootp-Process-DHCPACK-packet-during-HTTP-Boot.patch * 0006-efinet-Configure-network-from-UEFI-device-path.patch * 0007-efinet-Set-DNS-server-from-UEFI-protocol.patch New: * 0006-efinet-Configure-network-from-UEFI-device-path.patch * 0007-efinet-Set-DNS-server-from-UEFI-protocol.patch * 0008-kern-efi-efi-Print-URI-and-DNS-device-path-info.patch New: * 0007-efinet-Set-DNS-server-from-UEFI-protocol.patch * 0008-kern-efi-efi-Print-URI-and-DNS-device-path-info.patch * 0009-kern-efi-efi-Correct-endianness-in-IPv6-device-path.patch New: * 0008-kern-efi-efi-Print-URI-and-DNS-device-path-info.patch * 0009-kern-efi-efi-Correct-endianness-in-IPv6-device-path.patch * 0010-bootp-Fix-logical-operator-in-DHCP-option-overload-c.patch New: * 0009-kern-efi-efi-Correct-endianness-in-IPv6-device-path.patch * 0010-bootp-Fix-logical-operator-in-DHCP-option-overload-c.patch - Drop local patch ----------(New E)---------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ grub2.spec ++++++ --- /var/tmp/diff_new_pack.MbNqs1/_old 2026-07-15 16:29:22.385460734 +0200 +++ /var/tmp/diff_new_pack.MbNqs1/_new 2026-07-15 16:29:22.385460734 +0200 @@ -198,6 +198,17 @@ Source18: grub2-check-default.sh Source19: grub2-instdev-fixup.pl Source1000: PATCH_POLICY +Patch: 0001-lvm-allocate-metadata-buffer-from-raw-contents.patch +Patch: 0001-net-http-Check-result-of-grub_netbuff_put-in-http_re.patch +Patch: 0002-efinet-Add-structures-for-PXE-messages.patch +Patch: 0003-efinet-bootp-add-net_dhcp6-command-supporting-dhcpv6.patch +Patch: 0004-grub.texi-Add-net_dhcp6-document.patch +Patch: 0005-bootp-Process-DHCPACK-packet-during-HTTP-Boot.patch +Patch: 0006-efinet-Configure-network-from-UEFI-device-path.patch +Patch: 0007-efinet-Set-DNS-server-from-UEFI-protocol.patch +Patch: 0008-kern-efi-efi-Print-URI-and-DNS-device-path-info.patch +Patch: 0009-kern-efi-efi-Correct-endianness-in-IPv6-device-path.patch +Patch: 0010-bootp-Fix-logical-operator-in-DHCP-option-overload-c.patch Patch: rename-grub-info-file-to-grub2.patch Patch: grub2-linux.patch Patch: use-grub2-as-a-package-name.patch @@ -235,7 +246,6 @@ Patch: grub2-commands-introduce-read_file-subcommand.patch Patch: grub2-efi-chainload-harder.patch Patch: grub2-emu-4-all.patch -Patch: grub2-lvm-allocate-metadata-buffer-from-raw-contents.patch Patch: grub2-diskfilter-support-pv-without-metadatacopies.patch Patch: grub2-s390x-09-improve-zipl-setup.patch Patch: grub2-getroot-scan-disk-pv.patch @@ -269,12 +279,6 @@ Patch: grub2-ppc64-cas-new-scope.patch Patch: grub2-ppc64-cas-fix-double-free.patch Patch: grub2-efi_gop-avoid-low-resolution.patch -Patch: 0003-bootp-New-net_bootp6-command.patch -Patch: 0004-efinet-UEFI-IPv6-PXE-support.patch -Patch: 0005-grub.texi-Add-net_bootp6-doument.patch -Patch: 0006-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch -Patch: 0007-efinet-Setting-network-from-UEFI-device-path.patch -Patch: 0008-efinet-Setting-DNS-server-from-UEFI-protocol.patch Patch: 0012-tpm-Build-tpm-as-module.patch Patch: 0001-add-support-for-UEFI-network-protocols.patch Patch: 0002-AUDIT-0-http-boot-tracker-bug.patch ++++++ 0001-add-support-for-UEFI-network-protocols.patch ++++++ --- /var/tmp/diff_new_pack.MbNqs1/_old 2026-07-15 16:29:22.469463591 +0200 +++ /var/tmp/diff_new_pack.MbNqs1/_new 2026-07-15 16:29:22.473463728 +0200 @@ -107,7 +107,7 @@ (unsigned) ipv4->local_ip_address[0], (unsigned) ipv4->local_ip_address[1], (unsigned) ipv4->local_ip_address[2], -@@ -783,33 +783,60 @@ +@@ -783,6 +783,19 @@ (unsigned) ipv4->remote_port, (unsigned) ipv4->protocol, (unsigned) ipv4->static_ip_address); @@ -127,44 +127,7 @@ } break; case GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE: - { - grub_efi_ipv6_device_path_t *ipv6 - = (grub_efi_ipv6_device_path_t *) dp; -- grub_printf ("/IPv6(%x:%x:%x:%x:%x:%x:%x:%x,%x:%x:%x:%x:%x:%x:%x:%x,%u,%u,%x,%x)", -- (unsigned) ipv6->local_ip_address[0], -- (unsigned) ipv6->local_ip_address[1], -- (unsigned) ipv6->local_ip_address[2], -- (unsigned) ipv6->local_ip_address[3], -- (unsigned) ipv6->local_ip_address[4], -- (unsigned) ipv6->local_ip_address[5], -- (unsigned) ipv6->local_ip_address[6], -- (unsigned) ipv6->local_ip_address[7], -- (unsigned) ipv6->remote_ip_address[0], -- (unsigned) ipv6->remote_ip_address[1], -- (unsigned) ipv6->remote_ip_address[2], -- (unsigned) ipv6->remote_ip_address[3], -- (unsigned) ipv6->remote_ip_address[4], -- (unsigned) ipv6->remote_ip_address[5], -- (unsigned) ipv6->remote_ip_address[6], -- (unsigned) ipv6->remote_ip_address[7], -+ grub_printf ("/IPv6(%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x,%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x,%u,%u,%x,%x", -+ (unsigned) grub_be_to_cpu16 (ipv6->local_ip_address[0]), -+ (unsigned) grub_be_to_cpu16 (ipv6->local_ip_address[1]), -+ (unsigned) grub_be_to_cpu16 (ipv6->local_ip_address[2]), -+ (unsigned) grub_be_to_cpu16 (ipv6->local_ip_address[3]), -+ (unsigned) grub_be_to_cpu16 (ipv6->local_ip_address[4]), -+ (unsigned) grub_be_to_cpu16 (ipv6->local_ip_address[5]), -+ (unsigned) grub_be_to_cpu16 (ipv6->local_ip_address[6]), -+ (unsigned) grub_be_to_cpu16 (ipv6->local_ip_address[7]), -+ (unsigned) grub_be_to_cpu16 (ipv6->remote_ip_address[0]), -+ (unsigned) grub_be_to_cpu16 (ipv6->remote_ip_address[1]), -+ (unsigned) grub_be_to_cpu16 (ipv6->remote_ip_address[2]), -+ (unsigned) grub_be_to_cpu16 (ipv6->remote_ip_address[3]), -+ (unsigned) grub_be_to_cpu16 (ipv6->remote_ip_address[4]), -+ (unsigned) grub_be_to_cpu16 (ipv6->remote_ip_address[5]), -+ (unsigned) grub_be_to_cpu16 (ipv6->remote_ip_address[6]), -+ (unsigned) grub_be_to_cpu16 (ipv6->remote_ip_address[7]), - (unsigned) ipv6->local_port, +@@ -810,6 +823,20 @@ (unsigned) ipv6->remote_port, (unsigned) ipv6->protocol, (unsigned) ipv6->static_ip_address); @@ -185,46 +148,6 @@ } break; case GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE: -@@ -856,6 +883,39 @@ - dump_vendor_path ("Messaging", - (grub_efi_vendor_device_path_t *) dp); - break; -+ case GRUB_EFI_URI_DEVICE_PATH_SUBTYPE: -+ { -+ grub_efi_uri_device_path_t *uri -+ = (grub_efi_uri_device_path_t *) dp; -+ grub_printf ("/URI(%s)", uri->uri); -+ } -+ break; -+ case GRUB_EFI_DNS_DEVICE_PATH_SUBTYPE: -+ { -+ grub_efi_dns_device_path_t *dns -+ = (grub_efi_dns_device_path_t *) dp; -+ if (dns->is_ipv6) -+ { -+ grub_printf ("/DNS(%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x)", -+ (grub_uint16_t)(grub_be_to_cpu32(dns->dns_server_ip[0].addr[0]) >> 16), -+ (grub_uint16_t)(grub_be_to_cpu32(dns->dns_server_ip[0].addr[0])), -+ (grub_uint16_t)(grub_be_to_cpu32(dns->dns_server_ip[0].addr[1]) >> 16), -+ (grub_uint16_t)(grub_be_to_cpu32(dns->dns_server_ip[0].addr[1])), -+ (grub_uint16_t)(grub_be_to_cpu32(dns->dns_server_ip[0].addr[2]) >> 16), -+ (grub_uint16_t)(grub_be_to_cpu32(dns->dns_server_ip[0].addr[2])), -+ (grub_uint16_t)(grub_be_to_cpu32(dns->dns_server_ip[0].addr[3]) >> 16), -+ (grub_uint16_t)(grub_be_to_cpu32(dns->dns_server_ip[0].addr[3]))); -+ } -+ else -+ { -+ grub_printf ("/DNS(%d.%d.%d.%d)", -+ dns->dns_server_ip[0].v4.addr[0], -+ dns->dns_server_ip[0].v4.addr[1], -+ dns->dns_server_ip[0].v4.addr[2], -+ dns->dns_server_ip[0].v4.addr[3]); -+ } -+ } -+ break; - default: - grub_printf ("/UnknownMessaging(%x)", (unsigned) subtype); - break; --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -24,6 +24,7 @@ @@ -235,58 +158,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); -@@ -346,7 +347,7 @@ - } - - static grub_efi_handle_t --grub_efi_locate_device_path (grub_efi_guid_t *protocol, grub_efi_device_path_t *device_path, -+grub_efi_locate_device_path (grub_guid_t *protocol, grub_efi_device_path_t *device_path, - grub_efi_device_path_t **r_device_path) - { - grub_efi_handle_t handle; -@@ -499,6 +500,17 @@ - - ldp = grub_efi_find_last_device_path (ddp); - -+ /* Skip the DNS Device */ -+ if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE -+ && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_DNS_DEVICE_PATH_SUBTYPE) -+ { -+ ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; -+ ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; -+ ldp->length = sizeof (*ldp); -+ -+ ldp = grub_efi_find_last_device_path (ddp); -+ } -+ - if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE - || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE - && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE)) -@@ -766,6 +778,7 @@ - if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE - || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE - && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE -+ && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_DNS_DEVICE_PATH_SUBTYPE - && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_URI_DEVICE_PATH_SUBTYPE)) - continue; - dup_dp = grub_efi_duplicate_device_path (dp); -@@ -781,6 +794,15 @@ - } - - dup_ldp = grub_efi_find_last_device_path (dup_dp); -+ if (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_DNS_DEVICE_PATH_SUBTYPE) -+ { -+ dup_ldp = grub_efi_find_last_device_path (dup_dp); -+ dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; -+ dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; -+ dup_ldp->length = sizeof (*dup_ldp); -+ } -+ -+ dup_ldp = grub_efi_find_last_device_path (dup_dp); - dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; - dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; - dup_ldp->length = sizeof (*dup_ldp); -@@ -870,6 +892,9 @@ +@@ -927,6 +928,9 @@ GRUB_MOD_INIT(efinet) { @@ -296,7 +168,7 @@ grub_efinet_findcards (); grub_efi_net_config = grub_efi_net_config_real; } -@@ -881,5 +906,7 @@ +@@ -938,5 +942,7 @@ FOR_NET_CARDS_SAFE (card, next) if (card->driver == &efidriver) grub_net_card_unregister (card); @@ -3860,7 +3732,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); -@@ -2079,8 +2082,49 @@ +@@ -2147,8 +2150,49 @@ static grub_command_t cmd_setvlan, cmd_lsroutes, cmd_lscards; static grub_command_t cmd_lsaddr, cmd_slaac; @@ -3910,7 +3782,7 @@ grub_register_variable_hook ("net_default_server", defserver_get_env, defserver_set_env); grub_env_export ("net_default_server"); -@@ -2131,10 +2175,37 @@ +@@ -2199,10 +2243,37 @@ grub_net_restore_hw, GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK); grub_net_poll_cards_idle = grub_net_poll_cards_idle_real; @@ -3948,7 +3820,7 @@ grub_register_variable_hook ("net_default_server", 0, 0); grub_register_variable_hook ("pxe_default_server", 0, 0); grub_register_variable_hook ("net_default_ip", 0, 0); -@@ -2156,4 +2227,7 @@ +@@ -2224,4 +2295,7 @@ grub_net_fini_hw (0); grub_loader_unregister_preboot_hook (fini_hnd); grub_net_poll_cards_idle = NULL; @@ -3958,31 +3830,7 @@ } --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -673,6 +673,23 @@ - typedef grub_uint8_t grub_efi_ip_address_t[8] __attribute__ ((aligned(4))); - typedef grub_efi_uint64_t grub_efi_physical_address_t; - typedef grub_efi_uint64_t grub_efi_virtual_address_t; -+typedef struct { -+ grub_uint8_t addr[4]; -+} grub_efi_pxe_ipv4_address_t; -+ -+typedef struct { -+ grub_uint8_t addr[16]; -+} grub_efi_pxe_ipv6_address_t; -+ -+typedef struct { -+ grub_uint8_t addr[32]; -+} grub_efi_pxe_mac_address_t; -+ -+typedef union { -+ grub_uint32_t addr[4]; -+ grub_efi_pxe_ipv4_address_t v4; -+ grub_efi_pxe_ipv6_address_t v6; -+} grub_efi_pxe_ip_address_t; - - /* XXX although the spec does not specify the padding, this actually - must have the padding! */ -@@ -922,6 +939,8 @@ +@@ -945,6 +945,8 @@ grub_efi_uint16_t remote_port; grub_efi_uint16_t protocol; grub_efi_uint8_t static_ip_address; @@ -3991,23 +3839,7 @@ } GRUB_PACKED; typedef struct grub_efi_ipv6_device_path grub_efi_ipv6_device_path_t; -@@ -980,6 +999,15 @@ - } GRUB_PACKED; - typedef struct grub_efi_uri_device_path grub_efi_uri_device_path_t; - -+#define GRUB_EFI_DNS_DEVICE_PATH_SUBTYPE 31 -+struct grub_efi_dns_device_path -+{ -+ grub_efi_device_path_t header; -+ grub_efi_uint8_t is_ipv6; -+ grub_efi_pxe_ip_address_t dns_server_ip[0]; -+} GRUB_PACKED; -+typedef struct grub_efi_dns_device_path grub_efi_dns_device_path_t; -+ - #define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10 - - /* Media Device Path. */ -@@ -1062,6 +1090,23 @@ +@@ -1094,6 +1096,23 @@ } GRUB_PACKED; typedef struct grub_efi_bios_device_path grub_efi_bios_device_path_t; @@ -4031,18 +3863,12 @@ struct grub_efi_open_protocol_information_entry { grub_efi_handle_t agent_handle; -@@ -1564,23 +1609,28 @@ - - typedef grub_uint8_t grub_efi_pxe_packet_t[1472]; +@@ -1622,6 +1641,20 @@ + } GRUB_PACKED; + typedef struct grub_efi_pxe_dhcpv6_packet grub_efi_pxe_dhcpv6_packet_t; --typedef struct { -- grub_uint8_t addr[4]; --} grub_efi_pxe_ipv4_address_t; +typedef grub_efi_uint16_t grub_efi_pxe_base_code_udp_port_t; - --typedef struct { -- grub_uint8_t addr[16]; --} grub_efi_pxe_ipv6_address_t; ++ +typedef enum { + GRUB_EFI_PXE_BASE_CODE_TFTP_FIRST, + GRUB_EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE, @@ -4054,16 +3880,14 @@ + GRUB_EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY, + GRUB_EFI_PXE_BASE_CODE_MTFTP_LAST +} grub_efi_pxe_base_code_tftp_opcode_t; ++ + typedef union + { + grub_efi_uint8_t raw[1472]; +@@ -1654,6 +1687,14 @@ + grub_efi_char8_t error_string[127]; + } grub_efi_pxe_tftp_error_t; --typedef struct { -- grub_uint8_t addr[32]; --} grub_efi_pxe_mac_address_t; - --typedef union { -- grub_uint32_t addr[4]; -- grub_efi_pxe_ipv4_address_t v4; -- grub_efi_pxe_ipv6_address_t v6; --} grub_efi_pxe_ip_address_t; +typedef struct { + grub_efi_ip_address_t mcast_ip; + grub_efi_pxe_base_code_udp_port_t c_port; @@ -4071,10 +3895,22 @@ + grub_efi_uint16_t listen_timeout; + grub_efi_uint16_t transmit_timeout; +} grub_efi_pxe_base_code_mtftp_info_t; - ++ #define GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT 8 - typedef struct { -@@ -1630,18 +1680,32 @@ + typedef struct grub_efi_pxe_ip_filter + { +@@ -1699,8 +1740,8 @@ + grub_efi_boolean_t make_callbacks; + grub_efi_uint8_t ttl; + grub_efi_uint8_t tos; +- grub_efi_ip_address_t station_ip; +- grub_efi_ip_address_t subnet_mask; ++ grub_efi_pxe_ip_address_t station_ip; ++ grub_efi_pxe_ip_address_t subnet_mask; + grub_efi_pxe_packet_t dhcp_discover; + grub_efi_pxe_packet_t dhcp_ack; + grub_efi_pxe_packet_t proxy_offer; +@@ -1719,18 +1760,32 @@ typedef struct grub_efi_pxe { grub_uint64_t rev; @@ -4119,7 +3955,7 @@ struct grub_efi_pxe_mode *mode; } grub_efi_pxe_t; -@@ -1961,6 +2025,44 @@ +@@ -2051,6 +2106,44 @@ }; typedef struct grub_efi_ip4_config2_protocol grub_efi_ip4_config2_protocol_t; @@ -4161,10 +3997,10 @@ + +typedef struct grub_efi_ip4_config2_manual_address grub_efi_ip4_config2_manual_address_t; + - enum grub_efi_ip6_config_data_type { - GRUB_EFI_IP6_CONFIG_DATA_TYPE_INTERFACEINFO, - GRUB_EFI_IP6_CONFIG_DATA_TYPE_ALT_INTERFACEID, -@@ -1995,4 +2097,47 @@ + enum grub_efi_ip6_config_data_type + { + GRUB_EFI_IP6_CONFIG_DATA_TYPE_INTERFACEINFO, +@@ -2086,4 +2179,47 @@ }; typedef struct grub_efi_ip6_config_protocol grub_efi_ip6_config_protocol_t; ++++++ grub2-lvm-allocate-metadata-buffer-from-raw-contents.patch -> 0001-lvm-allocate-metadata-buffer-from-raw-contents.patch ++++++ --- /work/SRC/openSUSE:Factory/grub2/grub2-lvm-allocate-metadata-buffer-from-raw-contents.patch 2026-02-01 22:02:19.612750531 +0100 +++ /work/SRC/openSUSE:Factory/.grub2.new.1991/0001-lvm-allocate-metadata-buffer-from-raw-contents.patch 2026-07-15 16:29:08.804998789 +0200 @@ -1,24 +1,54 @@ +From 19ea3208a1ff43cc7f1fe81651c1060d7909300a Mon Sep 17 00:00:00 2001 From: Michael Chang <[email protected]> -Date: Fri, 9 Apr 2021 19:58:24 +0800 -Subject: [PATCH] Allocate LVM metadata buffer from raw contents +Date: Fri, 29 May 2026 11:17:56 +0800 +Subject: [PATCH] lvm: allocate metadata buffer from raw contents -The size reserved for on disk LVM metadata area can be exceedingly large that -may trigger out of memory error for allocating buffer based on it. Refine the -buffer allocation to use size of raw LVM metadata contents and read them from -within the metadata area as we only need to parse the JSON formatted contents -rather than the entire metadata area. This reduced the size significantly and -the likelihood to out of memory error. +Previously, the buffer for LVM metadata parsing was set to twice the +size of the metadata area, which caused excessive memory use. + +This patch changes the allocation to read the actual raw metadata blocks +directly from the metadata area. Instead of using twice the entire +metadata area size, we now allocate just what's needed for the raw +metadata. + +To illustrate, We can determine the size of the LVM metadata area by +running the command: + + pvs -o pv_name,pv_mda_size + +As a result, grub will allocate 2 * pv_mda_size, and since 1MiB is a +common default for pv_mda_size nowadays (it seems), this results in 2MiB +being allocated. + +However, most of the blocks in the metadata area are not useful to grub. +A lot of space gets wasted because it is occupied by a pre-allocated +circular buffer, which is used to track changes over time. To eliminate +this overhead, we can teach grub to use the raw metadata block to locate +the active metadata within the circular buffer. + +This change effectively reduces the buffer size while still working +correctly. In my test system on openSUSE, the buffer size for LVM +metadata dropped from 2,088,960 bytes to 1,119 bytes, which is a big +improvement. + +Signed-off-by: Michael Chang <[email protected]> +Reviewed-by: Andrew Hamilton <[email protected]> +Reviewed-By: Sudhakar Kuppusamy <[email protected]> +Reviewed-By: Leo Sandoval <[email protected]> +Part-of: <https://gitlab.freedesktop.org/gnu-grub/grub/-/merge_requests/136> --- - grub-core/disk/lvm.c | 79 ++++++++++++++++++++++++-------------------- - 1 file changed, 43 insertions(+), 36 deletions(-) + grub-core/disk/lvm.c | 98 ++++++++++++++++++++++++++++---------------- + 1 file changed, 62 insertions(+), 36 deletions(-) +diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c +index af6a8e93c..42f96eaa0 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c -@@ -138,9 +138,11 @@ +@@ -138,9 +138,11 @@ grub_lvm_detect (grub_disk_t disk, grub_err_t err; grub_uint64_t mda_offset, mda_size; grub_size_t ptr; -+ grub_uint64_t mda_raw_offset, mda_raw_size; ++ grub_uint64_t mda_raw_offset, mda_raw_size, mda_raw_end; char buf[GRUB_LVM_LABEL_SIZE]; char vg_id[GRUB_LVM_ID_STRLEN+1]; char pv_id[GRUB_LVM_ID_STRLEN+1]; @@ -26,12 +56,18 @@ char *metadatabuf, *mda_end, *vgname; const char *p, *q; struct grub_lvm_label_header *lh = (struct grub_lvm_label_header *) buf; -@@ -218,21 +220,15 @@ - - dlocn++; +@@ -220,19 +222,22 @@ grub_lvm_detect (grub_disk_t disk, mda_offset = grub_le_to_cpu64 (dlocn->offset); -- mda_size = grub_le_to_cpu64 (dlocn->size); + mda_size = grub_le_to_cpu64 (dlocn->size); ++ if (mda_size < GRUB_LVM_MDA_HEADER_SIZE) ++ { ++#ifdef GRUB_UTIL ++ grub_util_info ("LVM metadata area is too small"); ++#endif ++ goto fail; ++ } ++ /* It's possible to have multiple copies of metadata areas, we just use the first one. */ - @@ -51,7 +87,7 @@ if ((grub_strncmp ((char *)mdah->magic, GRUB_LVM_FMTT_MAGIC, sizeof (mdah->magic))) || (grub_le_to_cpu32 (mdah->version) != GRUB_LVM_FMTT_VERSION)) -@@ -242,42 +238,58 @@ +@@ -242,42 +247,68 @@ grub_lvm_detect (grub_disk_t disk, #ifdef GRUB_UTIL grub_util_info ("unknown LVM metadata header"); #endif @@ -62,14 +98,20 @@ rlocn = mdah->raw_locns; - if (grub_le_to_cpu64 (rlocn->offset) >= grub_le_to_cpu64 (mda_size)) + -+ mda_size = grub_le_to_cpu64 (mdah->size); + mda_raw_size = grub_le_to_cpu64 (rlocn->size); + mda_raw_offset = grub_le_to_cpu64 (rlocn->offset); + -+ if (mda_raw_offset >= mda_size) ++ if (grub_add (mda_raw_offset, mda_raw_size, &mda_raw_end) || ++ grub_le_to_cpu64 (mdah->size) > mda_size || ++ grub_le_to_cpu64 (mdah->size) < GRUB_LVM_MDA_HEADER_SIZE || ++ mda_raw_size > grub_le_to_cpu64 (mdah->size) - GRUB_LVM_MDA_HEADER_SIZE || ++ mda_raw_offset >= grub_le_to_cpu64 (mdah->size) || ++ mda_raw_offset < GRUB_LVM_MDA_HEADER_SIZE) { ++ grub_error (GRUB_ERR_OUT_OF_RANGE, "invalid LVM metadata area size/offset"); #ifdef GRUB_UTIL - grub_util_info ("metadata offset is beyond end of metadata area"); +- grub_util_info ("metadata offset is beyond end of metadata area"); ++ grub_util_info ("invalid LVM metadata area size/offset"); #endif - goto fail2; + goto fail; @@ -77,12 +119,17 @@ - if (grub_le_to_cpu64 (rlocn->offset) + grub_le_to_cpu64 (rlocn->size) > - grub_le_to_cpu64 (mdah->size)) -+ metadatabuf = grub_malloc (mda_raw_size); ++ if (mda_raw_size > GRUB_SIZE_MAX - 1) ++ goto fail; ++ ++ metadatabuf = grub_malloc (mda_raw_size + 1); + + if (! metadatabuf) + goto fail; + -+ if (mda_raw_offset + mda_raw_size > mda_size) ++ metadatabuf[mda_raw_size] = '\0'; ++ ++ if (mda_raw_end > grub_le_to_cpu64 (mdah->size)) { - if (2 * mda_size < GRUB_LVM_MDA_HEADER_SIZE || - (grub_le_to_cpu64 (rlocn->offset) + grub_le_to_cpu64 (rlocn->size) - @@ -95,7 +142,7 @@ - } + err = grub_disk_read (disk, 0, + mda_offset + mda_raw_offset, -+ mda_size - mda_raw_offset, ++ grub_le_to_cpu64 (mdah->size) - mda_raw_offset, + metadatabuf); + if (err) + goto fail2; @@ -108,8 +155,8 @@ - grub_le_to_cpu64 (mdah->size)); + err = grub_disk_read (disk, 0, + mda_offset + GRUB_LVM_MDA_HEADER_SIZE, -+ mda_raw_offset + mda_raw_size - mda_size, -+ metadatabuf + mda_size - mda_raw_offset); ++ mda_raw_end - grub_le_to_cpu64 (mdah->size), ++ metadatabuf + grub_le_to_cpu64 (mdah->size) - mda_raw_offset); + if (err) + goto fail2; + } @@ -132,7 +179,7 @@ { error_parsing_metadata: #ifdef GRUB_UTIL -@@ -286,11 +298,6 @@ +@@ -286,11 +317,6 @@ grub_lvm_detect (grub_disk_t disk, goto fail2; } @@ -144,3 +191,6 @@ mda_end = (char *)ptr; while (*q != ' ' && q < mda_end) +-- +2.54.0 + ++++++ 0001-net-http-Check-result-of-grub_netbuff_put-in-http_re.patch ++++++ >From 89d347ef476dcff038d769eacde170904e052258 Mon Sep 17 00:00:00 2001 From: Michael Chang <[email protected]> Date: Mon, 16 Dec 2024 16:03:30 +0800 Subject: [PATCH 01/10] net/http: Check result of grub_netbuff_put() in http_receive() Co-authored-by: Peter Jones <[email protected]> Signed-off-by: Peter Jones <[email protected]> Signed-off-by: Robbie Harwood <[email protected]> Signed-off-by: Michael Chang <[email protected]> Reviewed-by: Leo Sandoval <[email protected]> Reviewed-by: Andrew Hamilton <[email protected]> Part-of: <https://gitlab.freedesktop.org/gnu-grub/grub/-/merge_requests/127> --- grub-core/net/http.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grub-core/net/http.c b/grub-core/net/http.c index f389bf03d..a81e5fe61 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c @@ -291,7 +291,12 @@ http_receive (grub_net_tcp_socket_t sock __attribute__ ((unused)), nb2 = grub_netbuff_alloc (data->chunk_rem); if (!nb2) return grub_errno; - grub_netbuff_put (nb2, data->chunk_rem); + err = grub_netbuff_put (nb2, data->chunk_rem); + if (err) + { + grub_netbuff_free (nb2); + return grub_errno; + } grub_memcpy (nb2->data, nb->data, data->chunk_rem); if (file->device->net->packs.count >= 20) { -- 2.54.0 ++++++ 0002-efinet-Add-structures-for-PXE-messages.patch ++++++ >From 7037dc62f47532057e1e1ee5802e16fbebfdf209 Mon Sep 17 00:00:00 2001 From: Michael Chang <[email protected]> Date: Mon, 16 Dec 2024 16:03:31 +0800 Subject: [PATCH 02/10] efinet: Add structures for PXE messages When a GRUB2 image is booted from UEFI IPv6 PXE, the DHCPv6 Reply packet is cached in the firmware buffer and can be retrieved via the PXE Base Code protocol. The network interface can then be configured using the parameters from the retrieved packet. Augment existing structures to represent this, and make them agnostic between ipv4 and ipv6. Signed-off-by: Ken Lin <[email protected]> Co-authored-by: Robbie Harwood <[email protected]> Signed-off-by: Robbie Harwood <[email protected]> Signed-off-by: Michael Chang <[email protected]> Reviewed-by: Leo Sandoval <[email protected]> Reviewed-by: Andrew Hamilton <[email protected]> Part-of: <https://gitlab.freedesktop.org/gnu-grub/grub/-/merge_requests/127> --- include/grub/efi/api.h | 145 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 139 insertions(+), 6 deletions(-) diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index f7e9c46a5..f32138bf7 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -657,12 +657,35 @@ typedef void *grub_efi_handle_t; typedef void *grub_efi_event_t; typedef grub_efi_uint64_t grub_efi_lba_t; typedef grub_efi_uintn_t grub_efi_tpl_t; -typedef grub_uint8_t grub_efi_mac_address_t[32]; -typedef grub_uint8_t grub_efi_ipv4_address_t[4]; -typedef grub_uint16_t grub_efi_ipv6_address_t[8]; -typedef grub_uint8_t grub_efi_ip_address_t[8] __attribute__ ((aligned(4))); +typedef grub_efi_uint8_t grub_efi_mac_address_t[32]; +typedef grub_efi_uint8_t grub_efi_ipv4_address_t[4]; +typedef grub_efi_uint8_t grub_efi_ipv6_address_t[16]; +typedef union +{ + grub_efi_uint32_t addr[4]; + grub_efi_ipv4_address_t v4; + grub_efi_ipv6_address_t v6; +} grub_efi_ip_address_t __attribute__ ((aligned(4))); + typedef grub_efi_uint64_t grub_efi_physical_address_t; typedef grub_efi_uint64_t grub_efi_virtual_address_t; +typedef struct { + grub_uint8_t addr[4]; +} grub_efi_pxe_ipv4_address_t; + +typedef struct { + grub_uint8_t addr[16]; +} grub_efi_pxe_ipv6_address_t; + +typedef struct { + grub_uint8_t addr[32]; +} grub_efi_pxe_mac_address_t; + +typedef union { + grub_uint32_t addr[4]; + grub_efi_pxe_ipv4_address_t v4; + grub_efi_pxe_ipv6_address_t v6; +} grub_efi_pxe_ip_address_t; /* XXX although the spec does not specify the padding, this actually must have the padding! */ @@ -1541,16 +1564,126 @@ struct grub_efi_simple_text_output_interface }; typedef struct grub_efi_simple_text_output_interface grub_efi_simple_text_output_interface_t; -typedef grub_uint8_t grub_efi_pxe_packet_t[1472]; +typedef struct grub_efi_pxe_dhcpv4_packet +{ + grub_efi_uint8_t bootp_opcode; + grub_efi_uint8_t bootp_hwtype; + grub_efi_uint8_t bootp_hwaddr_len; + grub_efi_uint8_t bootp_gate_hops; + grub_efi_uint32_t bootp_ident; + grub_efi_uint16_t bootp_seconds; + grub_efi_uint16_t bootp_flags; + grub_efi_uint8_t bootp_ci_addr[4]; + grub_efi_uint8_t bootp_yi_addr[4]; + grub_efi_uint8_t bootp_si_addr[4]; + grub_efi_uint8_t bootp_gi_addr[4]; + grub_efi_uint8_t bootp_hw_addr[16]; + grub_efi_uint8_t bootp_srv_name[64]; + grub_efi_uint8_t bootp_boot_file[128]; + grub_efi_uint32_t dhcp_magik; + grub_efi_uint8_t dhcp_options[56]; +} grub_efi_pxe_dhcpv4_packet_t; + +struct grub_efi_pxe_dhcpv6_packet +{ + grub_efi_uint32_t message_type:8; + grub_efi_uint32_t transaction_id:24; + grub_efi_uint8_t dhcp_options[1024]; +} GRUB_PACKED; +typedef struct grub_efi_pxe_dhcpv6_packet grub_efi_pxe_dhcpv6_packet_t; + +typedef union +{ + grub_efi_uint8_t raw[1472]; + grub_efi_pxe_dhcpv4_packet_t dhcpv4; + grub_efi_pxe_dhcpv6_packet_t dhcpv6; +} grub_efi_pxe_packet_t; + +typedef struct grub_efi_pxe_icmp_error +{ + grub_efi_uint8_t type; + grub_efi_uint8_t code; + grub_efi_uint16_t checksum; + union + { + grub_efi_uint32_t reserved; + grub_efi_uint32_t mtu; + grub_efi_uint32_t pointer; + struct + { + grub_efi_uint16_t identifier; + grub_efi_uint16_t sequence; + } echo; + } u; + grub_efi_uint8_t data[494]; +} grub_efi_pxe_icmp_error_t; + +typedef struct grub_efi_pxe_tftp_error +{ + grub_efi_uint8_t error_code; + grub_efi_char8_t error_string[127]; +} grub_efi_pxe_tftp_error_t; + +#define GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT 8 +typedef struct grub_efi_pxe_ip_filter +{ + grub_efi_uint8_t filters; + grub_efi_uint8_t ip_count; + grub_efi_uint16_t reserved; + grub_efi_ip_address_t ip_list[GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT]; +} grub_efi_pxe_ip_filter_t; + +typedef struct { + grub_efi_pxe_ip_address_t ip_addr; + grub_efi_pxe_mac_address_t mac_addr; +} grub_efi_pxe_arp_entry_t; + +typedef struct { + grub_efi_pxe_ip_address_t ip_addr; + grub_efi_pxe_ip_address_t subnet_mask; + grub_efi_pxe_ip_address_t gw_addr; +} grub_efi_pxe_route_entry_t; + + +#define GRUB_EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES 8 +#define GRUB_EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES 8 typedef struct grub_efi_pxe_mode { - grub_uint8_t unused[52]; + grub_efi_boolean_t started; + grub_efi_boolean_t ipv6_available; + grub_efi_boolean_t ipv6_supported; + grub_efi_boolean_t using_ipv6; + grub_efi_boolean_t bis_supported; + grub_efi_boolean_t bis_detected; + grub_efi_boolean_t auto_arp; + grub_efi_boolean_t send_guid; + grub_efi_boolean_t dhcp_discover_valid; + grub_efi_boolean_t dhcp_ack_received; + grub_efi_boolean_t proxy_offer_received; + grub_efi_boolean_t pxe_discover_valid; + grub_efi_boolean_t pxe_reply_received; + grub_efi_boolean_t pxe_bis_reply_received; + grub_efi_boolean_t icmp_error_received; + grub_efi_boolean_t tftp_error_received; + grub_efi_boolean_t make_callbacks; + grub_efi_uint8_t ttl; + grub_efi_uint8_t tos; + grub_efi_ip_address_t station_ip; + grub_efi_ip_address_t subnet_mask; grub_efi_pxe_packet_t dhcp_discover; grub_efi_pxe_packet_t dhcp_ack; grub_efi_pxe_packet_t proxy_offer; grub_efi_pxe_packet_t pxe_discover; grub_efi_pxe_packet_t pxe_reply; + grub_efi_pxe_packet_t pxe_bis_reply; + grub_efi_pxe_ip_filter_t ip_filter; + grub_efi_uint32_t arp_cache_entries; + grub_efi_pxe_arp_entry_t arp_cache[GRUB_EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES]; + grub_efi_uint32_t route_table_entries; + grub_efi_pxe_route_entry_t route_table[GRUB_EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES]; + grub_efi_pxe_icmp_error_t icmp_error; + grub_efi_pxe_tftp_error_t tftp_error; } grub_efi_pxe_mode_t; typedef struct grub_efi_pxe -- 2.54.0 ++++++ 0003-efinet-bootp-add-net_dhcp6-command-supporting-dhcpv6.patch ++++++ ++++ 1379 lines (skipped) ++++++ 0004-grub.texi-Add-net_dhcp6-document.patch ++++++ >From c1abd5d8dd4dd08a501707a8540be2f157ae77af Mon Sep 17 00:00:00 2001 From: Michael Chang <[email protected]> Date: Mon, 16 Dec 2024 16:03:33 +0800 Subject: [PATCH 04/10] grub.texi: Add net_dhcp6 document Update grub documentation for net_dhcp6 command. Signed-off-by: Ken Lin <[email protected]> Signed-off-by: Robbie Harwood <[email protected]> Signed-off-by: Michael Chang <[email protected]> Reviewed-by: Leo Sandoval <[email protected]> Reviewed-by: Andrew Hamilton <[email protected]> Part-of: <https://gitlab.freedesktop.org/gnu-grub/grub/-/merge_requests/127> --- docs/grub.texi | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index c948e1ee7..94d08d85d 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5477,6 +5477,12 @@ This includes the following commands: @item @command{net_dhcp} - @pxref{net_dhcp} +@item +@command{net_bootp6} - @pxref{net_bootp6} + +@item +@command{net_dhcp6} - @pxref{net_dhcp6} + @item @command{net_get_dhcp_option} - @pxref{net_get_dhcp_option} @@ -8791,10 +8797,12 @@ Note: The command is not allowed when lockdown is enforced (@pxref{Lockdown}). * net_add_dns:: Add a DNS server * net_add_route:: Add routing entry * net_bootp:: Perform a bootp/DHCP autoconfiguration +* net_bootp6:: Perform a DHCPv6 autoconfiguration * net_del_addr:: Remove IP address from interface * net_del_dns:: Remove a DNS server * net_del_route:: Remove a route entry * net_dhcp:: Perform a DHCP autoconfiguration +* net_dhcp6:: Perform a DHCPv6 autoconfiguration * net_get_dhcp_option:: Retrieve DHCP options * net_ipv6_autoconf:: Perform IPv6 autoconfiguration * net_ls_addr:: List interfaces @@ -8849,6 +8857,17 @@ command (@pxref{net_dhcp}). @end deffn +@node net_bootp6 +@subsection net_bootp6 + +@deffn Command net_bootp6 [@var{card}] +Alias for net_dhcp6, for compatibility with older version of the downstream +patch set. It will perform the same DHCPv6 handshake with the net_dhcp6 command +(@pxref{net_dhcp6}). + +@end deffn + + @node net_del_addr @subsection net_del_addr @@ -8917,6 +8936,17 @@ Sets environment variable @samp{net_}@var{<card>}@samp{_boot_file} @end deffn +@node net_dhcp6 +@subsection net_dhcp6 + +@deffn Command net_dhcp6 [@var{card}] +Perform configuration of @var{card} using DHCPv6 protocol. If no card name is +specified, try to configure all existing cards. If configuration was +successful, interface with name @var{card}@samp{:dhcp6} and configured address +is added to @var{card}. +@end deffn + + @node net_get_dhcp_option @subsection net_get_dhcp_option -- 2.54.0 ++++++ 0005-bootp-Process-DHCPACK-packet-during-HTTP-Boot.patch ++++++ >From 63a340f776a56934260b106f73263d6ee8853910 Mon Sep 17 00:00:00 2001 From: Michael Chang <[email protected]> Date: Mon, 16 Dec 2024 16:03:34 +0800 Subject: [PATCH 05/10] bootp: Process DHCPACK packet during HTTP Boot The vendor class identifier with the string "HTTPClient" is used to indicate that the packet is responding to an HTTP boot request. In the DHCPv4 configuration, the boot_file for HTTP boot specifies the URL of the boot file, while for PXE boot, it specifies the path to the boot file. Consequently, the next-server field becomes obsolete, as the HTTP URL already encodes the server address for the boot file. In DHCPv6 configuration, no ambiguity in the boot_file, as dhcp6.bootfile-url is used to specify the URL for both HTTP and PXE boot files. This update adds processing for the "HTTPClient" vendor class identifier in DHCPACK packets, interpreting it as an HTTP format rather than a PXE format. Signed-off-by: Ken Lin <[email protected]> Signed-off-by: Robbie Harwood <[email protected]> Signed-off-by: Michael Chang <[email protected]> Reviewed-by: Leo Sandoval <[email protected]> Reviewed-by: Andrew Hamilton <[email protected]> Part-of: <https://gitlab.freedesktop.org/gnu-grub/grub/-/merge_requests/127> --- grub-core/net/bootp.c | 38 ++++++++++++++++++++++++++++++++++++-- include/grub/net.h | 1 + 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index d9988908f..79019aeb1 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -20,6 +20,7 @@ #include <grub/env.h> #include <grub/i18n.h> #include <grub/command.h> +#include <grub/net.h> #include <grub/net/ip.h> #include <grub/net/netbuff.h> #include <grub/net/udp.h> @@ -348,6 +349,9 @@ grub_net_configure_by_dhcp_ack (const char *name, grub_uint8_t opt_len, overload = 0; const char *boot_file = 0, *server_name = 0; grub_size_t boot_file_len, server_name_len; + char *vci_server_name = NULL; + char *vci_boot_file = NULL; + char *vci_protocol = NULL; addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; addr.ipv4 = bp->your_ip; @@ -397,6 +401,22 @@ grub_net_configure_by_dhcp_ack (const char *name, boot_file_len = sizeof (bp->boot_file); } + opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_VENDOR_CLASS_IDENTIFIER, &opt_len); + if (opt && opt_len) + { + grub_env_set_net_property (name, "vendor_class_identifier", (const char *) opt, opt_len); + if (opt_len == sizeof ("HTTPClient") - 1 + && grub_strncmp ((const char *) opt, "HTTPClient", opt_len) == 0 + && (boot_file && boot_file_len) + && dissect_url (boot_file, boot_file_len, &vci_protocol, &vci_server_name, &vci_boot_file)) + { + server_name = vci_server_name; + server_name_len = grub_strlen (vci_server_name); + boot_file = vci_boot_file; + boot_file_len = grub_strlen (vci_boot_file); + } + } + if (bp->server_ip) { grub_snprintf (server_ip, sizeof (server_ip), "%d.%d.%d.%d", @@ -424,7 +444,7 @@ grub_net_configure_by_dhcp_ack (const char *name, if (device && !*device && bp->server_ip) { - *device = grub_xasprintf ("tftp,%s", server_ip); + *device = grub_xasprintf ("%s,%s", vci_protocol ? : "tftp", server_ip); grub_print_error (); } @@ -438,7 +458,13 @@ grub_net_configure_by_dhcp_ack (const char *name, } if (device && !*device) { - *device = grub_xasprintf ("tftp,%s", server_name); + *device = grub_xasprintf ("%s,%s", vci_protocol ? : "tftp", server_name); + grub_print_error (); + } + else if (device && vci_protocol) + { + grub_free (*device); + *device = grub_xasprintf ("%s,%s", vci_protocol, server_name); grub_print_error (); } } @@ -541,7 +567,12 @@ grub_net_configure_by_dhcp_ack (const char *name, val = grub_malloc (2 * opt_len + 4 + 1); if (!val) + { + grub_free (vci_protocol); + grub_free (vci_boot_file); + grub_free (vci_server_name); return inter; + } for (i = 0; i < opt_len; i++) { @@ -567,6 +598,9 @@ grub_net_configure_by_dhcp_ack (const char *name, else grub_errno = GRUB_ERR_NONE; + grub_free (vci_protocol); + grub_free (vci_boot_file); + grub_free (vci_server_name); return inter; } diff --git a/include/grub/net.h b/include/grub/net.h index 16f0e764d..33f0ce6de 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -530,6 +530,7 @@ enum GRUB_NET_DHCP_MESSAGE_TYPE = 53, GRUB_NET_DHCP_SERVER_IDENTIFIER = 54, GRUB_NET_DHCP_PARAMETER_REQUEST_LIST = 55, + GRUB_NET_BOOTP_VENDOR_CLASS_IDENTIFIER = 60, GRUB_NET_BOOTP_CLIENT_ID = 61, GRUB_NET_DHCP_TFTP_SERVER_NAME = 66, GRUB_NET_DHCP_BOOTFILE_NAME = 67, -- 2.54.0 ++++++ 0006-efinet-Configure-network-from-UEFI-device-path.patch ++++++ >From 3367e3b36ce9c6d0b783feb6829db6a93652cea0 Mon Sep 17 00:00:00 2001 From: Michael Chang <[email protected]> Date: Mon, 16 Dec 2024 16:03:35 +0800 Subject: [PATCH 06/10] efinet: Configure network from UEFI device path The PXE Base Code protocol, which was previously used to obtain the cached PXE DHCPACK packet, is no longer available for HTTP Boot. HTTP boot configuration must now be retrieved from the device path nodes defined in the following UEFI Specification sections: 9.3.5.12 IPv4 Device Path 9.3.5.13 IPv6 Device Path 9.3.5.23 Uniform Resource Identifiers (URI) Device Path This patch introduces the following changes: include/grub/efi/api.h: Added new structures for the Uniform Resource Identifiers (URI) and DNS Device Path. The DNS Device Path is not currently used and is skipped. grub-core/net/drivers/efi/efinet.c: Checks if the PXE Base Code is available. If not, it retrieves the network boot configuration from the device path representing the current setup. The DHCPACK packet is reconstructed from the device path and passed into the common DHCP packet processing functions to ensure the network interface is set up as it was previously. Signed-off-by: Ken Lin <[email protected]> Signed-off-by: Robbie Harwood <[email protected]> Signed-off-by: Michael Chang <[email protected]> Reviewed-by: Leo Sandoval <[email protected]> Reviewed-by: Andrew Hamilton <[email protected]> Part-of: <https://gitlab.freedesktop.org/gnu-grub/grub/-/merge_requests/127> --- grub-core/net/drivers/efi/efinet.c | 318 +++++++++++++++++++++++++++-- include/grub/efi/api.h | 20 ++ 2 files changed, 323 insertions(+), 15 deletions(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index 9c34230b3..98ea75e9a 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -23,6 +23,7 @@ #include <grub/efi/api.h> #include <grub/efi/efi.h> #include <grub/i18n.h> +#include <grub/net/netbuff.h> GRUB_MOD_LICENSE ("GPLv3+"); @@ -342,6 +343,251 @@ grub_efinet_findcards (void) grub_free (handles); } +static struct grub_net_buff * +grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *use_ipv6) +{ + grub_efi_uint16_t uri_len; + grub_efi_device_path_t *ldp, *ddp; + grub_efi_uri_device_path_t *uri_dp; + struct grub_net_buff *nb; + grub_err_t err; + + ddp = grub_efi_duplicate_device_path (dp); + if (!ddp) + return NULL; + + ldp = grub_efi_find_last_device_path (ddp); + + if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE + || GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_URI_DEVICE_PATH_SUBTYPE) + { + grub_free (ddp); + return NULL; + } + + uri_len = GRUB_EFI_DEVICE_PATH_LENGTH (ldp) > 4 ? GRUB_EFI_DEVICE_PATH_LENGTH (ldp) - 4 : 0; + + if (!uri_len) + { + grub_free (ddp); + return NULL; + } + + uri_dp = (grub_efi_uri_device_path_t *) ldp; + + ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; + ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; + ldp->length = sizeof (*ldp); + + ldp = grub_efi_find_last_device_path (ddp); + + /* Skip the DNS Device */ + if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE + && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_DNS_DEVICE_PATH_SUBTYPE) + { + ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; + ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; + ldp->length = sizeof (*ldp); + + ldp = grub_efi_find_last_device_path (ddp); + } + + if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE + || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE + && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE)) + { + grub_free (ddp); + return NULL; + } + + nb = grub_netbuff_alloc (512); + if (!nb) + { + grub_free (ddp); + return NULL; + } + + grub_memset (nb->data, 0, 512); + + if (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE) + { + grub_efi_ipv4_device_path_t *ipv4 = (grub_efi_ipv4_device_path_t *) ldp; + struct grub_net_bootp_packet *bp; + grub_uint8_t *ptr; + + bp = (struct grub_net_bootp_packet *) nb->tail; + err = grub_netbuff_put (nb, sizeof (*bp) + 4); + if (err) + { + grub_free (ddp); + grub_netbuff_free (nb); + return NULL; + } + + if (uri_len >= sizeof (bp->boot_file)) + { + grub_free (ddp); + grub_netbuff_free (nb); + return NULL; + } + grub_memcpy (bp->boot_file, uri_dp->uri, uri_len); + bp->boot_file[uri_len] = '\0'; + grub_memcpy (&bp->your_ip, ipv4->local_ip_address, sizeof (bp->your_ip)); + grub_memcpy (&bp->server_ip, ipv4->remote_ip_address, sizeof (bp->server_ip)); + + bp->vendor[0] = GRUB_NET_BOOTP_RFC1048_MAGIC_0; + bp->vendor[1] = GRUB_NET_BOOTP_RFC1048_MAGIC_1; + bp->vendor[2] = GRUB_NET_BOOTP_RFC1048_MAGIC_2; + bp->vendor[3] = GRUB_NET_BOOTP_RFC1048_MAGIC_3; + + ptr = nb->tail; + err = grub_netbuff_put (nb, sizeof (ipv4->subnet_mask) + 2); + if (err) + { + grub_free (ddp); + grub_netbuff_free (nb); + return NULL; + } + *ptr++ = GRUB_NET_BOOTP_NETMASK; + *ptr++ = sizeof (ipv4->subnet_mask); + grub_memcpy (ptr, ipv4->subnet_mask, sizeof (ipv4->subnet_mask)); + + ptr = nb->tail; + err = grub_netbuff_put (nb, sizeof (ipv4->gateway_ip_address) + 2); + if (err) + { + grub_free (ddp); + grub_netbuff_free (nb); + return NULL; + } + *ptr++ = GRUB_NET_BOOTP_ROUTER; + *ptr++ = sizeof (ipv4->gateway_ip_address); + grub_memcpy (ptr, ipv4->gateway_ip_address, sizeof (ipv4->gateway_ip_address)); + + ptr = nb->tail; + err = grub_netbuff_put (nb, sizeof ("HTTPClient") + 1); + if (err) + { + grub_free (ddp); + grub_netbuff_free (nb); + return NULL; + } + *ptr++ = GRUB_NET_BOOTP_VENDOR_CLASS_IDENTIFIER; + *ptr++ = sizeof ("HTTPClient") - 1; + grub_memcpy (ptr, "HTTPClient", sizeof ("HTTPClient") - 1); + + ptr = nb->tail; + err = grub_netbuff_put (nb, 1); + if (err) + { + grub_free (ddp); + grub_netbuff_free (nb); + return NULL; + } + *ptr = GRUB_NET_BOOTP_END; + *use_ipv6 = 0; + + ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; + ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; + ldp->length = sizeof (*ldp); + ldp = grub_efi_find_last_device_path (ddp); + + while (GRUB_EFI_DEVICE_PATH_TYPE (ldp) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE + && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_VLAN_DEVICE_PATH_SUBTYPE) + { + ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; + ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; + ldp->length = sizeof (*ldp); + ldp = grub_efi_find_last_device_path (ddp); + } + + if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE + && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE) + { + grub_efi_mac_address_device_path_t *mac = (grub_efi_mac_address_device_path_t *) ldp; + bp->hw_type = mac->if_type; + bp->hw_len = sizeof (bp->mac_addr); + grub_memcpy (bp->mac_addr, mac->mac_address, bp->hw_len); + } + } + else + { + grub_efi_ipv6_device_path_t *ipv6 = (grub_efi_ipv6_device_path_t *) ldp; + + struct grub_net_dhcp6_packet *d6p; + struct grub_net_dhcp6_option *opt; + struct grub_net_dhcp6_option_iana *iana; + struct grub_net_dhcp6_option_iaaddr *iaaddr; + + d6p = (struct grub_net_dhcp6_packet *)nb->tail; + err = grub_netbuff_put (nb, sizeof(*d6p)); + if (err) + { + grub_free (ddp); + grub_netbuff_free (nb); + return NULL; + } + d6p->message_type = GRUB_NET_DHCP6_REPLY; + + opt = (struct grub_net_dhcp6_option *) nb->tail; + err = grub_netbuff_put (nb, sizeof(*opt)); + if (err) + { + grub_free (ddp); + grub_netbuff_free (nb); + return NULL; + } + opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_IA_NA); + opt->len = grub_cpu_to_be16_compile_time (sizeof (*iana) + sizeof (*opt) + sizeof (*iaaddr)); + + err = grub_netbuff_put (nb, sizeof (*iana)); + if (err) + { + grub_free (ddp); + grub_netbuff_free (nb); + return NULL; + } + + opt = (struct grub_net_dhcp6_option *) nb->tail; + err = grub_netbuff_put (nb, sizeof (*opt)); + if (err) + { + grub_free (ddp); + grub_netbuff_free (nb); + return NULL; + } + opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_IAADDR); + opt->len = grub_cpu_to_be16_compile_time (sizeof (*iaaddr)); + + iaaddr = (struct grub_net_dhcp6_option_iaaddr *) nb->tail; + err = grub_netbuff_put (nb, sizeof (*iaaddr)); + if (err) + { + grub_free (ddp); + grub_netbuff_free (nb); + return NULL; + } + grub_memcpy (iaaddr->addr, ipv6->local_ip_address, sizeof (ipv6->local_ip_address)); + + opt = (struct grub_net_dhcp6_option *)nb->tail; + err = grub_netbuff_put (nb, sizeof (*opt) + uri_len); + if (err) + { + grub_free (ddp); + grub_netbuff_free (nb); + return NULL; + } + opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_BOOTFILE_URL); + opt->len = grub_cpu_to_be16 (uri_len); + grub_memcpy (opt->data, uri_dp->uri, uri_len); + + *use_ipv6 = 1; + } + + grub_free (ddp); + return nb; +} + static void grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, char **path) @@ -361,7 +607,12 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, { grub_efi_device_path_t *cdp; struct grub_efi_pxe *pxe; - struct grub_efi_pxe_mode *pxe_mode; + struct grub_efi_pxe_mode *pxe_mode = NULL; + grub_uint8_t *packet_buf; + grub_size_t packet_bufsz ; + int ipv6; + struct grub_net_buff *nb = NULL; + if (card->driver != &efidriver) continue; cdp = grub_efi_get_device_path (card->efi_handle); @@ -381,11 +632,30 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, ldp = grub_efi_find_last_device_path (dp); if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE - && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE)) + && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE + && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_DNS_DEVICE_PATH_SUBTYPE + && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_URI_DEVICE_PATH_SUBTYPE)) continue; dup_dp = grub_efi_duplicate_device_path (dp); if (!dup_dp) continue; + + if (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_URI_DEVICE_PATH_SUBTYPE) + { + dup_ldp = grub_efi_find_last_device_path (dup_dp); + dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; + dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; + dup_ldp->length = sizeof (*dup_ldp); + } + + dup_ldp = grub_efi_find_last_device_path (dup_dp); + if (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_DNS_DEVICE_PATH_SUBTYPE) + { + dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; + dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; + dup_ldp->length = sizeof (*dup_ldp); + } + dup_ldp = grub_efi_find_last_device_path (dup_dp); dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; @@ -406,23 +676,37 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, } pxe = grub_efi_open_protocol (hnd, &pxe_io_guid, GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); - if (! pxe) - continue; - pxe_mode = pxe->mode; + if (!pxe) + { + nb = grub_efinet_create_dhcp_ack_from_device_path (dp, &ipv6); + if (!nb) + { + grub_print_error (); + continue; + } + packet_buf = nb->head; + packet_bufsz = nb->tail - nb->head; + } + else + { + pxe_mode = pxe->mode; + packet_buf = (grub_uint8_t *) &pxe_mode->dhcp_ack; + packet_bufsz = sizeof (pxe_mode->dhcp_ack); + ipv6 = pxe_mode->using_ipv6; + } - if (pxe_mode->using_ipv6) + if (ipv6) { grub_dprintf ("efinet", "using ipv6 and dhcpv6\n"); - grub_dprintf ("efinet", "dhcp_ack_received: %s%s\n", - pxe_mode->dhcp_ack_received ? "yes" : "no", - pxe_mode->dhcp_ack_received ? "" : " cannot continue"); - if (!pxe_mode->dhcp_ack_received) - continue; + if (pxe_mode) + grub_dprintf ("efinet", "dhcp_ack_received: %s%s\n", + pxe_mode->dhcp_ack_received ? "yes" : "no", + pxe_mode->dhcp_ack_received ? "" : " cannot continue"); inter = grub_net_configure_by_dhcpv6_reply (card->name, card, 0, (struct grub_net_dhcp6_packet *) - &pxe_mode->dhcp_ack, - sizeof (pxe_mode->dhcp_ack), + packet_buf, + packet_bufsz, 1, device, path); if (grub_errno) grub_print_error (); @@ -434,8 +718,8 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, grub_dprintf ("efinet", "using ipv4 and dhcp\n"); inter = grub_net_configure_by_dhcp_ack (card->name, card, 0, (struct grub_net_bootp_packet *) - &pxe_mode->dhcp_ack, - sizeof (pxe_mode->dhcp_ack), + packet_buf, + packet_bufsz, 1, device, path); grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path); } @@ -462,6 +746,10 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, vlan_dp = (grub_efi_device_path_t *) ((grub_efi_uint8_t *) vlan_dp + vlan_dp_len); } } + + if (nb) + grub_netbuff_free (nb); + return; } } diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index f32138bf7..04193692b 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -919,6 +919,8 @@ struct grub_efi_ipv4_device_path grub_efi_uint16_t remote_port; grub_efi_uint16_t protocol; grub_efi_uint8_t static_ip_address; + grub_efi_ipv4_address_t gateway_ip_address; + grub_efi_ipv4_address_t subnet_mask; } GRUB_PACKED; typedef struct grub_efi_ipv4_device_path grub_efi_ipv4_device_path_t; @@ -982,6 +984,24 @@ struct grub_efi_vlan_device_path } GRUB_PACKED; typedef struct grub_efi_vlan_device_path grub_efi_vlan_device_path_t; +#define GRUB_EFI_URI_DEVICE_PATH_SUBTYPE 24 + +struct grub_efi_uri_device_path +{ + grub_efi_device_path_t header; + grub_efi_char8_t uri[0]; +} GRUB_PACKED; +typedef struct grub_efi_uri_device_path grub_efi_uri_device_path_t; + +#define GRUB_EFI_DNS_DEVICE_PATH_SUBTYPE 31 +struct grub_efi_dns_device_path +{ + grub_efi_device_path_t header; + grub_efi_uint8_t is_ipv6; + grub_efi_pxe_ip_address_t dns_server_ip[0]; +} GRUB_PACKED; +typedef struct grub_efi_dns_device_path grub_efi_dns_device_path_t; + #define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10 /* Media Device Path. */ -- 2.54.0 ++++++ 0007-efinet-Set-DNS-server-from-UEFI-protocol.patch ++++++ >From 9f6c8a42c7a4c605adf5dfc3f24b15f4d80850c8 Mon Sep 17 00:00:00 2001 From: Michael Chang <[email protected]> Date: Mon, 16 Dec 2024 16:03:36 +0800 Subject: [PATCH 07/10] efinet: Set DNS server from UEFI protocol In the URI device path node, any string of characters (i.e., a name), rather than a network address, can be used to look up resources. This requires DNS services to resolve the name to an IP address. However, since the DNS device path requires a later UEFI version and may not always be available, we use the EFI_IP4_CONFIG2_PROTOCOL and EFI_IP6_CONFIG_PROTOCOL to obtain the DNS server information. These two protocols are defined in the following sections of the UEFI specification: 27.5 EFI IPv4 Configuration II Protocol 27.7 EFI IPv6 Configuration Protocol include/grub/efi/api.h: Added new structures and protocol UUIDs for EFI_IP4_CONFIG2_PROTOCOL and EFI_IP6_CONFIG_PROTOCOL. grub-core/net/drivers/efi/efinet.c: Uses the EFI_IP4_CONFIG2_PROTOCOL and EFI_IP6_CONFIG_PROTOCOL to obtain the DNS server addresses for IPv4 and IPv6, respectively. The DNS server addresses are incorporated into the DHCPACK packet and passed into the shared DHCP packet processing routines to ensure the network interface is configured as it was previously. Signed-off-by: Ken Lin <[email protected]> Signed-off-by: Robbie Harwood <[email protected]> Signed-off-by: Michael Chang <[email protected]> Reviewed-by: Leo Sandoval <[email protected]> Reviewed-by: Andrew Hamilton <[email protected]> Part-of: <https://gitlab.freedesktop.org/gnu-grub/grub/-/merge_requests/127> --- grub-core/net/drivers/efi/efinet.c | 171 +++++++++++++++++++++++++++++ include/grub/efi/api.h | 78 +++++++++++++ 2 files changed, 249 insertions(+) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index 98ea75e9a..47424184b 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -30,6 +30,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); /* GUID. */ static grub_guid_t net_io_guid = GRUB_EFI_SIMPLE_NETWORK_GUID; static grub_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID; +static grub_guid_t ip4_config_guid = GRUB_EFI_IP4_CONFIG2_PROTOCOL_GUID; +static grub_guid_t ip6_config_guid = GRUB_EFI_IP6_CONFIG_PROTOCOL_GUID; static grub_err_t send_card_buffer (struct grub_net_card *dev, @@ -343,6 +345,125 @@ grub_efinet_findcards (void) grub_free (handles); } +static grub_efi_handle_t +grub_efi_locate_device_path (grub_guid_t *protocol, grub_efi_device_path_t *device_path, + grub_efi_device_path_t **r_device_path) +{ + grub_efi_handle_t handle; + grub_efi_status_t status; + + status = grub_efi_system_table->boot_services->locate_device_path ( + protocol, &device_path, &handle); + + if (status != GRUB_EFI_SUCCESS) + return 0; + + if (r_device_path) + *r_device_path = device_path; + + return handle; +} + +static grub_efi_ipv4_address_t * +grub_dns_server_ip4_address (grub_efi_device_path_t *dp, grub_efi_uintn_t *num_dns) +{ + grub_efi_handle_t hnd; + grub_efi_status_t status; + grub_efi_ip4_config2_protocol_t *conf; + grub_efi_ipv4_address_t *addrs; + grub_efi_uintn_t data_size = 1 * sizeof (grub_efi_ipv4_address_t); + + hnd = grub_efi_locate_device_path (&ip4_config_guid, dp, NULL); + + if (!hnd) + return 0; + + conf = grub_efi_open_protocol (hnd, &ip4_config_guid, + GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); + + if (!conf) + return 0; + + addrs = grub_malloc (data_size); + if (!addrs) + return 0; + + status = conf->get_data (conf, + GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER, + &data_size, addrs); + + if (status == GRUB_EFI_BUFFER_TOO_SMALL) + { + grub_free (addrs); + addrs = grub_malloc (data_size); + if (!addrs) + return 0; + + status = conf->get_data (conf, + GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER, + &data_size, addrs); + } + + if (status != GRUB_EFI_SUCCESS) + { + grub_free (addrs); + return 0; + } + + *num_dns = data_size / sizeof (grub_efi_ipv4_address_t); + return addrs; +} + +static grub_efi_ipv6_address_t * +grub_dns_server_ip6_address (grub_efi_device_path_t *dp, grub_efi_uintn_t *num_dns) +{ + grub_efi_handle_t hnd; + grub_efi_status_t status; + grub_efi_ip6_config_protocol_t *conf; + grub_efi_ipv6_address_t *addrs; + grub_efi_uintn_t data_size = 1 * sizeof (grub_efi_ipv6_address_t); + + hnd = grub_efi_locate_device_path (&ip6_config_guid, dp, NULL); + + if (!hnd) + return 0; + + conf = grub_efi_open_protocol (hnd, &ip6_config_guid, + GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); + + if (!conf) + return 0; + + addrs = grub_malloc (data_size); + if (!addrs) + return 0; + + status = conf->get_data (conf, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_DNSSERVER, + &data_size, addrs); + + if (status == GRUB_EFI_BUFFER_TOO_SMALL) + { + grub_free (addrs); + addrs = grub_malloc (data_size); + if (!addrs) + return 0; + + status = conf->get_data (conf, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_DNSSERVER, + &data_size, addrs); + } + + if (status != GRUB_EFI_SUCCESS) + { + grub_free (addrs); + return 0; + } + + *num_dns = data_size / sizeof (grub_efi_ipv6_address_t); + return addrs; +} + static struct grub_net_buff * grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *use_ipv6) { @@ -414,6 +535,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u grub_efi_ipv4_device_path_t *ipv4 = (grub_efi_ipv4_device_path_t *) ldp; struct grub_net_bootp_packet *bp; grub_uint8_t *ptr; + grub_efi_ipv4_address_t *dns; + grub_efi_uintn_t num_dns; bp = (struct grub_net_bootp_packet *) nb->tail; err = grub_netbuff_put (nb, sizeof (*bp) + 4); @@ -476,6 +599,32 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u *ptr++ = sizeof ("HTTPClient") - 1; grub_memcpy (ptr, "HTTPClient", sizeof ("HTTPClient") - 1); + dns = grub_dns_server_ip4_address (dp, &num_dns); + if (dns) + { + grub_efi_uintn_t size_dns = sizeof (*dns) * num_dns; + + if (size_dns > GRUB_UCHAR_MAX) + { + num_dns = GRUB_UCHAR_MAX / sizeof (*dns); + size_dns = sizeof (*dns) * num_dns; + } + + ptr = nb->tail; + err = grub_netbuff_put (nb, size_dns + 2); + if (err) + { + grub_free (dns); + grub_free (ddp); + grub_netbuff_free (nb); + return NULL; + } + *ptr++ = GRUB_NET_BOOTP_DNS; + *ptr++ = size_dns; + grub_memcpy (ptr, dns, size_dns); + grub_free (dns); + } + ptr = nb->tail; err = grub_netbuff_put (nb, 1); if (err) @@ -518,6 +667,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u struct grub_net_dhcp6_option *opt; struct grub_net_dhcp6_option_iana *iana; struct grub_net_dhcp6_option_iaaddr *iaaddr; + grub_efi_ipv6_address_t *dns; + grub_efi_uintn_t num_dns; d6p = (struct grub_net_dhcp6_packet *)nb->tail; err = grub_netbuff_put (nb, sizeof(*d6p)); @@ -581,6 +732,26 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u opt->len = grub_cpu_to_be16 (uri_len); grub_memcpy (opt->data, uri_dp->uri, uri_len); + dns = grub_dns_server_ip6_address (dp, &num_dns); + if (dns) + { + grub_efi_uintn_t size_dns = sizeof (*dns) * num_dns; + + opt = (struct grub_net_dhcp6_option *)nb->tail; + err = grub_netbuff_put (nb, sizeof(*opt) + size_dns); + if (err) + { + grub_free (dns); + grub_free (ddp); + grub_netbuff_free (nb); + return NULL; + } + opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_DNS_SERVERS); + opt->len = grub_cpu_to_be16 (size_dns); + grub_memcpy (opt->data, dns, size_dns); + grub_free (dns); + } + *use_ipv6 = 1; } diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 04193692b..cc98e3d65 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -374,6 +374,16 @@ { 0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 } \ } +#define GRUB_EFI_IP4_CONFIG2_PROTOCOL_GUID \ + { 0x5b446ed1, 0xe30b, 0x4faa, \ + { 0x87, 0x1a, 0x36, 0x54, 0xec, 0xa3, 0x60, 0x80 } \ + } + +#define GRUB_EFI_IP6_CONFIG_PROTOCOL_GUID \ + { 0x937fe521, 0x95ae, 0x4d1a, \ + { 0x89, 0x29, 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a } \ + } + #define LINUX_EFI_INITRD_MEDIA_GUID \ { 0x5568e427, 0x68fc, 0x4f3d, \ { 0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68 } \ @@ -2008,4 +2018,72 @@ struct grub_efi_memory_attribute_protocol }; typedef struct grub_efi_memory_attribute_protocol grub_efi_memory_attribute_protocol_t; +enum grub_efi_ip4_config2_data_type + { + GRUB_EFI_IP4_CONFIG2_DATA_TYPE_INTERFACEINFO, + GRUB_EFI_IP4_CONFIG2_DATA_TYPE_POLICY, + GRUB_EFI_IP4_CONFIG2_DATA_TYPE_MANUAL_ADDRESS, + GRUB_EFI_IP4_CONFIG2_DATA_TYPE_GATEWAY, + GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER, + GRUB_EFI_IP4_CONFIG2_DATA_TYPE_MAXIMUM, + }; +typedef enum grub_efi_ip4_config2_data_type grub_efi_ip4_config2_data_type_t; + +struct grub_efi_ip4_config2_protocol +{ + grub_efi_status_t (__grub_efi_api *set_data) (struct grub_efi_ip4_config2_protocol *this, + grub_efi_ip4_config2_data_type_t data_type, + grub_efi_uintn_t data_size, + void *data); + + grub_efi_status_t (__grub_efi_api *get_data) (struct grub_efi_ip4_config2_protocol *this, + grub_efi_ip4_config2_data_type_t data_type, + grub_efi_uintn_t *data_size, + void *data); + + grub_efi_status_t (__grub_efi_api *register_data_notify) (struct grub_efi_ip4_config2_protocol *this, + grub_efi_ip4_config2_data_type_t data_type, + grub_efi_event_t event); + + grub_efi_status_t (__grub_efi_api *unregister_datanotify) (struct grub_efi_ip4_config2_protocol *this, + grub_efi_ip4_config2_data_type_t data_type, + grub_efi_event_t event); +}; +typedef struct grub_efi_ip4_config2_protocol grub_efi_ip4_config2_protocol_t; + +enum grub_efi_ip6_config_data_type + { + GRUB_EFI_IP6_CONFIG_DATA_TYPE_INTERFACEINFO, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_ALT_INTERFACEID, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_POLICY, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_DUP_ADDR_DETECT_TRANSMITS, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_MANUAL_ADDRESS, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_GATEWAY, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_DNSSERVER, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_MAXIMUM, + }; +typedef enum grub_efi_ip6_config_data_type grub_efi_ip6_config_data_type_t; + +struct grub_efi_ip6_config_protocol +{ + grub_efi_status_t (__grub_efi_api *set_data) (struct grub_efi_ip6_config_protocol *this, + grub_efi_ip6_config_data_type_t data_type, + grub_efi_uintn_t data_size, + void *data); + + grub_efi_status_t (__grub_efi_api *get_data) (struct grub_efi_ip6_config_protocol *this, + grub_efi_ip6_config_data_type_t data_type, + grub_efi_uintn_t *data_size, + void *data); + + grub_efi_status_t (__grub_efi_api *register_data_notify) (struct grub_efi_ip6_config_protocol *this, + grub_efi_ip6_config_data_type_t data_type, + grub_efi_event_t event); + + grub_efi_status_t (__grub_efi_api *unregister_datanotify) (struct grub_efi_ip6_config_protocol *this, + grub_efi_ip6_config_data_type_t data_type, + grub_efi_event_t event); +}; +typedef struct grub_efi_ip6_config_protocol grub_efi_ip6_config_protocol_t; + #endif /* ! GRUB_EFI_API_HEADER */ -- 2.54.0 ++++++ 0008-kern-efi-efi-Print-URI-and-DNS-device-path-info.patch ++++++ >From 3b2f1c791eab603086cc40497e97ff59a3671376 Mon Sep 17 00:00:00 2001 From: Michael Chang <[email protected]> Date: Mon, 16 Dec 2024 16:03:37 +0800 Subject: [PATCH 08/10] kern/efi/efi: Print URI and DNS device path info Signed-off-by: Michael Chang <[email protected]> Reviewed-by: Leo Sandoval <[email protected]> Reviewed-by: Andrew Hamilton <[email protected]> Part-of: <https://gitlab.freedesktop.org/gnu-grub/grub/-/merge_requests/127> --- grub-core/kern/efi/efi.c | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index 77456835e..d332d7d16 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -856,6 +856,57 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) dump_vendor_path ("Messaging", (grub_efi_vendor_device_path_t *) dp); break; + case GRUB_EFI_URI_DEVICE_PATH_SUBTYPE: + { + grub_efi_uri_device_path_t *uri; + grub_uint8_t *buf; + grub_efi_uint16_t uri_len; + + uri = (grub_efi_uri_device_path_t *) dp; + uri_len = len - sizeof (uri->header); + buf = grub_malloc (uri_len + 1); + if (!buf) + { + grub_print_error(); + break; + } + grub_memcpy (buf, uri->uri, uri_len); + buf[uri_len] = '\0'; + + grub_printf ("/Uri(%s)", buf); + grub_free (buf); + } + break; + case GRUB_EFI_DNS_DEVICE_PATH_SUBTYPE: + { + grub_efi_dns_device_path_t *dns; + dns = (grub_efi_dns_device_path_t *) dp; + if (dns->is_ipv6) + grub_printf ("/Dns(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)", + dns->dns_server_ip->v6.addr[0], + dns->dns_server_ip->v6.addr[1], + dns->dns_server_ip->v6.addr[2], + dns->dns_server_ip->v6.addr[3], + dns->dns_server_ip->v6.addr[4], + dns->dns_server_ip->v6.addr[5], + dns->dns_server_ip->v6.addr[6], + dns->dns_server_ip->v6.addr[7], + dns->dns_server_ip->v6.addr[8], + dns->dns_server_ip->v6.addr[9], + dns->dns_server_ip->v6.addr[10], + dns->dns_server_ip->v6.addr[11], + dns->dns_server_ip->v6.addr[12], + dns->dns_server_ip->v6.addr[13], + dns->dns_server_ip->v6.addr[14], + dns->dns_server_ip->v6.addr[15]); + else + grub_printf ("/Dns(%u.%u.%u.%u)", + dns->dns_server_ip->v4.addr[0], + dns->dns_server_ip->v4.addr[1], + dns->dns_server_ip->v4.addr[2], + dns->dns_server_ip->v4.addr[3]); + } + break; default: grub_printf ("/UnknownMessaging(%x)", (unsigned) subtype); break; -- 2.54.0 ++++++ 0009-kern-efi-efi-Correct-endianness-in-IPv6-device-path.patch ++++++ >From 49a031bb4f237baa452dbd7d2155e4cfea95152a Mon Sep 17 00:00:00 2001 From: Michael Chang <[email protected]> Date: Mon, 16 Dec 2024 16:03:38 +0800 Subject: [PATCH 09/10] kern/efi/efi: Correct endianness in IPv6 device path Signed-off-by: Michael Chang <[email protected]> Reviewed-by: Leo Sandoval <[email protected]> Reviewed-by: Andrew Hamilton <[email protected]> Part-of: <https://gitlab.freedesktop.org/gnu-grub/grub/-/merge_requests/127> --- grub-core/kern/efi/efi.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index d332d7d16..0b5a128f6 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -790,22 +790,22 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) grub_efi_ipv6_device_path_t *ipv6 = (grub_efi_ipv6_device_path_t *) dp; grub_printf ("/IPv6(%x:%x:%x:%x:%x:%x:%x:%x,%x:%x:%x:%x:%x:%x:%x:%x,%u,%u,%x,%x)", - (unsigned) ipv6->local_ip_address[0], - (unsigned) ipv6->local_ip_address[1], - (unsigned) ipv6->local_ip_address[2], - (unsigned) ipv6->local_ip_address[3], - (unsigned) ipv6->local_ip_address[4], - (unsigned) ipv6->local_ip_address[5], - (unsigned) ipv6->local_ip_address[6], - (unsigned) ipv6->local_ip_address[7], - (unsigned) ipv6->remote_ip_address[0], - (unsigned) ipv6->remote_ip_address[1], - (unsigned) ipv6->remote_ip_address[2], - (unsigned) ipv6->remote_ip_address[3], - (unsigned) ipv6->remote_ip_address[4], - (unsigned) ipv6->remote_ip_address[5], - (unsigned) ipv6->remote_ip_address[6], - (unsigned) ipv6->remote_ip_address[7], + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->local_ip_address)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->local_ip_address + 2)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->local_ip_address + 4)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->local_ip_address + 6)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->local_ip_address + 8)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->local_ip_address + 10)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->local_ip_address + 12)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->local_ip_address + 14)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->remote_ip_address)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->remote_ip_address + 2)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->remote_ip_address + 4)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->remote_ip_address + 6)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->remote_ip_address + 8)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->remote_ip_address + 10)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->remote_ip_address + 12)), + (unsigned) grub_be_to_cpu16 (grub_get_unaligned16 (ipv6->remote_ip_address + 14)), (unsigned) ipv6->local_port, (unsigned) ipv6->remote_port, (unsigned) ipv6->protocol, -- 2.54.0 ++++++ 0010-bootp-Fix-logical-operator-in-DHCP-option-overload-c.patch ++++++ >From ff4a61585af0b84c7bf6d95dd3691c2d4658f7c3 Mon Sep 17 00:00:00 2001 From: Michael Chang <[email protected]> Date: Mon, 16 Dec 2024 16:03:39 +0800 Subject: [PATCH 10/10] bootp: Fix logical operator in DHCP option overload check Signed-off-by: Michael Chang <[email protected]> Reviewed-by: Leo Sandoval <[email protected]> Reviewed-by: Andrew Hamilton <[email protected]> Part-of: <https://gitlab.freedesktop.org/gnu-grub/grub/-/merge_requests/127> --- grub-core/net/bootp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 79019aeb1..627b26810 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -394,7 +394,7 @@ grub_net_configure_by_dhcp_ack (const char *name, boot_file = (const char *) opt; boot_file_len = opt_len; } - else if (size > OFFSET_OF (boot_file, bp) && !(overload && GRUB_DHCP_OPT_OVERLOAD_FILE) && + else if (size > OFFSET_OF (boot_file, bp) && !(overload & GRUB_DHCP_OPT_OVERLOAD_FILE) && bp->boot_file[0]) { boot_file = bp->boot_file; -- 2.54.0 ++++++ grub2-bsc1220338-key_protector-implement-the-blocklist.patch ++++++ --- /var/tmp/diff_new_pack.MbNqs1/_old 2026-07-15 16:29:23.001481689 +0200 +++ /var/tmp/diff_new_pack.MbNqs1/_new 2026-07-15 16:29:23.005481824 +0200 @@ -15,10 +15,8 @@ include/grub/efi/api.h | 5 +++++ 2 files changed, 36 insertions(+) -Index: grub-2.12/grub-core/disk/key_protector.c -=================================================================== ---- grub-2.12.orig/grub-core/disk/key_protector.c -+++ grub-2.12/grub-core/disk/key_protector.c +--- a/grub-core/disk/key_protector.c ++++ b/grub-core/disk/key_protector.c @@ -25,6 +25,10 @@ GRUB_MOD_LICENSE ("GPLv3+"); @@ -30,7 +28,7 @@ struct grub_key_protector *grub_key_protectors = NULL; grub_err_t -@@ -53,11 +57,34 @@ grub_key_protector_unregister (struct gr +@@ -53,11 +57,34 @@ return GRUB_ERR_NONE; } @@ -65,7 +63,7 @@ if (grub_key_protectors == NULL) return grub_error (GRUB_ERR_OUT_OF_RANGE, "No key protector registered"); -@@ -69,5 +96,9 @@ grub_key_protector_recover_key (const ch +@@ -69,5 +96,9 @@ if (kp == NULL) return grub_error (GRUB_ERR_OUT_OF_RANGE, "Key protector '%s' not found", protector); @@ -75,12 +73,10 @@ + return kp->recover_key (key, key_size); } -Index: grub-2.12/include/grub/efi/api.h -=================================================================== ---- grub-2.12.orig/include/grub/efi/api.h -+++ grub-2.12/include/grub/efi/api.h -@@ -389,6 +389,11 @@ - { 0x89, 0x29, 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a } \ +--- a/include/grub/efi/api.h ++++ b/include/grub/efi/api.h +@@ -409,6 +409,11 @@ + { 0xbd, 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25 } \ } +#define GRUB_EFI_SYSTEMD_GUID \
