Commit Graph

9518 Commits

Author SHA1 Message Date
Matthew Garrett 527cbe513a Tag the bootp request as a DHCP discover 2018-03-29 22:18:53 -04:00
Matthew Garrett 902aec6758 Allow protocol to be separated from host with a semicolon
Some DHCP servers (such as dnsmasq) tokenise parameters with commas, making
it impossible to pass boot files with commas in them. Allow using a semicolon
to separate the protocol from host if a comma wasn't found.
2018-03-29 22:18:53 -04:00
Matthew Garrett fd0a4f5881 Send a user class identifier in bootp requests
It's helpful to determine that a request was sent by grub in order to permit
the server to provide different information at different stages of the boot
process. Send GRUB2 as a type 77 DHCP option when sending bootp packets in
order to make this possible.
2018-03-29 22:18:53 -04:00
Matthew Garrett 0987f9d173 Allow non-default ports for HTTP requests
Add support for passing ports in HTTP requests. This takes the form of:
(http,serverip:portnum)/file
2018-03-29 22:18:53 -04:00
Matthew Garrett 2ed8170c6f Allow passing of trusted keys via variables
Add support for adding gpg keys to the trusted database with a new command
called "trust_var". This takes the contents of a variable (in ascii-encoded
hex) and interprets it as a gpg public key.
2018-03-29 22:18:53 -04:00
Matthew Garrett d779b3e0fc Fix hex representation of binary variable contents
The getenv code was mishandling the conversion of binary to hex. Grub's
sprintf() doesn't seem to support the full set of format conversions, so
fix this in the nasty way.
2018-03-29 22:18:53 -04:00
Matthew Garrett 3d995d8c97 Add smbios command
Incorporate the smbios command from
https://raw.githubusercontent.com/dm0-/gnuxc/master/patches/grub-2.02~beta2-smbios-module.patch
so we can extract the machine UUID and serial number.
2018-03-29 22:18:53 -04:00
Matthew Garrett 357f451338 Add fwconfig command
Add a command to read values from the qemu fwcfg store. This allows data
to be passed from the qemu command line to grub.

Example use:

echo '(hd0,1)' >rootdev
qemu -fw_cfg opt/rootdev,file=rootdev

fwconfig opt/rootdev root
2018-03-29 22:18:53 -04:00
Matthew Garrett 3cb28afab6 Measure multiboot images and modules 2018-03-29 22:18:53 -04:00
Alex Crawford 1545295ad4 gpt: add search by disk uuid command 2018-03-29 22:18:53 -04:00
Alex Crawford bacbed2c07 gpt: minor cleanup 2018-03-29 22:18:53 -04:00
Matthew Garrett 206172d9f1 Measure commands
Measure each command executed by grub, which includes script execution.
2018-03-29 22:18:53 -04:00
Matthew Garrett 7f587ef7f9 Measure the kernel commandline
Measure the kernel commandline to ensure that it hasn't been modified
2018-03-29 22:18:53 -04:00
Matthew Garrett 5433dc99b3 Measure kernel and initrd on BIOS systems
Measure the kernel and initrd when loaded on BIOS systems
2018-03-29 22:18:53 -04:00
Matthew Garrett bccf37f527 Rework linux16 command
We want a single buffer that contains the entire kernel image in order to
perform a TPM measurement. Allocate one and copy the entire kernel int it
before pulling out the individual blocks later on.
2018-03-29 22:18:53 -04:00
Matthew Garrett 794c5b35d0 Rework linux command
We want a single buffer that contains the entire kernel image in order to
perform a TPM measurement. Allocate one and copy the entire kernel into it
before pulling out the individual blocks later on.
2018-03-29 22:18:53 -04:00
Matthew Garrett 6b79d94608 Add BIOS boot measurement
Measure the on-disk grub core on BIOS systems - unlike UEFI, the firmware
can't do this stage for us.
2018-03-29 22:18:53 -04:00
Michael Marineau d1270a2ba3 gpt: clean up little-endian crc32 computation
- Remove problematic cast from *uint8_t to *uint32_t (alignment issue).
 - Remove dynamic allocation and associated error handling paths.
 - Match parameter ordering to existing grub_crypto_hash function.
2018-03-29 22:18:53 -04:00
Matthew Garrett a5693087f0 Measure kernel + initrd
Measure the kernel and initrd when loaded on UEFI systems
2018-03-29 22:18:53 -04:00
Matthew Garrett 2db9e60640 Core TPM support
Add support for performing basic TPM measurements. Right now this only
supports extending PCRs statically and only on UEFI and BIOS systems, but
will measure all modules as they're loaded.
2018-03-29 22:18:53 -04:00
Matthew Garrett 57b4382f0c Fix race in EFI validation
The Secure Boot code currently reads the kernel from disk, validates the
signature and then reads it from disk again. A sufficiently exciting storage
device could modify the kernel between these two events and trigger the
execution of an untrusted kernel. Avoid re-reading it in order to ensure
this isn't a problem, and in the process speed up boot by not reading the
kernel twice.
2018-03-29 22:18:53 -04:00
Matthew Garrett 03b547c21e Add verity hash passthrough
Read the verity hash from the kernel binary and pass it to the running
system via the kernel command line
2018-03-29 22:18:53 -04:00
Matthew Garrett 250af4351d Add efi getenv command
Add a command to obtain the contents of EFI firmware variables.
2018-03-29 22:18:53 -04:00
Matthew Garrett f4d00290ed Fail validation if we can't find shim and Secure Boot is enabled
If grub is signed with a key that's in the trusted EFI keyring, an attacker
can point a boot entry at grub rather than at shim and grub will fail to
locate the shim verification protocol. This would then allow booting an
arbitrary kernel image. Fail validation if Secure Boot is enabled and we
can't find the shim protocol in order to prevent this.
2018-03-29 22:18:53 -04:00
Michael Marineau 67475f53e0 gpt: add search by partition label and uuid commands
Builds on the existing filesystem search code. Only for GPT right now.
2018-03-29 22:18:53 -04:00
Michael Marineau febf4666fb tests: add some partitions to the gpt unit test data 2018-03-29 22:18:52 -04:00
Michael Marineau ffb13159f1 gpt: switch partition names to a 16 bit type
In UEFI/GPT strings are UTF-16 so use a uint16 to make dealing with the
string practical.
2018-03-29 22:18:52 -04:00
Michael Marineau d9bdbc1048 gpt: move gpt guid printing function to common library 2018-03-29 22:18:52 -04:00
Michael Marineau f8f6f790aa gpt: split out checksum recomputation
For basic data modifications the full repair function is overkill.
2018-03-29 22:18:52 -04:00
Michael Marineau 508b02fc8a gpt: new gptprio.next command for selecting priority based partitions
Basic usage would look something like this:

    gptprio.next -d usr_dev -u usr_uuid
    linuxefi ($usr_dev)/boot/vmlinuz mount.usr=PARTUUID=$usr_uuid

After booting the system should set the 'successful' bit on the
partition that was used.
2018-03-29 22:18:52 -04:00
Michael Marineau 2cd009dffe gpt: add a new generic GUID type
In order to do anything with partition GUIDs they need to be stored in a
proper structure like the partition type GUIDs. Additionally add an
initializer macro to simplify defining both GUID types.
2018-03-29 22:18:52 -04:00
Michael Marineau c1151f761f tests: fix path to words file on Gentoo/CoreOS
By default there isn't a linux.words file, but there is words.
2018-03-29 22:18:52 -04:00
Michael Marineau 5e1829d414 gpt: add write function and gptrepair command
The first hint of something practical, a command that can restore any of
the GPT structures from the alternate location. New test case must run
under QEMU because the loopback device used by the other unit tests does
not support writing.
2018-03-29 22:18:52 -04:00
Michael Marineau dab6fac705 gpt: add new repair function to sync up primary and backup tables. 2018-03-29 22:18:52 -04:00
Michael Marineau 3d066264ac gpt: consolidate crc32 computation code
The gcrypt API is overly verbose, wrap it up in a helper function to
keep this rather common operation easy to use.
2018-03-29 22:18:52 -04:00
Michael Marineau 94f04a532d gpt: record size of of the entries table
The size of the entries table will be needed later when writing it back
to disk. Restructure the entries reading code to flow a little better.
2018-03-29 22:18:52 -04:00
Michael Marineau c26743a145 gpt: rename misnamed header location fields
The header location fields refer to 'this header' and 'alternate header'
respectively, not 'primary header' and 'backup header'. The previous
field names are backwards for the backup header.
2018-03-29 22:18:52 -04:00
Michael Marineau f69a9e0fdc gpt: start new GPT module
This module is a new implementation for reading GUID Partition Tables
which is much stricter than the existing part_gpt module and exports GPT
data directly instead of the generic grub_partition structure. It will
be the basis for modules that need to read/write/update GPT data.

The current code does nothing more than read and verify the table.
2018-03-29 22:18:52 -04:00
Colin Watson dec8c6a8ac Don't allow insmod when secure boot is enabled.
Hi,

Fedora's patch to forbid insmod in UEFI Secure Boot environments is fine
as far as it goes.  However, the insmod command is not the only way that
modules can be loaded.  In particular, the 'normal' command, which
implements the usual GRUB menu and the fully-featured command prompt,
will implicitly load commands not currently loaded into memory.  This
permits trivial Secure Boot violations by writing commands implementing
whatever you want to do and pointing $prefix at the malicious code.

I'm currently test-building this patch (replacing your current
grub-2.00-no-insmod-on-sb.patch), but this should be more correct.  It
moves the check into grub_dl_load_file.
2018-03-29 22:18:52 -04:00
Matthew Garrett 23589dc78b Add support for linuxefi 2018-03-29 22:18:52 -04:00
Vladimir Serbinenko e54c99aaff Increase version to 2.02. 2017-04-25 16:23:16 +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
Andrei Borzenkov 007f0b407f Add gnulib-fix-gcc7-fallthrough.diff
As long as the code is not upstream, add it as explicit patch for the
case of gnulib refresh.
2017-04-04 19:37:47 +03: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
Andrei Borzenkov 6cef7f6079 btrfs: avoid "used uninitialized" error with GCC7
sblock was local and so considered new variable on every loop
iteration.

Closes: 50597
2017-04-04 19:22:32 +03:00
Andrei Borzenkov ec4af117c6 acpi: add missing efi_call wrapper to acpi command
Fixed loading of ACPI tables on EFI (side effect was apparent memory
corruption ranging from unpredictable behavior to system reset).

Reported by Nando Eva <nando4eva@ymail.com>
2017-04-02 14:47:20 +03:00
Vladimir Serbinenko 8014b7b337 Increment version to GRUB 2.02~rc2. 2017-03-15 09:20:29 +01:00
Vladimir Serbinenko fcea891e17 Use core2duo for bootcheck test on 64-bit EFI.
Obviously pentium2 can't run efi64.
2017-03-15 09:20:14 +01:00
Andrei Borzenkov c42cb97f08 efi: skip iPXE block device.
iPXE adds Simple File System Protocol to loaded image handle, as side
effect it also adds Block IO protocol (according to comments, to work
around some bugs in EDK2). GRUB assumes that every device with Block IO
is disk and skips network initialization entirely. But iPXE Block IO
implementation is just a stub which always fails for every operation
so cannot be used. Attempt to detect and skip such devices.

We are using media ID which iPXE sets to "iPXE" and block IO size in
hope that no real device would announce 1B block ...

Closes: 50518
2017-03-14 04:14:36 +00:00
phcoder bcf3c55531 xen: Fix wrong register in relocator.
This fixes chainloading of some GRUB variants.
2017-03-05 10:07:36 +01:00