- Add 5005-Revert-boot-Make-initrd_prepare-semantically-equival.patch

Revert commit d64193a2a652b15db9cb9ed10c6b77a17ca46cd2 until the regression it
  caused, reported at https://github.com/systemd/systemd/issues/35439, is fixed
  (see also bsc#1233752 for its downstream counterpart).

OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=1562
This commit is contained in:
Franck Bui 2024-12-03 15:05:11 +00:00 committed by Git OBS Bridge
parent 6c624246d2
commit 941f6c37db
3 changed files with 151 additions and 0 deletions

View File

@ -0,0 +1,141 @@
From 6d370166c42d6bd0d6907acc75ce6f09ade1e629 Mon Sep 17 00:00:00 2001
From: Franck Bui <fbui@suse.com>
Date: Mon, 2 Dec 2024 09:45:27 +0100
Subject: [PATCH 1/1] Revert "boot: Make initrd_prepare() semantically
equivalent to combine_initrds()"
This reverts commit f8fa4222c9ac3e74e91c64e25e9532c99559cf99.
---
src/boot/boot.c | 56 ++++++++++++++-----------------------------------
1 file changed, 16 insertions(+), 40 deletions(-)
diff --git a/src/boot/boot.c b/src/boot/boot.c
index 129d6f8f5d..2d84b6c320 100644
--- a/src/boot/boot.c
+++ b/src/boot/boot.c
@@ -13,7 +13,6 @@
#include "initrd.h"
#include "linux.h"
#include "measure.h"
-#include "memory-util-fundamental.h"
#include "part-discovery.h"
#include "pe.h"
#include "proto/block-io.h"
@@ -2422,18 +2421,18 @@ static EFI_STATUS initrd_prepare(
EFI_FILE *root,
const BootEntry *entry,
char16_t **ret_options,
- Pages *ret_initrd_pages,
+ void **ret_initrd,
size_t *ret_initrd_size) {
assert(root);
assert(entry);
assert(ret_options);
- assert(ret_initrd_pages);
+ assert(ret_initrd);
assert(ret_initrd_size);
if (entry->type != LOADER_LINUX || !entry->initrd) {
*ret_options = NULL;
- *ret_initrd_pages = (Pages) {};
+ *ret_initrd = NULL;
*ret_initrd_size = 0;
return EFI_SUCCESS;
}
@@ -2447,6 +2446,7 @@ static EFI_STATUS initrd_prepare(
EFI_STATUS err;
size_t size = 0;
+ _cleanup_free_ uint8_t *initrd = NULL;
STRV_FOREACH(i, entry->initrd) {
_cleanup_free_ char16_t *o = options;
@@ -2465,54 +2465,30 @@ static EFI_STATUS initrd_prepare(
if (err != EFI_SUCCESS)
return err;
- if (!INC_SAFE(&size, ALIGN4(info->FileSize)))
- return EFI_OUT_OF_RESOURCES;
- }
-
- _cleanup_pages_ Pages pages = xmalloc_initrd_pages(size);
- uint8_t *p = PHYSICAL_ADDRESS_TO_POINTER(pages.addr);
-
- STRV_FOREACH(i, entry->initrd) {
- _cleanup_(file_closep) EFI_FILE *handle = NULL;
- err = root->Open(root, &handle, *i, EFI_FILE_MODE_READ, 0);
- if (err != EFI_SUCCESS)
- return err;
-
- _cleanup_free_ EFI_FILE_INFO *info = NULL;
- err = get_file_info(handle, &info, NULL);
- if (err != EFI_SUCCESS)
- return err;
-
if (info->FileSize == 0) /* Automatically skip over empty files */
continue;
- size_t read_size = info->FileSize;
- err = chunked_read(handle, &read_size, p);
+ size_t new_size, read_size = info->FileSize;
+ if (!ADD_SAFE(&new_size, size, read_size))
+ return EFI_OUT_OF_RESOURCES;
+ initrd = xrealloc(initrd, size, new_size);
+
+ err = chunked_read(handle, &read_size, initrd + size);
if (err != EFI_SUCCESS)
return err;
/* Make sure the actual read size is what we expected. */
- assert(read_size == info->FileSize);
- p += read_size;
-
- size_t pad;
- pad = ALIGN4(read_size) - read_size;
- if (pad == 0)
- continue;
-
- memzero(p, pad);
- p += pad;
+ assert(size + read_size == new_size);
+ size = new_size;
}
- assert(PHYSICAL_ADDRESS_TO_POINTER(pages.addr + size) == p);
-
if (entry->options) {
_cleanup_free_ char16_t *o = options;
options = xasprintf("%ls %ls", o, entry->options);
}
*ret_options = TAKE_PTR(options);
- *ret_initrd_pages = TAKE_STRUCT(pages);
+ *ret_initrd = TAKE_PTR(initrd);
*ret_initrd_size = size;
return EFI_SUCCESS;
}
@@ -2542,9 +2518,9 @@ static EFI_STATUS image_start(
return log_error_status(err, "Error making file device path: %m");
size_t initrd_size = 0;
- _cleanup_pages_ Pages initrd_pages = {};
+ _cleanup_free_ void *initrd = NULL;
_cleanup_free_ char16_t *options_initrd = NULL;
- err = initrd_prepare(image_root, entry, &options_initrd, &initrd_pages, &initrd_size);
+ err = initrd_prepare(image_root, entry, &options_initrd, &initrd, &initrd_size);
if (err != EFI_SUCCESS)
return log_error_status(err, "Error preparing initrd: %m");
@@ -2562,7 +2538,7 @@ static EFI_STATUS image_start(
}
_cleanup_(cleanup_initrd) EFI_HANDLE initrd_handle = NULL;
- err = initrd_register(PHYSICAL_ADDRESS_TO_POINTER(initrd_pages.addr), initrd_size, &initrd_handle);
+ err = initrd_register(initrd, initrd_size, &initrd_handle);
if (err != EFI_SUCCESS)
return log_error_status(err, "Error registering initrd: %m");
--
2.43.0

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Tue Dec 3 14:27:15 UTC 2024 - Franck Bui <fbui@suse.com>
- Add 5005-Revert-boot-Make-initrd_prepare-semantically-equival.patch
Revert commit d64193a2a652b15db9cb9ed10c6b77a17ca46cd2 until the regression it
caused, reported at https://github.com/systemd/systemd/issues/35439, is fixed
(see also bsc#1233752 for its downstream counterpart).
-------------------------------------------------------------------
Tue Dec 3 09:39:39 UTC 2024 - Franck Bui <fbui@suse.com>

View File

@ -237,6 +237,7 @@ Patch: 0009-pid1-handle-console-specificities-weirdness-for-s390.patch
Patch: 5001-Revert-udev-update-devlink-with-the-newer-device-nod.patch
Patch: 5002-Revert-udev-revert-workarounds-for-issues-caused-by-.patch
Patch: 5004-disable-session-freeze.patch
Patch: 5005-Revert-boot-Make-initrd_prepare-semantically-equival.patch
%endif
%description