Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:michael-chang:test:grub:old
grub2
0021-grub_dl_load_segments-page-align-the-tramp...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0021-grub_dl_load_segments-page-align-the-tramp-GOT-areas.patch of Package grub2
From 62667d7a460a46e210eca26cc7acf57941d4716e Mon Sep 17 00:00:00 2001 From: Laszlo Ersek <lersek@redhat.com> Date: Fri, 7 Apr 2023 16:56:09 +0200 Subject: [PATCH 21/26] grub_dl_load_segments(): page-align the tramp/GOT areas too The tramp/GOT write-protection in grub_dl_set_mem_attrs() requires that the tramp/GOT areas of the module image *not* share a page with any other memory allocations. Page-align the tramp/GOT areas, while satisfying their intrinsic alignment requirements too. Fixes: 887f1d8fa976 (modules: load module sections at page-aligned addresses) Fixes: ad1b904d325b (nx: set page permissions for loaded modules.) Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- grub-core/kern/dl.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index 8df02939e..0539d5401 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -231,7 +231,9 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) grub_size_t tsize = 0, talign = 1, arch_addralign = 1; #if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv) && !defined (__s390x__) grub_size_t tramp; + grub_size_t tramp_align; grub_size_t got; + grub_size_t got_align; grub_err_t err; #endif char *ptr; @@ -262,12 +264,18 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) err = grub_arch_dl_get_tramp_got_size (e, &tramp, &got); if (err) return err; - tsize += ALIGN_UP (tramp, GRUB_ARCH_DL_TRAMP_ALIGN); - if (talign < GRUB_ARCH_DL_TRAMP_ALIGN) - talign = GRUB_ARCH_DL_TRAMP_ALIGN; - tsize += ALIGN_UP (got, GRUB_ARCH_DL_GOT_ALIGN); - if (talign < GRUB_ARCH_DL_GOT_ALIGN) - talign = GRUB_ARCH_DL_GOT_ALIGN; + tramp_align = GRUB_ARCH_DL_TRAMP_ALIGN; + if (tramp_align < arch_addralign) + tramp_align = arch_addralign; + tsize += ALIGN_UP (tramp, tramp_align); + if (talign < tramp_align) + talign = tramp_align; + got_align = GRUB_ARCH_DL_GOT_ALIGN; + if (got_align < arch_addralign) + got_align = arch_addralign; + tsize += ALIGN_UP (got, got_align); + if (talign < got_align) + talign = got_align; #endif #ifdef GRUB_MACHINE_EMU @@ -327,11 +335,11 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) } } #if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv) && !defined (__s390x__) - ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_TRAMP_ALIGN); + ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, tramp_align); mod->tramp = ptr; mod->trampptr = ptr; ptr += tramp; - ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_GOT_ALIGN); + ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, got_align); mod->got = ptr; mod->gotptr = ptr; ptr += got; -- 2.42.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor