Commit graph

9571 commits

Author SHA1 Message Date
Jordan Glover
5033080eb6 grub-mkconfig: Fix detecting .sig files as system images
grub-mkconfig detects detached RSA signatures for kernel images used for
signature checking as valid images and adds them to grub.cfg as separate
menu entries. This patch adds .sig extension to common blacklist.

Signed-off-by: Jordan Glover <Golden_Miller83@protonmail.ch>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2017-12-06 12:58:54 +01:00
Eric Snowberg
2dc163bf69 ieee1275: Fix segfault in grub-ofpathname
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2017-12-06 12:55:55 +01:00
Eric Snowberg
2a88564017 grub-install: Fix memory leak
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2017-11-28 20:33:06 +01:00
Eric Snowberg
3d8df86d82 ls: prevent double open
Prevent a double open.  This can cause problems with some ieee1275
devices, causing the system to hang.  The double open can occur
as follows:

grub_ls_list_files (char *dirname, int longlist, int all, int human)
       dev = grub_device_open (device_name);
       dev remains open while:
       grub_normal_print_device_info (device_name);
                dev = grub_device_open (name);

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2017-11-24 16:18:29 +01:00
David E. Box
446794de8d tsc: Change default tsc calibration method to pmtimer on EFI systems
On efi systems, make pmtimer based tsc calibration the default over the
pit. This prevents Grub from hanging on Intel SoC systems that power gate
the pit.

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2017-10-06 16:58:55 +02:00
Alexander Graf
92bfc33db9 efi: Free malloc regions on exit
When we exit grub, we don't free all the memory that we allocated earlier
for our heap region. This can cause problems with setups where you try
to descend the boot order using "exit" entries, such as PXE -> HD boot
scenarios.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2017-09-07 23:35:01 +02:00
Alexander Graf
0ba90a7f01 efi: Move grub_reboot() into kernel
The reboot function calls machine_fini() and then reboots the system.
Currently it lives in lib/ which means it gets compiled into the
reboot module which lives on the heap.

In a following patch, I want to free the heap on machine_fini()
though, so we would free the memory that the code is running in. That
obviously breaks with smarter UEFI implementations.

So this patch moves it into the core. That way we ensure that all
code running after machine_fini() in the UEFI case is running from
memory that got allocated (and gets deallocated) by the UEFI core.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2017-09-07 23:29:31 +02:00
Konrad Rzeszutek Wilk
b4d709b6ee Use grub-file to figure out whether multiboot2 should be used for Xen.gz
The multiboot2 is much more preferable than multiboot. Especiall
if booting under EFI where multiboot does not have the functionality
to pass ImageHandler.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2017-09-07 23:25:29 +02:00
Konrad Rzeszutek Wilk
a8e0f1adf7 Fix util/grub.d/20_linux_xen.in: Add xen_boot command support for aarch64
Commit d33045ce7f introduced
the support for this, but it does not work under x86 (as it stops
20_linux_xen from running).

The 20_linux_xen is run under a shell and any exits from within it:

(For example on x86):
+ /usr/bin/grub2-file --is-arm64-efi /boot/xen-4.9.0.gz
[root@tst063 grub]# echo $?
1

will result in 20_linux_xen exiting without continuing
and also causing grub2-mkconfig to stop processing.

As in:

 [root@tst063 grub]# ./grub-mkconfig | tail
 Generating grub configuration file ...
 Found linux image: /boot/vmlinuz-4.13.0-0.rc5.git1.1.fc27.x86_64
 Found initrd image: /boot/initramfs-4.13.0-0.rc5.git1.1.fc27.x86_64.img
 Found linux image: /boot/vmlinuz-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2
 Found initrd image: /boot/initramfs-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2.img
 		echo	'Loading Linux 0-rescue-ec082ee24aea41b9b16aca52a6d10cc2 ...'
 		linux	/vmlinuz-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2 root=/dev/mapper/fedora_tst063-root ro single
 		echo	'Loading initial ramdisk ...'
 		initrd	/initramfs-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2.img
 	}
 }

 ### END /usr/local/etc/grub.d/10_linux ###

 ### BEGIN /usr/local/etc/grub.d/20_linux_xen ###

 root@tst063 grub]#

And no more.

This patch wraps the invocation of grub-file to be a in subshell
and to process the return value in a conditional. That fixes
the issue.

RH-BZ 1486002: grub2-mkconfig does not work if xen.gz is installed.

CC: Fu Wei <fu.wei@linaro.org>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2017-09-07 23:25:29 +02:00
Vladimir Serbinenko
78d2b81bd1 Fix compilation for x86_64-efi. 2017-09-07 13:55:22 +02:00
Vladimir Serbinenko
1b18d6b0d3 Add a file missing in multiboot2 commit. 2017-09-05 23:13:55 +02:00
Vladimir Serbinenko
95acd4cbda gzio: fix unaligned access 2017-08-30 21:31:28 +02:00
Vladimir Serbinenko
4f31bfe1d3 grub-fs-tester: Fix bashism 2017-08-30 21:31:26 +02:00
Vladimir Serbinenko
061258a05e Regenerate checksum.h with newer unifont.
Old link is broken. New unifont is
http://ftp.de.debian.org/debian/pool/main/u/unifont/xfonts-unifont_9.0.06-2_all.deb
2017-08-30 17:12:04 +02:00
Vladimir Serbinenko
32099228e6 printf_unit_test: Disable Wformat-truncation on GCC >= 7
We intentionally pass NULL as argument to format, hence disable the warning.
2017-08-30 16:59:25 +02:00
Vladimir Serbinenko
ec763ed00a qemu, coreboot, multiboot: Change linking address to 0x9000.
It's common for distros to use a defective ld which links at 0x9000. Instead
of fighting it, just move link target to 0x9000.
2017-08-30 16:29:59 +02:00
Stefan Fritsch
b18ce97c67 Implement checksum verification for gunzip
This implements the crc32 check for the gzip format. Support for zlib's
adler checksum is not included, yet.
2017-08-30 16:07:54 +02:00
Vladimir Serbinenko
c42acc23ff xfs: Don't attempt to iterate over empty directory.
Reported by: Tuomas Tynkkynen
2017-08-30 15:56:19 +02:00
Patrick Steinhardt
e75cf4a58b unix exec: avoid atexit handlers when child exits
The `grub_util_exec_redirect_all` helper function can be used to
spawn an executable and redirect its output to some files. After calling
`fork()`, the parent will wait for the child to terminate with
`waitpid()` while the child prepares its file descriptors, environment
and finally calls `execvp()`. If something in the children's setup
fails, it will stop by calling `exit(127)`.

Calling `exit()` will cause any function registered via `atexit()` to be
executed, which is usually the wrong thing to do in a child. And
actually, one can easily observe faulty behaviour on musl-based systems
without modprobe(8) installed: executing `grub-install --help` will call
`grub_util_exec_redirect_all` with "modprobe", which obviously fails if
modprobe(8) is not installed. Due to the child now exiting and invoking
the `atexit()` handlers, it will clean up some data structures of the
parent and cause it to be deadlocked in the `waitpid()` syscall.

The issue can easily be fixed by calling `_exit(127)` instead, which is
especially designed to be called when the atexit-handlers should not be
executed.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2017-08-30 15:20:13 +02:00
Vladimir Serbinenko
3d86efda00 arc: Do not create spurious variable grub_arc_memory_type_t. 2017-08-30 15:18:24 +02:00
Xuan Guo
5435aaac3c Set have_exec to y on cygwin so we have grub_mkrescue. 2017-08-14 16:27:53 +02:00
Vladimir Serbinenko
6ccb2d54bc enforcing fixup 2017-08-14 16:27:10 +02:00
Vladimir Serbinenko
4bfd26623f multiboot fixup 2017-08-14 16:24:05 +02:00
Vladimir Serbinenko
6cc79ec10c linux fixup 2017-08-14 16:23:52 +02:00
Vladimir Serbinenko
c36c2a8640 yylex: Explicilty cast fprintf to void.
It's needed to avoid warning on recent GCC.
2017-08-14 14:11:43 +02:00
Vladimir Serbinenko
3732816bc0 genmoddep: Check that no modules provide the same symbol.
The semantics of 2 modules providing the same symbol are undefined. So
ensure that it doesn't happen.
2017-08-14 14:10:48 +02:00
Vladimir Serbinenko
26e5aea941 Fix symbols appearing in several modules in linux*.
If same symbol is provided by 2 modules its semantics are undefined.
Avoid this by depending rather than double-including files.
2017-08-14 14:09:30 +02:00
Vladimir Serbinenko
21e4a6fa03 multiboot: disentangle multiboot and multiboot2.
Previously we had multiboot and multiboot2 declaring the same symbols.
This can potentially lead to aliasing and strange behaviours when e.g.
module instead of module2 is used with multiboot2.

Bug: #51137
2017-08-14 14:08:54 +02:00
Vladimir Serbinenko
6662372053 hdparm: Depend on hexdump rather than having a second copy of hexdump. 2017-08-14 12:48:58 +02:00
Vladimir Serbinenko
7108c0c86e grub.texi: Fix typo
Reported by: 	Ori Avtalion <saltyhorse>
2017-08-14 11:36:50 +02:00
Pete Batard
1deebd85ef io: add a GRUB_GZ prefix to gzio specific defines
* This is done to avoid a conflict with a PACKED define in the EDK2
2017-08-07 19:30:26 +02:00
Pete Batard
bdd89d239c core: use GRUB_TERM_ definitions when handling term characters
* Also use hex value for GRUB_TERM_ESC as '\e' is not in the C standard and is not understood by some compilers
2017-08-07 19:28:22 +02:00
Leif Lindholm
f826330683 efi: change heap allocation type to GRUB_EFI_LOADER_CODE
With upcoming changes to EDK2, allocations of type EFI_LOADER_DATA may
not return regions with execute ability. Since modules are loaded onto
the heap, change the heap allocation type to GRUB_EFI_LOADER_CODE in
order to permit execution on systems with this feature enabled.

Closes: 50420

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
2017-08-07 19:03:34 +02:00
Leif Lindholm
91212e0aa0 arm64 linux loader: improve type portability
In preparation for turning this into a common loader for 32-bit and 64-bit
platforms, ensure the code will compile cleanly for either.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
2017-08-07 18:54:56 +02:00
Leif Lindholm
c5841ba7f0 efi: Add GRUB_PE32_MAGIC definition
Add a generic GRUB_PE32_MAGIC definition for the PE 'MZ' tag and delete
the existing one in arm64/linux.h.

Update arm64 Linux loader to use this new definition.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
2017-08-07 18:52:09 +02:00
Leif Lindholm
8c9465fac9 efi: move fdt helper library
There is nothing ARM64 (or even ARM) specific about the efi fdt helper
library, which is used for locating or overriding a firmware-provided
devicetree in a UEFI system - so move it to loader/efi for reuse.

Move the fdtload.h include file to grub/efi and update path to
efi/fdtload.h in source code referring to it.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
2017-08-07 18:50:44 +02:00
Vladimir Serbinenko
4bc909bf89 Remove grub_efi_allocate_pages.
grub_efi_allocate_pages Essentially does 2 unrelated things:
* Allocate at fixed address.
* Allocate at any address.

To switch between 2 different functions it uses address == 0 as magic
value which is wrong as 0 is a perfectly valid fixed adress to allocate at.
2017-08-07 18:33:29 +02:00
Leif Lindholm
dd5fde2df8 efi: refactor grub_efi_allocate_pages
Expose a new function, grub_efi_allocate_pages_real(), making it possible
to specify allocation type and memory type as supported by the UEFI
AllocatePages boot service.

Make grub_efi_allocate_pages() a consumer of the new function,
maintaining its old functionality.

Also delete some left-around #if 1/#else blocks in the affected
functions.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
2017-08-07 18:23:39 +02:00
Vladimir Serbinenko
e66dc5d71e Fail if xorriso failed.
If xorriso failed most likely we didn't generate a meaningful image.
2017-08-07 18:08:39 +02:00
Vladimir Serbinenko
9e962fd3c4 mkrescue: Check xorriso presence before doing anything else.
mkrescue can't do anything useful without xorriso, so abort early if it's
not available.
2017-08-07 18:05:17 +02:00
Pali Rohár
435fa75e01 * grub-core/fs/udf.c: Add support for UUID
Use same algorithm as in libblkid from util-linux v2.30.

1. Take first 16 bytes from UTF-8 encoded string of VolumeSetIdentifier
2. If all bytes are hexadecimal digits, convert to lowercase and use as UUID
3. If first 8 bytes are not all hexadecimal digits, convert those 8 bytes
   to their hexadecimal representation, resulting in 16 bytes for UUID
4. Otherwise, compose UUID from two parts:
   1. part: converted first 8 bytes (which are hexadecimal digits) to lowercase
   2. part: encoded following 4 bytes to their hexadecimal representation (16 bytes)

So UUID would always have 16 hexadecimal digits in lowercase variant.

According to UDF specification, first 16 Unicode characters of
VolumeSetIdentifier should be unique value and first 8 should be
hexadecimal characters.

In most cases all 16 characters are hexadecimal, but e.g. MS Windows
format.exe set only first 8 as hexadecimal and remaining as fixed
(non-unique) which violates specification.
2017-08-07 17:51:50 +02:00
Pali Rohár
76188809d5 udf: Fix reading label, lvd.ident is dstring
UDF dstring has stored length in the last byte of buffer. Therefore last
byte is not part of recorded characters. And empty string in dstring is
encoded as empty buffer, including first byte (compression id).
2017-08-07 17:51:50 +02:00
Pete Batard
fa42786264 zfs: remove size_t typedef and use grub_size_t instead
* Prevents some toolchains from issuing a warning on size_t redef.
2017-08-07 16:21:15 +02:00
Rob Clark
e8ab5a1a9e Fix a segfault in lsefi
when protocols_per_handle returns error, we can't use the pointers we
passed to it, and that includes trusting num_protocols.

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2017-08-03 20:03:09 +02:00
Vladimir Serbinenko
68d54b55f4 fdt: silence clang warning. 2017-07-10 01:34:22 +00:00
Vladimir Serbinenko
cb8b7e4e36 arm-efi: Fix compilation 2017-07-09 21:49:55 +00:00
AppChecker
a0fe0c26aa crypto: Fix use after free.
Reported by: AppChecker
Transformed to patch by: Satish Govindarajan
2017-07-09 21:57:35 +02:00
Vladimir Serbinenko
284afab081 ehci: Fix compilation on i386 2017-07-09 21:31:19 +02:00
phcoder
d8901e3ba1 cache: Fix compilation for ppc, sparc and arm64 2017-07-09 20:59:15 +02:00
phcoder
edb37fb30b ehci: Fix compilation for amd64 2017-07-09 20:58:31 +02:00