Commit Graph

2090 Commits

Author SHA1 Message Date
Nicholas Vinson 0c0bcffc23 grub-probe: Add PARTUUID detection support
Add PARTUUID detection support grub-probe for MBR and GPT partition schemes.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-04-23 13:24:29 +02:00
Nicholas Vinson a16f4a822f disk: Update grub_gpt_partentry
Rename grub_gpt_part_type to grub_gpt_part_guid and update grub_gpt_partentry
to use this type for both the partition type GUID string and the partition GUID
string entries.  This change ensures that the two GUID fields are handled more
consistently and helps to simplify the changes needed to add Linux partition
GUID support.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-04-23 13:21:45 +02:00
Nicholas Vinson c2b86ae1fc grub-probe: Centralize GUID prints
Define print_gpt_guid(), so there is a central function for printing
GUID strings.  This change is a precursor for later patches which rely
on this logic.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-04-23 13:21:22 +02:00
Olaf Hering 3d8439da8c grub-install: Locale depends on nls
With --disable-nls no locales exist.

Avoid runtime error by moving code that copies locales into its own
function. Return early in case nls was disabled. That way the compiler
will throw away unreachable code, no need to put preprocessor
conditionals everywhere to avoid warnings about unused code.

Fix memleak by freeing srcf and dstf.
Convert tabs to spaces in moved code.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-04-23 13:13:11 +02:00
Matthew S. Turnbull a698240df0 grub-mkconfig/10_linux: Support multiple early initrd images
Add support for multiple, shared, early initrd images. These early
images will be loaded in the order declared, and all will be loaded
before the initrd image.

While many classes of data can be provided by early images, the
immediate use case would be for distributions to provide CPU
microcode to mitigate the Meltdown and Spectre vulnerabilities.

There are two environment variables provided for declaring the early
images.

* GRUB_EARLY_INITRD_LINUX_STOCK is for the distribution declare
  images that are provided by the distribution or installed packages.
  If undeclared, this will default to a set of common microcode image
  names.

* GRUB_EARLY_INITRD_LINUX_CUSTOM is for user created images. User
  images will be loaded after the stock images.

These separate configurations allow the distribution and user to
declare different image sets without clobbering each other.

This also makes a minor update to ensure that UUID partition labels
stay disabled when no initrd image is found, even if early images are
present.

This is a continuation of a previous patch published by Christian
Hesse in 2016:
http://lists.gnu.org/archive/html/grub-devel/2016-02/msg00025.html

Down stream Gentoo bug:
https://bugs.gentoo.org/645088

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Signed-off-by: Matthew S. Turnbull <sparky@bluefang-logic.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-03-14 13:23:27 +01:00
Eric Snowberg 28b0d19061 mkimage: fix build regression in grub_mkimage_load_image
The grub_mkimage_load_image function (commit 7542af6, mkimage: refactor a bunch
of section data into a struct.) introduces a build regression on SPARC:

  cc1: warnings being treated as errors
  In file included from util/grub-mkimage32.c:23:
  util/grub-mkimagexx.c: In function 'grub_mkimage_load_image32':
  util/grub-mkimagexx.c:1968: error: missing initializer
  util/grub-mkimagexx.c:1968: error: (near initialization for 'smd.sections')
  make[2]: *** [util/grub_mkimage-grub-mkimage32.o] Error 1

Initialize the entire section_metadata structure.

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-03-07 22:05:48 +01:00
dann frazier d73badfd0a Revert "Keep the native terminal active when enabling gfxterm"
This can cause an issue where GRUB is trying to display both a text and
graphical menu on the display at the same time, resulting in a flickering
effect when e.g. scrolling quickly through a menu (LP: #1752767).

Revert for now while we look for a better solution for the original issue.

This reverts commit 52ef7b23f5.

Signed-off-by: dann frazier <dann.frazier@canonical.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-03-05 15:26:42 +01:00
Peter Jones ebc825b549 mkimage: avoid copying relocations for sections that won't be copied.
Some versions of gcc include a plugin called "annobin", and in some
build systems this is enabled by default.  This plugin creates special
ELF note sections to track which ABI-breaking features are used by a
binary, as well as a series of relocations to annotate where.

If grub is compiled with this feature, then when grub-mkimage translates
the binary to another file format which does not strongly associate
relocation data with sections (i.e. when platform is *-efi), these
relocations appear to be against the .text section rather than the
original note section.  When the binary is loaded by the PE runtime
loader, hilarity ensues.

This issue is not necessarily limited to the annobin, but could arise
any time there are relocations in sections that are not represented in
grub-mkimage's output.

This patch seeks to avoid this issue by only including relocations that
refer to sections which will be included in the final binary.

As an aside, this should also obviate the need to avoid -funwind-tables,
-fasynchronous-unwind-tables, and any sections similar to .eh_frame in
the future.  I've tested it on x86-64-efi with the following gcc command
line options (as recorded by -grecord-gcc-flags), but I still need to
test the result on some other platforms that have been problematic in
the past (especially ARM Aarch64) before I feel comfortable making
changes to the configure.ac bits:

GNU C11 7.2.1 20180116 (Red Hat 7.2.1-7) -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow -msoft-float -mno-stack-arg-probe -mcmodel=large -mno-red-zone -m64 -mtune=generic -march=x86-64 -g3 -Os -freg-struct-return -fno-stack-protector -ffreestanding -funwind-tables -fasynchronous-unwind-tables -fno-strict-aliasing -fstack-clash-protection -fno-ident -fplugin=annobin

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-03-05 14:08:09 +01:00
Peter Jones 7542af695f mkimage: refactor a bunch of section data into a struct.
This basically moves a bunch of the section information we pass around a
lot into a struct, and passes a pointer to a single one of those
instead.

This shouldn't change the binary file output or the "grub-mkimage -v"
output in any way.

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-03-05 14:05:35 +01:00
Peter Jones e30de94926 mkimage: make locate_sections() set up vaddresses as well.
This puts both kinds of address initialization at the same place, and also lets
us iterate through the section list one time fewer.

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-03-05 13:44:55 +01:00
Peter Jones 594ac31571 mkimage: rename a couple of things to be less confusing later.
This renames some things:

- the "strtab" and "strtab_section" in relocate_symbols are changed to "symtab"
  instead, so as to be less confusing when "strtab" is moved to a struct in a
  later patch.

- The places where we pass section_vaddresses to functions are changed to also
  be called section_vaddresses"inside those functions, so I get less confused
  when I put addresses and vaddresses in a struct in a later patch.

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-03-05 13:44:55 +01:00
Peter Jones 352868d123 mkimage: make it easier to run syntax checkers on grub-mkimagexx.c
This makes it so you can treat grub-mkimagexx.c as a file you can build
directly, so syntax checkers like vim's "syntastic" plugin, which uses
"gcc -x c -fsyntax-only" to build it, will work.

One still has to do whatever setup is required to make it pick the right
include dirs, which -W options we use, etc., but this makes it so you
can do the checking on the file you're editing, rather than on a
different file.

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-03-05 13:44:55 +01:00
H.J. Lu 842c390469 x86-64: Treat R_X86_64_PLT32 as R_X86_64_PC32
Starting from binutils commit bd7ab16b4537788ad53521c45469a1bdae84ad4a:

https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=bd7ab16b4537788ad53521c45469a1bdae84ad4a

x86-64 assembler generates R_X86_64_PLT32, instead of R_X86_64_PC32, for
32-bit PC-relative branches.  Grub2 should treat R_X86_64_PLT32 as
R_X86_64_PC32.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-02-23 22:25:30 +01:00
Steve McIntyre 6400613ad0 Make grub-install check for errors from efibootmgr
Code is currently ignoring errors from efibootmgr, giving users
clearly bogus output like:

        Setting up grub-efi-amd64 (2.02~beta3-4) ...
        Installing for x86_64-efi platform.
        Could not delete variable: No space left on device
        Could not prepare Boot variable: No space left on device
        Installation finished. No error reported.

and then potentially unbootable systems. If efibootmgr fails, grub-install
should know that and report it!

We've been using similar patch in Debian now for some time, with no ill effects.

Signed-off-by: Steve McIntyre <93sam@debian.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-02-14 18:02:01 +01:00
Eric Snowberg 69e0a67bfb sparc64: Add blocklist GPT support for SPARC
Add block-list GPT support for SPARC.  The OBP "load" and "boot" methods
are partition aware and neither command can see the partition table. Also
neither command can address the entire physical disk. When the install
happens, grub generates the block-list entries based on the beginning of the
physical disk, not the beginning of the partition. This patch fixes the
block-list entries so they match what OBP expects during boot for a GPT disk.

T5 and above now supports GPT as well as VTOC.

This patch has been tested on T5-2 and newer SPARC systems.

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-02-14 17:42:56 +01:00
dann frazier 52ef7b23f5 Keep the native terminal active when enabling gfxterm
grub-mkconfig will set GRUB_TERMINAL_OUTPUT to "gfxterm" unless the user
has overridden it. On EFI systems, this will stop output from going to the
default "console" terminal. When the EFI fw console is configured to output to
both serial and video, this will cause GRUB to only display on video - while
continuing to accept input from both video and serial.

Instead of switching from "console" to "gfxterm", let's output to both.

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-01-29 12:51:03 +01:00
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
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 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
Fu Wei d33045ce7f util/grub.d/20_linux_xen.in: Add xen_boot command support for aarch64
This patch adds the support of xen_boot command for aarch64:
    xen_hypervisor
    xen_module
These two commands are only for aarch64, since it has its own protocol and
commands to boot xen hypervisor and Dom0, but not multiboot.

For other architectures, they are still using multiboot and module
commands.

Signed-off-by: Fu Wei <fu.wei@linaro.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2017-05-18 22:30:35 +02:00
Vladimir Serbinenko 3edabad8fe arm_coreboot: Support grub-mkstandalone. 2017-05-08 21:59:48 +02:00
Vladimir Serbinenko fcbb723d4b Add support for device-tree-based drivers. 2017-05-08 21:19:59 +02:00
Vladimir Serbinenko 24e37a8852 arm-coreboot: Start new port. 2017-05-08 20:53:28 +02:00
Vladimir Serbinenko a35ac85430 mkimage: Pass layout to mkimage_generate_elfXX rather than some fields.
This allows easier extension of this function without having too long of
arguments list.
2017-05-08 17:32:15 +02:00
Andrei Borzenkov 4bd4a88725 i386, x86_64, ppc: fix switch fallthrough cases with GCC7
In util/getroot and efidisk slightly modify exitsing comment to mostly
retain it but still make GCC7 compliant with respect to fall through
annotation.

In grub-core/lib/xzembed/xz_dec_lzma2.c it adds same comments as
upstream.

In grub-core/tests/setjmp_tets.c declare functions as "noreturn" to
suppress GCC7 warning.

In grub-core/gnulib/regexec.c use new __attribute__, because existing
annotation is not recognized by GCC7 parser (which requires that comment
immediately precedes case statement).

Otherwise add FALLTHROUGH comment.

Closes: 50598
2017-04-04 19:23:55 +03:00
Vladimir Serbinenko 512bb31cbc Whitelist sparc64-ieee1275 as having no video modules.
ieee1275_fb is not built on sparc64 due to virtual address issues.
2017-02-22 09:55:51 +01:00
Vladimir Serbinenko 42e24b6006 Fix thumb compilation with clang.
According to EABI only STT_FUNC has convention of lowest bit indicating
execution mode. R_THM_{JUMP,CALL}* relocations are assumed to be pointing
to thumb mode unless they use STT_FUNC.
2017-02-02 00:59:49 +01:00
Vladimir Serbinenko 34fe0b5901 arm64: Add support for GOT and PCREL32 relocations. 2017-02-01 21:46:19 +01:00
Vladimir Serbinenko 377c121170 mkimage: Fix memory leak. 2017-02-01 21:21:17 +01:00
Vladimir Serbinenko 43b444e593 arm/arm64: Fix improper use of start address.
It was used instead of loading address of current section or of entire buffer.
2017-02-01 20:12:07 +01:00
Vladimir Serbinenko f14c77f501 grub-mkfont: Remove leftover debug statement. 2017-01-31 22:32:21 +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 255b9e0bea grub-module-verifier: Add mips to all_video whitelist.
On MIPS video is compiled-in. So all_video is empty. Whitelist it.
2017-01-30 19:52:58 +01:00
Vladimir Serbinenko 6371e9c104 grub-module-verifier: Ignore all_video emptiness on xen.
It's intentional that it's empty when no video modules
are available.
2017-01-30 00:13:41 +00:00
Dirk Mueller 0d663b50b9 grub-mknetdir: Add support for ARM64 EFI 2016-11-14 19:27:13 +03:00
Robert Marshall 3c3e96d044 Failed config now returns exit code (#1252311)
Grub would notify the user if the new config was invalid, however, it
did not exit properly with exit code 1. Added the proper exit code.

Resolves: rhbz#1252311
2016-03-11 17:24:56 +01:00
Andrei Borzenkov 9545a8fd04 20_linux_xen: fix test for GRUB_DEVICE
Same fix as in 082bc9f.
2016-03-06 08:54:19 +03:00
Mike Gilbert 082bc9f77b 10_linux: Fix grouping of tests for GRUB_DEVICE
Commit 7290bb562 causes GRUB_DISABLE_LINUX_UUID to be ignored due to
mixing of || and && operators. Add some parens to help with that.
2016-03-06 08:51:07 +03:00
Vladimir Serbinenko 86ef66d977 arm-uboot: Make self-relocatable to allow loading at any address 2016-02-27 13:40:52 +01:00
Vladimir Serbinenko 5bcb7d394c Allow _start == 0 with relocatable images 2016-02-27 13:35:36 +01:00
Vladimir Serbinenko df21fff504 Provide __bss_start and _end symbols in grub-mkimage.
For this ensure that all bss sections are merged.

We need this to correctly prelink non-PE relocatable images.
2016-02-27 13:35:36 +01:00
Vladimir Serbinenko 73a9c742fe Encapsulate image layout into a separate structure.
Currently we pass around a lot of pointer. Instead put all relevant data
into one structure.
2016-02-27 13:35:36 +01:00
Vladimir Serbinenko dd3969e7ec mkimagexx: Split PE and generic part for relocations.
As a preparation for U-Boot relocations, split emitting PE-relocations
from parsing source ELF-relocations.
2016-02-27 13:35:36 +01:00
Vladimir Serbinenko 36212460d3 mkimage.c: Split into separate files.
util/grub-mkimagexx.c is included in a special way into mkimage.c.
Interoperation between defines makes this very tricky. Instead
just have a clean interface and compile util/grub-mkimage*.c separately
from mkimage.c
2016-02-27 13:35:36 +01:00
Vladimir Serbinenko 6e1ace590a Change -v to -V for version of shell utils. 2016-02-12 15:46:05 +01:00
Vladimir Serbinenko 7c35f65aac xnu: Add new kernel path to autoconfig. 2016-02-12 15:42:26 +01:00
Andrei Borzenkov 67dba97e45 support modules without symbol table
all_video module does not have any code or data and exists solely for
.moddeps section to pull in dependencies. This makes all symbols unneeded.

While in current binutils (last released version as of this commit is 2.26)
``strip --strip-unneeded'' unintentionally adds section symbols for each
existing section, this behavior was considered a bug and changed in commit
14f2c699ddca1e2f706342dffc59a6c7e23e844c to completely strip symbol table
in this case.

Older binutils (verified with 2.17) and some other toolchains (at least
elftoolchain r3223M), both used in FreeBSD, remove symbol table in all_video
as well.

Relax run-time check and do not return error for modules without symbol table.
Add additional checks to module verifier to make sure such modules

a) have non-empty .moddeps section. Without either externally visible symbols
or .moddeps modules are completely useless and should not be built.

b) do not have any relocations.

Closes: 46986

v2: add run-time check for empty symbol table if relocations are present as
    suggested by Vladimir.
2016-02-03 20:34:55 +03:00
Andrei Borzenkov 7290bb5623 10_linux: avoid multi-device root= kernel argument
If root filesystem is multidev btrfs, do not attempt to pass all devices as
kernel root= argument. This results in splitting command line in GRUB due to
embedded newline and even if we managed to quote it, kernel does not know how
to interpret it anyway. Multidev btrfs requires user space device scanning,
so passing single device would not work too.

This still respects user settings GRUB_DISABLE_LINUX_UUID. Not sure what we
should do in this case.

Closes: 45709
2016-02-01 20:13:48 +03:00
Vladimir Serbinenko ff84a9b868 Error out if mtools invocation fails. 2016-01-22 19:28:08 +01:00
Vladimir Serbinenko 605eecc985 arm64: Add support for relocations needed for linaro gcc 2016-01-22 19:09:37 +01:00
Andrei Borzenkov f826d914e2 grub-probe: fix memory leak
Found by: Coverity scan.
CID: 73783
2016-01-16 21:47:28 +03:00
Andrei Borzenkov 66768b99f1 grub-install: include ehci in list of native modules
This matches behavior of "nativedisk" command.

Reported and tested by Smith Henry <sh37092@gmail.com>
2016-01-10 16:08:06 +03:00
Andrei Borzenkov 962b69d950 grub-mkimage: remove redundant NULL check
Found by: Coverity scan.
CID: 73737
2016-01-10 11:51:34 +03:00
Andrei Borzenkov 5a5a3c6963 setup: fix NULL pointer dereference
Check return value of grub_guess_root_devices

Found by: Coverity scan.
CID: 73638, 73751
2016-01-09 21:25:22 +03:00
Andrei Borzenkov 670c43af27 mkimage: fix unintended sign extension
Found by: Coverity scan.
CID: 73691, 73717
2016-01-09 21:05:44 +03:00
Andrei Borzenkov dc27d254f2 util/getroot: delete dead code
is_part cannot be non-zero at this point.

Found by: Coveruty scan.
CID: 73838
2016-01-09 20:54:54 +03:00
Andrei Borzenkov 725548a285 grub-mklayout: check subscript bounds
Found by: Coverity scan.
CID: 73686
2016-01-09 14:13:36 +03:00
Andrei Borzenkov d5cc487d39 grub-probe: fix memory leak
Found by: Coverity scan.
CID: 73783
2016-01-09 13:55:28 +03:00
Andrei Borzenkov 0e075ac385 util/setup: fix grub_util_path_list leak
Add helper grub_util_free_path_list and use it where appropriate.

Found by: Coverity scan.
CID: 73727
2016-01-09 13:55:18 +03:00
Andrei Borzenkov 57e7f1b775 setup: fix memory leak
Found by: Coverity scan.
CID: 73680, 73715
2016-01-09 13:10:10 +03:00
Andrei Borzenkov efc04d65c7 grub-module-verifier: fix unintended sign extension
Found by: Coverity scan.
CID: 156533, 156532
2016-01-09 11:36:42 +03:00
Vladimir Serbinenko 3f430a0126 Move file loading functions to grub-emu.
So that we can use it in grub-emu as well as utils.
2016-01-05 21:10:27 +01:00
Vladimir Serbinenko dcc499aaf0 module-verifier: allow limited-range relocations on sparc64.
clang as incomplete mcmodel=large support. As we don't currently need full
mcmodel=large support for sparc64, relax those checks.
2015-12-31 18:30:39 +01:00
Vladimir Serbinenko e1b2b9bf1d module-verifier: Check range-limited relative relocations.
Check that they point to the same module, so will end up in the same
chunk of memory.
2015-12-31 15:29:28 +01:00
Vladimir Serbinenko a7cf8b1e23 Verify modules on build-time rather than failing in runtime. 2015-12-31 13:09:15 +01:00
Andrey Borzenkov 2333a83baa 30_os-prober: derive --class from os-prober generated label
Currently only Windows gets distinguished icons, everything else is displayed
using the same generic one. Add additional --class based on os-prober returned
label, which usually is expected to match primary distribution name.

Also use it for Windows as well - chainloader prober may actually return
different strings (Windows, MS-DOS, Windows9xME).
2015-12-30 22:30:16 +03:00
Vladimir Serbinenko dbab354157 grub-mkrescue: Delete temporary file
Reported by: Thomas Schmitt
2015-12-29 17:48:34 +01:00
Vladimir Serbinenko 4111882828 grub-mount: Fix oath parsing.
Brackets detection was copied from somewhere else and makes no sense in case
of grub-mount and prevents user from accessing and files with ) in them.
2015-12-29 17:43:05 +01:00
Andrei Borzenkov 1018e91dce mkimage: zero fill alignment space
This did not cause real problem but is good for reproducible builds. I hit
it with recent bootinfoscript that displays embedded config; I was puzzled
by random garbage at the end.

Prezero memory buffer used to assemble core.img. This makes individual
memset redundant. Also ensure buffer is filled with zeroes in several other
places.

Also remove redundant zeroing code where we fill in the whole memory block
anyway.
2015-11-06 21:33:28 +03:00
Eric Snowberg 8cb4c4edbe sparc64 - use correct drive name within grub_util_sparc_setup
Incorrect drive name was being passed into grub_util_sparc_setup,
causing the grub-install to fail.

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
2015-10-07 19:51:57 +03:00
Vladimir Serbinenko a2721778e5 grub-install: Use a+ in fopen rather than r+.
r+ does not create a file if none exists.
2015-07-27 12:42:47 +02:00
Andrei Borzenkov 4358e0c81e grub-probe: fix memory leak in probe (ofpath)
Found by: Coverity scan.
CID: 73772
2015-06-19 20:47:44 +03:00
Andrei Borzenkov 03f1f24e37 grub-probe: restructure code to make static analysis easier
Current code in probe() could not be verified to not contain memory leaks.
Restructure code and ensure grub_device_close is always called at the end of
loop.

Calms down Coverity scan.
CID: 73739
2015-06-19 20:47:43 +03:00
Andrei Borzenkov 5082ea6184 remove extra newlines in grub_util_* strings
grub_util_{info,warn,error} already add trailing newlines, so remove
them from format strings. Also trailing full stops are already added.
2015-05-13 09:47:17 +03:00
Vladimir Serbinenko 2dcf260d89 util/grub-mkrescue: Fix compilation 2015-05-07 19:45:06 +02:00
Vladimir Serbinenko 9916ed6f82 grub-install-common: Increase buf size to 8192 as modinfo.sh is bigger. 2015-05-07 17:09:58 +02:00
Vladimir Serbinenko 5fd1cb980a grub-mkrescue: Recognize -output as an alias of --output.
This helps us to be in line with xorriso -as mkisofs.

Suggested by: Thomas Schmitt
2015-05-07 16:34:34 +02:00
Andrei Borzenkov 104dff36ea grub-mkconfig: use $pkgdatadir in scripts
Otherwise scripts will source wrong grub-mkconfig_lib.
2015-04-29 19:18:54 +03:00
Vladimir Serbinenko 70b002de55 Remove -V in grub-mkrescue.c
It clashhes with -V which is alias to -volid.
2015-04-24 17:52:30 +02:00
Andrei Borzenkov 12bf557039 do not emit cryptomount without crypto UUID 2015-03-28 22:13:35 +03:00
Daniel Kahn Gillmor 85a7be2414 util/mkimage: Use stable timestamp when generating binaries. 2015-03-27 13:26:48 +01:00
Vladimir Serbinenko cf47a2fba5 grub-mkrescue: pass all unrecognized options unchanged to xorriso. 2015-03-20 12:55:27 +01:00
Vladimir Serbinenko 27d1a67f8a Fix canonicalize_file_name clash.
canonicalize_file_name clashed with gnulib function. Additionally
it was declared in 2 places: emu/misc.h and util/misc.h. Added
grub_ prefix and removed second declaration.
2015-03-04 01:00:19 +01:00
Andrei Borzenkov 018f79da6f grub-probe: free temporary variable 2015-02-28 20:19:57 +03:00
Vladimir Serbinenko afd6b6bbae grub-probe: Mark a "[default=]" for translation. 2015-02-28 16:22:46 +01:00
Jiri Slaby 32cd33bd19 util: mkimage, fix gcc5 build failure
gcc5 reports:
../util/mkimage.c: In function 'grub_install_get_image_target':
../util/mkimage.c:954:5: error: loop exit may only be reached after undefined behavior [-Werror=aggressive-loop-optimizations]
     && j < ARRAY_SIZE (image_targets[i].names); j++)
     ^
../util/mkimage.c:953:39: note: possible undefined statement is here
      for (j = 0; image_targets[i].names[j]
                                        ^

Well, let's move the index 'j' test before accesing the array to:
1) make the loop obvious
2) make gcc happy

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
2015-02-12 22:18:01 +03:00
Andrei Borzenkov 016875dd52 setup: fix blocklist size calculation
Found by: Coverity scan.
2015-01-30 22:57:39 +03:00
Andrei Borzenkov 151c19a42a grub-fstest: fix descriptor leak
Found by: Coverity scan.
2015-01-30 22:45:58 +03:00
Andrei Borzenkov 7aaed66455 grub-mkimage: fix potential NULL pointer dereference
Move fatal check whether symtab_section is NULL before first reference.

Found by: Coverity scan.
2015-01-30 22:26:05 +03:00
Andrei Borzenkov 11aae26cc3 util/grub-probe: fix memory leaks.
Found by: Coverity scan.
2015-01-27 22:11:52 +03:00
Vladimir Serbinenko 9ee5ae1fae Document intentional fallthroughs.
Found by: Coverity scan.
2015-01-27 17:17:58 +01:00
Andrei Borzenkov bd196014ec util/setup: fix memory leak.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Andrei Borzenkov fe4efe0d50 util/mkimage: fix memory leaks.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Andrei Borzenkov 1a87156e01 util/grub-mount: fix descriptor leak.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Andrei Borzenkov bd4e20eedf util/grub-mkstandalone: fix memory leak.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Andrei Borzenkov be0743b052 util/grub-install: rearrange code to avoid memory leak.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00