From: "Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: [PATCH 03/15] modules: Don't allocate space for non-allocable sections.
Date: Fri, 24 May 2024 20:45:04 +0300 [thread overview]
Message-ID: <CAEaD8JPKN48GxDZK1+3BytD1WBOhQGFCr0Kig2-eCuiNGCRugw@mail.gmail.com> (raw)
In-Reply-To: <20240524110402.203880-4-mate.kukri@canonical.com>
Reviewed-By: Vladimir Serbinenko
On Fri, May 24, 2024 at 2:06 PM Mate Kukri <mate.kukri@canonical.com> wrote:
>
> From: Peter Jones <pjones@redhat.com>
>
> Currently when loading grub modules, we allocate space for all sections,
> including those without SHF_ALLOC set. We then copy the sections that
> /do/ have SHF_ALLOC set into the allocated memory, leaving some of our
> allocation untouched forever. Additionally, on platforms with GOT
> fixups and trampolines, we currently compute alignment round-ups for the
> sections and sections with sh_size = 0.
>
> This patch removes the extra space from the allocation computation, and
> makes the allocation computation loop skip empty sections as the loading
> loop does.
>
> Signed-off-by: Peter Jones <pjones@redhat.com>
> (cherry picked from commit 0f76b53f2fe86542123c7aa1ae39c90852972a99)
> Signed-off-by: Jan Setje-Eilers <jan.setjeeilers@oracle.com>
> Signed-off-by: Mate Kukri <mate.kukri@canonical.com>
> ---
> grub-core/kern/dl.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
> index 0bf40caa6..37db9fab0 100644
> --- a/grub-core/kern/dl.c
> +++ b/grub-core/kern/dl.c
> @@ -237,6 +237,9 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
> i < e->e_shnum;
> i++, s = (const Elf_Shdr *)((const char *) s + e->e_shentsize))
> {
> + if (s->sh_size == 0 || !(s->sh_flags & SHF_ALLOC))
> + continue;
> +
> tsize = ALIGN_UP (tsize, s->sh_addralign) + s->sh_size;
> if (talign < s->sh_addralign)
> talign = s->sh_addralign;
> --
> 2.39.2
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
--
Regards
Vladimir 'phcoder' Serbinenko
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next prev parent reply other threads:[~2024-05-24 17:46 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-24 11:03 [PATCH 00/15] UEFI NX support and NX Linux loader using shim loader protocol Mate Kukri
2024-05-24 11:03 ` [PATCH 01/15] modules: make .module_license read-only Mate Kukri
2024-05-24 17:41 ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 02/15] modules: strip .llvm_addrsig sections and similar Mate Kukri
2024-05-24 17:42 ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 03/15] modules: Don't allocate space for non-allocable sections Mate Kukri
2024-05-24 17:45 ` Vladimir 'phcoder' Serbinenko [this message]
2024-05-24 11:03 ` [PATCH 04/15] pe: add the DOS header struct and fix some bad naming Mate Kukri
2024-05-24 17:49 ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 05/15] modules: load module sections at page-aligned addresses Mate Kukri
2024-05-24 17:57 ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 06/15] nx: add memory attribute get/set API Mate Kukri
2024-05-24 18:03 ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 07/15] nx: set page permissions for loaded modules Mate Kukri
2024-05-24 18:10 ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 08/15] nx: set the nx compatible flag in EFI grub images Mate Kukri
2024-05-24 18:11 ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 09/15] grub_dl_load_segments(): page-align the tramp/GOT areas too Mate Kukri
2024-05-24 18:15 ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 10/15] grub_dl_set_mem_attrs(): add self-check for the tramp/GOT sizes Mate Kukri
2024-05-24 18:16 ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:03 ` [PATCH 11/15] grub_dl_set_mem_attrs(): fix format string Mate Kukri
2024-05-24 11:03 ` [PATCH 12/15] mm: Fixup bogus assumptions about types sizes in format strings Mate Kukri
2024-05-24 11:04 ` [PATCH 13/15] efi: Provide wrappers for load_image, start_image, unload_image Mate Kukri
2024-05-24 18:27 ` Vladimir 'phcoder' Serbinenko
2024-05-24 11:04 ` [PATCH 14/15] efi: Use shim's loader protocol for EFI image verification and loading Mate Kukri
2024-05-24 11:04 ` [PATCH 15/15] efi: Disallow fallback to legacy Linux loader when shim says NX is required Mate Kukri
2024-05-24 18:23 ` [PATCH 00/15] UEFI NX support and NX Linux loader using shim loader protocol Vladimir 'phcoder' Serbinenko
2024-05-24 19:07 ` Mate Kukri
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAEaD8JPKN48GxDZK1+3BytD1WBOhQGFCr0Kig2-eCuiNGCRugw@mail.gmail.com \
--to=phcoder@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).