Alexey Makhalov
f7bd9986f6
efi: Fix use-after-free in halt/reboot path
...
commit 92bfc33db9
("efi: Free malloc regions on exit")
introduced memory freeing in grub_efi_fini(), which is
used not only by exit path but by halt/reboot one as well.
As result of memory freeing, code and data regions used by
modules, such as halt, reboot, acpi (used by halt) also got
freed. After return to module code, CPU executes, filled
by UEFI firmware (tested with edk2), 0xAFAFAFAF pattern as
a code. Which leads to #UD exception later.
grub> halt
!!!! X64 Exception Type - 06(#UD - Invalid Opcode) CPU Apic ID - 00000000 !!!!
RIP - 0000000003F4EC28, CS - 0000000000000038, RFLAGS - 0000000000200246
RAX - 0000000000000000, RCX - 00000000061DA188, RDX - 0A74C0854DC35D41
RBX - 0000000003E10E08, RSP - 0000000007F0F860, RBP - 0000000000000000
RSI - 00000000064DB768, RDI - 000000000832C5C3
R8 - 0000000000000002, R9 - 0000000000000000, R10 - 00000000061E2E52
R11 - 0000000000000020, R12 - 0000000003EE5C1F, R13 - 00000000061E0FF4
R14 - 0000000003E10D80, R15 - 00000000061E2F60
DS - 0000000000000030, ES - 0000000000000030, FS - 0000000000000030
GS - 0000000000000030, SS - 0000000000000030
CR0 - 0000000080010033, CR2 - 0000000000000000, CR3 - 0000000007C01000
CR4 - 0000000000000668, CR8 - 0000000000000000
DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
GDTR - 00000000079EEA98 0000000000000047, LDTR - 0000000000000000
IDTR - 0000000007598018 0000000000000FFF, TR - 0000000000000000
FXSAVE_STATE - 0000000007F0F4C0
Proposal here is to continue to free allocated memory for
exit boot services path but keep it for halt/reboot path
as it won't be much security concern here.
Introduced GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY
loader flag to be used by efi halt/reboot path.
Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-07-29 16:55:48 +02:00
Vladimir Serbinenko
d454509bb8
Fix remaining cases of gcc 7 fallthrough warning.
...
They are all intended, so just add the relevant comment.
2017-04-12 01:42:38 +00:00
Vladimir Serbinenko
c96cfac167
Fix mingw compilation.
2017-02-03 13:01:34 +01:00
Vladimir Serbinenko
ea20dd2b22
ia64: Fix iterator for relocation entries.
...
Don't assume relocation entry size and use sh_entsize properly.
2017-02-01 20:10:26 +01:00
Vladimir Serbinenko
a134ef1ab9
ia64: Add support for R_IA64_GPREL64I.
...
Recent GCC generates those relocations, so we need to support them.
2017-01-31 12:39:01 +01:00
Vladimir Serbinenko
30d0053799
* grub-core/kern/ia64/dl.c (grub_arch_dl_relocate_symbols): Add checks
...
for relocation range.
2013-12-11 11:29:35 +01:00
Vladimir Serbinenko
979742bc7e
* grub-core/kern/ia64/dl.c (grub_arch_dl_relocate_symbols): Handle
...
non-function pcrel21b relocation. It happens with .text.unlikely
section.
2013-12-11 11:28:48 +01:00
Vladimir Serbinenko
4f4ea1b449
* grub-core/kern/ia64/dl_helper.c (grub_ia64_dl_get_tramp_got_size):
...
Do not explicitly check for symbol table as it's already checked in
platform-independent layer.
2013-12-09 14:22:31 +01:00
Vladimir Serbinenko
78b2b0a1a0
* grub-core/kern/ia64/efi/init.c (grub_arch_sync_caches): Move to ...
...
* grub-core/kern/ia64/cache.c (grub_arch_sync_caches): ... here.
2013-12-08 18:27:40 +01:00
Vladimir Serbinenko
fbbfb6ab11
* grub-core/kern/ia64/efi/init.c: Fix alignment code so it doesn't
...
truncate incomplete lines but instead flushes them.
2013-12-08 18:10:05 +01:00
Vladimir Serbinenko
8c534b85f1
Revamp relocation handling.
...
Move more code to common dl.c. Add missing veneers for arm and arm64.
Decreases kernel size by 70 bytes on i386-pc (40-50 compressed)
2013-12-06 09:18:55 +01:00
Vladimir Serbinenko
ce55ed0389
Remove leftover GRUB_IA64_DL_TRAMP_SIZE.
2013-11-30 11:14:30 +01:00
Vladimir Serbinenko
4906052019
Unify GOT/trampoline handling between PPC, MIPS and IA64 as they
...
do essentially the same thing, do it in similar way.
2013-11-21 21:54:33 +01:00
Vladimir Serbinenko
631187be8c
Add missing includes of loader.h.
2013-11-11 02:30:09 +01:00
Vladimir Serbinenko
9612ebc00e
Add new ports: i386-xen and x86_64-xen. This allows running GRUB in
...
XEN PV environment and load kernels.
2013-11-09 21:29:11 +01:00
Vladimir 'phcoder' Serbinenko
d5e2a158e1
Fix ia64-efi image generation on big-endian machines. Deduplicate
...
some code while on it.
Reported by: Leif Lindholm.
2013-04-09 19:19:19 +02:00
Vladimir 'phcoder' Serbinenko
9e5e66d15e
Use ITC on IA64 rather than broken routine based on daytime.
...
* grub-core/kern/efi/efi.c (grub_rtc_get_time_ms) [__ia64__]: Remove on
ia64.
(grub_get_rtc) [__ia64__]: Likewise.
* grub-core/kern/ia64/efi/init.c (divisor): New variable.
(get_itc): New function.
(grub_rtc_get_time_ms): Likewise.
(grub_machine_init): Calibrate ITC.
* include/grub/efi/time.h (grub_get_rtc), (GRUB_TICKS_PER_SECOND):
Keep only on non-ia64. Don't export since it's broken and used only
if TSC is unavailable.
2012-06-09 10:52:39 +02:00
Vladimir 'phcoder' Serbinenko
67093bc0ed
Another round of string clarification and adding TRANSLATORS comments.
2012-02-26 17:28:05 +01:00
Vladimir 'phcoder' Serbinenko
ebcecdf1c3
Increase warning level.
...
* conf/Makefile.common (CFLAGS_GNULIB): Add -Wno-redundant-decls
-Wno-unreachable-code -Wno-conversion -Wno-old-style-definition.
* configure.ac (HOST_CFLAGS): Add bunch of -W arguments.
(TARGET_CFLAGS): Likewise.
(HOST_CFLAGS): Add -Werror unless --disable-werror is activated.
* grub-core/Makefile.core.def (decompressor_xz): Add
-Wno-unreachable-code.
(normal): Add -Wno-redundant-decls.
(xzio): Add -Wno-unreachable-code.
(lzopio): Add -Wno-redundant-decls -Wno-error.
* grub-core/commands/acpi.c: Add exception to -Wcast-align.
* grub-core/commands/lsacpi.c: Add exception to -Wcast-align.
* grub-core/gensymlist.sh: Add exception to -Wmissing-format-attribute.
* grub-core/kern/dl.c: Add exception to -Wcast-align.
* grub-core/kern/efi/efi.c (grub_efi_modules_addr): Likewise.
* grub-core/kern/i386/coreboot/init.c: Add exception to
-Wsuggest-attribute=noreturn.
* grub-core/kern/ia64/dl.c: Add exception to -Wcast-align.
* grub-core/kern/ia64/dl_helper.c: Likewise.
* grub-core/kern/mips/dl.c: Likewise.
* grub-core/kern/sparc64/dl.c: Likewise.
* grub-core/lib/LzmaEnc.c: Add exception to -Wshadow.
* grub-core/lib/libgcrypt_wrap/cipher_wrap.h (memcpy): Likewise.
(memcmp): Likewise.
* grub-core/lib/pbkdf2.c: Add exception to -Wunreachable-code.
* grub-core/loader/ia64/efi/linux.c: Add exception to -Wcast-align.
* grub-core/loader/mips/linux.c: Likewise.
* grub-core/loader/multiboot_elfxx.c: Likewise.
* grub-core/script/parser.y: Add exception to -Wunreachable-code.
* grub-core/video/sm712.c: Add exception to -Wcast-align.
* util/import_gcry.py: Add -Wno-cast-align to modules checked by hand.
* grub-core/font/font.c (grub_font_loader_init): Add explicit cast and
fixme.
* grub-core/fs/iso9660.c (grub_iso9660_iterate_dir): Likewise.
* grub-core/kern/i386/multiboot_mmap.c (grub_machine_mmap_init):
Fix prototype.
2012-02-10 16:48:48 +01:00
Vladimir 'phcoder' Serbinenko
9c4b5c13e6
Improve gettext support. Stylistic fixes and error handling fixes while
...
on it.
2012-02-08 19:26:01 +01:00
Vladimir 'phcoder' Serbinenko
49a45021c1
* grub-core/lib/LzmaEnc.c (LzmaEnc_CodeOneBlock): Remove set but not
...
used variable.
* grub-core/kern/ia64/dl_helper.c (grub_ia64_dl_get_tramp_got_size):
Likewise.
2011-11-08 19:46:41 +01:00
Vladimir 'phcoder' Serbinenko
ed64e9e279
Support trampoline jumps on powerpc.
...
* grub-core/kern/dl.c (grub_dl_load_segments) [__powerpc__]: Follow
__ia64__ path.
(grub_dl_load_segments): Set mod->sz.
(grub_dl_flush_cache): Flush whole space occupied by module, not just
segments.
* grub-core/kern/ia64/dl.c (nopm): Make const while on it.
(jump): Likewise.
* grub-core/kern/powerpc/dl.c (grub_arch_dl_get_tramp_got_size): New
function.
(trampoline): New struct.
(trampoline_template): New const.
(grub_arch_dl_relocate_symbols): Create trampolines on overflow.
* include/grub/dl.h (grub_dl): Add sz element.
[__powerpc__]: Follow __ia64__.
(GRUB_ARCH_DL_TRAMP_ALIGN): Define on ppc.
(GRUB_ARCH_DL_GOT_ALIGN): Likewise.
(GRUB_ARCH_DL_TRAMP_SIZE): Likewise.
(grub_arch_dl_get_tramp_got_size) [__powerpc__]: New proto.
2011-11-08 11:23:56 +01:00
Vladimir 'phcoder' Serbinenko
a97501d238
Make grub_prefix into module to fix the arbitrary limit and save
...
some space.
* grub-core/kern/emu/main.c (grub_prefix): Removed.
* grub-core/kern/i386/coreboot/startup.S (grub_prefix): Likewise.
* grub-core/kern/i386/efi/startup.S (grub_prefix): Likewise.
* grub-core/kern/i386/ieee1275/startup.S (grub_prefix): Likewise.
* grub-core/kern/i386/pc/startup.S (grub_prefix): Likewise.
* grub-core/kern/i386/qemu/startup.S (grub_prefix): Likewise.
* grub-core/kern/ia64/efi/startup.S (grub_prefix): Likewise.
* grub-core/kern/mips/startup.S (grub_prefix): Likewise.
* grub-core/kern/powerpc/ieee1275/startup.S (grub_prefix): Likewise.
* grub-core/kern/sparc64/ieee1275/crt0.S (grub_prefix): Likewise.
* grub-core/kern/x86_64/efi/startup.S (grub_prefix): Likewise.
* include/grub/ia64/efi/kernel.h: Removed.
* include/grub/kernel.h: New module type OBJ_TYPE_PREFIX.
(grub_prefix): Removed.
* include/grub/offsets.h (GRUB_KERNEL_I386_PC_PREFIX): Removed.
(GRUB_KERNEL_I386_PC_PREFIX_END): Likewise.
(GRUB_KERNEL_I386_QEMU_PREFIX): Likewise.
(GRUB_KERNEL_I386_QEMU_PREFIX_END): Likewise.
(GRUB_KERNEL_SPARC64_IEEE1275_PREFIX): Likewise.
(GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END): Likewise.
(GRUB_KERNEL_POWERPC_IEEE1275_PREFIX): Likewise.
(GRUB_KERNEL_POWERPC_IEEE1275_PREFIX_END): Likewise.
(GRUB_KERNEL_MIPS_LOONGSON_PREFIX): Likewise.
(GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END): Likewise.
(GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX): Likewise.
(GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END): Likewise.
(GRUB_KERNEL_MIPS_ARC_PREFIX): Likewise.
(GRUB_KERNEL_MIPS_ARC_PREFIX_END): Likewise.
(GRUB_KERNEL_I386_EFI_PREFIX): Likewise.
(GRUB_KERNEL_I386_EFI_PREFIX_END): Likewise.
(GRUB_KERNEL_IA64_EFI_PREFIX): Likewise.
(GRUB_KERNEL_IA64_EFI_PREFIX_END): Likewise.
(GRUB_KERNEL_X86_64_EFI_PREFIX): Likewise.
(GRUB_KERNEL_X86_64_EFI_PREFIX_END): Likewise.
(GRUB_KERNEL_I386_COREBOOT_PREFIX): Likewise.
(GRUB_KERNEL_I386_COREBOOT_PREFIX_END): Likewise.
(GRUB_KERNEL_I386_MULTIBOOT_PREFIX): Likewise.
(GRUB_KERNEL_I386_MULTIBOOT_PREFIX_END): Likewise.
(GRUB_KERNEL_I386_IEEE1275_PREFIX): Likewise.
(GRUB_KERNEL_I386_IEEE1275_PREFIX_END): Likewise.
(GRUB_KERNEL_MACHINE_PREFIX): Likewise.
(GRUB_KERNEL_MACHINE_PREFIX_END): Likewise.
* grub-core/kern/main.c (grub_set_prefix_and_root): Retrieve grub_prefix
from module.
* util/grub-mkimage.c (image_target_desc): Removed prefix and
prefix_end.
(image_targets): Likewise.
(generate_image): Put prefix as a module.
2011-10-18 15:21:51 +02:00
Vladimir 'phcoder' Serbinenko
574618a2e9
unify prefix handling across platforms
2011-07-02 14:09:36 +02:00
Vladimir 'phcoder' Serbinenko
543a8f6ef9
* grub-core/kern/ia64/dl_helper.c (grub_ia64_dl_get_tramp_got_size):
...
Fix potential usage of Elf32 instead of Elf64 when compiling on
32-bit architecture. Add endianness macros while on it.
2011-05-18 00:21:49 +02:00
Vladimir 'phcoder' Serbinenko
5a0baa09f2
Remove now useless LD script
2011-05-08 18:28:25 +02:00
Vladimir 'phcoder' Serbinenko
2679b7249b
Fix LTOFF relocation to functions (needed for trampolines)
2011-05-08 17:07:40 +02:00
Vladimir 'phcoder' Serbinenko
44748f71c0
Add explicit byt 0 to workaround a problem with assembler
2011-05-08 17:06:56 +02:00
Vladimir 'phcoder' Serbinenko
fa610088ba
Add missing time installation
2011-05-08 17:06:28 +02:00
Vladimir 'phcoder' Serbinenko
ad6e5cf25f
add missing file
2011-05-08 12:42:08 +02:00
Vladimir 'phcoder' Serbinenko
5452733f35
more or less functional ia64 grub-mkimage
2011-05-08 12:39:08 +02:00
phcoder
c18271ed00
Fix compilation errors
2011-01-03 02:28:14 +01:00
Vladimir 'phcoder' Serbinenko
7edf63fce6
merge ia64-emu into ia64
2011-01-02 23:55:50 +01:00
phcoder
f49157dfe5
Restructure module loading and many fixes. Now normal.mod loads successfully
2011-01-02 23:30:25 +01:00
phcoder
bbbf84350e
Working hello.mod with extcmd.mod
2011-01-02 19:20:28 +01:00
phcoder
73911575dd
support for registering functions from modules (not tested yet)
2011-01-02 14:58:57 +01:00
phcoder
daca6c5f45
ltoff relocation support
2011-01-02 14:39:23 +01:00
phcoder
f9c30af6d0
Succesfully loaded return-only module on ia64-emu
2011-01-02 14:09:58 +01:00
Vladimir 'phcoder' Serbinenko
6585de4c0c
merge mainline into ia64
2010-08-31 21:47:26 +02:00