On 2/26/26 09:14, Mikle Lappo wrote:
Add maintainers into CC

On Wed, Feb 25, 2026 at 2:07 PM <[email protected] <mailto:[email protected]>> wrote:

    From: Mikhail Lappo <[email protected] <mailto:[email protected]>>

    libfdt requires the FDT blob to be 8-byte aligned. The alignment is
    validated in fdt_check_header(), and misaligned blobs may be rejected
    or cause failures on architectures that enforce strict alignment.

    Currently the blob is allocated with grub_malloc(), which does not
    guarantee 8-byte alignment. Replace it with grub_memalign(8, size)
    to ensure the required alignment.

    Signed-off-by: Mikhail Lappo <[email protected]
    <mailto:[email protected]>>
    ---
      grub-core/loader/efi/fdt.c | 3 ++-
      1 file changed, 2 insertions(+), 1 deletion(-)

    diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
    index e510b3491..f25d362d3 100644
    --- a/grub-core/loader/efi/fdt.c
    +++ b/grub-core/loader/efi/fdt.c
    @@ -38,6 +38,7 @@ static void *fdt;
      #define FDT_ADDR_SIZE_EXTRA ((2 * grub_fdt_prop_entry_size
    (sizeof(grub_uint32_t))) + \
                                   sizeof (FDT_ADDR_CELLS_STRING) + \
                                   sizeof (FDT_SIZE_CELLS_STRING))
    +#define FDT_BLOB_ALIGNMENT 8

      static const struct grub_arg_option options_fdtdump[] = {
        {"prop",     'p', 0, N_("Get property."), N_("prop"),
    ARG_TYPE_STRING},
    @@ -145,7 +146,7 @@ grub_cmd_devicetree (grub_command_t cmd
    __attribute__ ((unused)),
          goto out;

        size = grub_file_size (dtb);
    -  blob = grub_malloc (size);
    +  blob = grub_memalign (FDT_BLOB_ALIGNMENT, size);
        if (!blob)
          goto out;

-- 2.44.0


Isn't #define GRUB_MM_ALIGN_LOG2 setting a minimum alignment of 16 bytes on 32-bit and 32 bytes on 64-bit systems?

Please, have a look at the code starting here:

grub-core/kern/mm.c:478:  align = (align >> GRUB_MM_ALIGN_LOG2);

Best regards

Heinrich

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to