1 2021-06-08 Daniel Kiper <daniel.kiper@oracle.com>
5 2021-06-08 Daniel Kiper <daniel.kiper@oracle.com>
7 SECURITY: Add SECURITY file
8 The SECURITY file describes the GRUB project security policy.
10 It is based on https://github.com/wireapp/wire/blob/master/SECURITY.md
12 2021-06-08 Daniel Kiper <daniel.kiper@oracle.com>
14 MAINTAINERS: Add MAINTAINERS file
15 The MAINTAINERS file provides basic information about the GRUB project
18 2021-06-01 Dimitri John Ledkov <xnox@ubuntu.com>
20 grub-install: Add backup and restore
21 Refactor clean_grub_dir() to create a backup of all the files, instead
22 of just irrevocably removing them as the first action. If available,
23 register atexit() handler to restore the backup if errors occur before
24 point of no return, or remove the backup if everything was successful.
25 If atexit() is not available, the backup remains on disk for manual
28 Some platforms defined a point of no return, i.e. after modules & core
29 images were updated. Failures from any commands after that stage are
30 ignored, and backup is cleaned up. For example, on EFI platforms update
31 is not reverted when efibootmgr fails.
33 Extra care is taken to ensure atexit() handler is only invoked by the
34 parent process and not any children forks. Some older GRUB codebases
35 can invoke parent atexit() hooks from forks, which can mess up the
38 This allows safer upgrades of MBR & modules, such that
39 modules/images/fonts/translations are consistent with MBR in case of
40 errors. For example accidental grub-install /dev/non-existent-disk
41 currently clobbers and upgrades modules in /boot/grub, despite not
42 actually updating any MBR.
44 This patch only handles backup and restore of files copied to /boot/grub.
45 This patch does not perform backup (or restoration) of MBR itself or
46 blocklists. Thus when installing i386-pc platform, corruption may still
47 occur with MBR and blocklists which will not be attempted to be
48 automatically recovered.
50 Also add modinfo.sh and *.efi to the cleanup/backup/restore code path,
51 to ensure it is also cleaned, backed up and restored.
53 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
55 2021-06-01 Dimitri John Ledkov <xnox@ubuntu.com>
57 osdep/unix/exec: Avoid atexit() handlers when child execvp() fails
58 The functions grub_util_exec_pipe() and grub_util_exec_pipe_stderr()
59 currently call execvp(). If the call fails for any reason, the child
60 currently calls exit(127). This in turn executes the parents
61 atexit() handlers from the forked child, and then the same handlers
62 are called again from parent. This is usually not desired, and can
63 lead to deadlocks, and undesired behavior. So, change the exit() calls
64 to _exit() calls to avoid calling atexit() handlers from child.
66 Fixes: e75cf4a58 (unix exec: avoid atexit handlers when child exits)
68 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
70 2021-06-01 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
72 lib/i386/relocator64: Build fixes for i386
73 This fixes cross-compiling to x86 (e.g., the Hurd) from x86-linux of
75 grub-core/lib/i386/relocator64.S
77 This file has six sections that only build with a 64-bit assembler,
78 yet only the first two sections had support for a 32-bit assembler.
79 This patch completes this for the remaining sections.
81 To reproduce, update the GRUB source description in your local Guix
84 ./pre-inst-env guix build --system=i686-linux --target=i586-pc-gnu grub
86 or install an x86 cross-build environment on x86-linux (32-bit!) and
87 configure to cross build and make, e.g., do something like
91 --build=i686-unknown-linux-gnu \
95 Additionally, remove a line with redundant spaces.
97 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
99 2021-06-01 Javier Martinez Canillas <javierm@redhat.com>
101 fs/xfs: Add needsrepair incompat feature support
102 The XFS now has an incompat feature flag to indicate that a filesystem
103 needs to be repaired. The Linux kernel refuses to mount the filesystem
104 that has it set and only the xfs_repair tool is able to clear that flag.
106 The GRUB doesn't have the concept of mounting filesystems and just
107 attempts to read the files. But it does some sanity checking before
108 attempting to read from the filesystem. Among the things which are tested,
109 is if the super block only has set of incompatible features flags that
110 are supported by GRUB. If it contains any flags that are not listed as
111 supported, reading the XFS filesystem fails.
113 Since the GRUB doesn't attempt to detect if the filesystem is inconsistent
114 nor replays the journal, the filesystem access is a best effort. For this
115 reason, ignore if the filesystem needs to be repaired and just print a debug
116 message. That way, if reading or booting fails later, the user is able to
117 figure out that the failures can be related to broken XFS filesystem.
119 Suggested-by: Eric Sandeen <esandeen@redhat.com>
120 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
122 2021-06-01 Carlos Maiolino <cmaiolino@redhat.com>
124 fs/xfs: Add bigtime incompat feature support
125 The XFS filesystem supports a bigtime feature to overcome y2038 problem.
126 This patch makes the GRUB able to support the XFS filesystems with this
129 The XFS counter for the bigtime enabled timestamps starts at 0, which
130 translates to GRUB_INT32_MIN (Dec 31 20:45:52 UTC 1901) in the legacy
131 timestamps. The conversion to Unix timestamps is made before passing the
132 value to other GRUB functions.
134 For this to work properly, GRUB requires an access to flags2 field in the
135 XFS ondisk inode. So, the grub_xfs_inode structure has been updated to
136 cover full ondisk inode.
138 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
140 2021-06-01 Carlos Maiolino <cmaiolino@redhat.com>
142 fs: Use 64-bit type for filesystem timestamp
143 Some filesystems nowadays use 64-bit types for timestamps. So, update
144 grub_dirhook_info struct to use an grub_int64_t type to store mtime.
145 This also updates the grub_unixtime2datetime() function to receive
146 a 64-bit timestamp argument and do 64-bit-safe divisions.
148 All the remaining conversion from 32-bit to 64-bit should be safe, as
149 32-bit to 64-bit attributions will be implicitly casted. The most
150 critical part in the 32-bit to 64-bit conversion is in the function
151 grub_unixtime2datetime() where it needs to deal with the 64-bit type.
152 So, for that, the grub_divmod64() helper has been used.
154 These changes enables the GRUB to support dates beyond y2038.
156 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
158 2021-05-28 Javier Martinez Canillas <javierm@redhat.com>
160 types: Define PRI{x,d}GRUB_INT{32,64}_T format specifiers
161 There are already PRI*_T constants defined for unsigned integers but not
162 for signed integers. Add format specifiers for the latter.
164 Suggested-by: Daniel Kiper <daniel.kiper@oracle.com>
165 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
167 2021-05-28 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
169 kern/efi/sb: Remove duplicate efi_shim_lock_guid variable
170 The efi_shim_lock_guid local variable and shim_lock_guid global variable
171 have the same GUID value. Only the latter is retained.
173 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
175 2021-05-10 Javier Martinez Canillas <javierm@redhat.com>
177 util/mkimage: Fix wrong PE32+ section sizes for some arches
178 The commit f60ba9e5945 (util/mkimage: Refactor section setup to use a helper)
179 added a helper function to setup PE sections. But it also changed how the
180 raw data offsets were calculated since all the section sizes are aligned.
181 However, for some platforms, i.e ia64-efi and arm64-efi, the kernel image
182 size is not aligned using the section alignment. This leads to the situation
183 in which the mods section offset in its PE section header does not match its
184 real placement in the PE file. So, finally the GRUB is not able to locate
185 and load built-in modules.
187 The problem surfaces on ia64-efi and arm64-efi because both platforms
188 require additional relocation data which is added behind .bss section.
189 So, we have to add some padding behind this extra data to make the
190 beginning of mods section properly aligned in the PE file. Fix it by
191 aligning the kernel_size to the section alignment. That makes the sizes
192 and offsets in the PE section headers to match relevant sections in the
195 Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
196 Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
197 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
199 2021-05-10 Daniel Kiper <daniel.kiper@oracle.com>
201 term/terminfo: Fix the terminfo command help and documentation
202 Additionally, fix the terminfo spelling mistake in
203 the GRUB development documentation.
205 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
207 2021-05-10 Daniel Kiper <daniel.kiper@oracle.com>
209 i18n: Align N_() formatting with the rest of GRUB code
210 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
212 2021-05-10 Daniel Kiper <daniel.kiper@oracle.com>
214 i18n: Format large integers before the translation message - take 2
215 This is an additional fix which has been missing from the commit 837fe48de
216 (i18n: Format large integers before the translation message).
218 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
220 2021-04-13 Miguel Ángel Arruga Vivas <rosen644835@gmail.com>
222 i18n: Format large integers before the translation message
223 The GNU gettext only supports the ISO C99 macros for integral
224 types. If there is a need to use unsupported formatting macros,
225 e.g. PRIuGRUB_UINT64_T, according to [1] the number to a string
226 conversion should be separated from the code printing message
227 requiring the internationalization. So, the function grub_snprintf()
228 is used to print the numeric values to an intermediate buffer and
229 the internationalized message contains a string format directive.
231 [1] https://www.gnu.org/software/gettext/manual/html_node/Preparing-Strings.html#No-string-concatenation
233 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
235 2021-04-12 Daniel Axtens <dja@axtens.net>
237 video/fb/fbfill: Use unsigned integers for width/height
238 Since commit 7ce3259f67ac (video/fb/fbfill: Fix potential integer
239 overflow), clang builds of grub-emu have failed with messages like:
241 /usr/bin/ld: libgrubmods.a(libgrubmods_a-fbfill.o): in function `grub_video_fbfill_direct24':
242 fbfill.c:(.text+0x28e): undefined reference to `__muloti4'
244 This appears to be due to a weird quirk in how clang compiles
246 grub_mul(dst->mode_info->bytes_per_pixel, width, &rowskip)
248 which is grub_mul(unsigned int, int, &grub_size_t).
250 It looks like clang somewhere promotes everything to 128-bit maths
251 before ultimately reducing down to 64 bit for grub_size_t. I think
252 this is because width is signed, and indeed converting width to an
253 unsigned int makes the problem go away.
255 This conversion also makes more sense generally:
256 - the caller of all the fbfill_directN functions is
257 grub_video_fb_fill_dispatch() and it takes width and height as
258 unsigned ints already,
259 - it doesn't make sense to fill a negative width or height.
261 Convert the width and height arguments and associated loop counters
264 Fixes: 7ce3259f67ac (video/fb/fbfill: Fix potential integer overflow)
266 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
268 2021-04-12 Glenn Washburn <development@efficientek.com>
270 docs: Conform badmem and cutmem description indentations with other commands
271 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
273 docs: Add note to cryptomount that UUIDs should be specified without dashes
274 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
276 2021-04-12 Aru Sahni <aru@arusahni.net>
278 templates: Fix user-facing typo with an incorrect use of "it's"
279 Since the possessive form of "it" is being used, the apostrophe must be omitted.
281 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
283 2021-04-12 Colin Watson <cjwatson@debian.org>
285 buffer: Sync up out-of-range error message
286 The messages associated with other similar GRUB_ERR_OUT_OF_RANGE errors
287 were lacking the trailing full stop. Syncing up the strings saves a small
288 amount of precious core image space on i386-pc.
290 DOWN: obj/i386-pc/grub-core/kernel.img (31740 > 31708) - change: -32
291 DOWN: i386-pc core image (biosdisk ext2 part_msdos) (27453 > 27452) - change: -1
292 DOWN: i386-pc core image (biosdisk ext2 part_msdos diskfilter mdraid09) (32367 > 32359) - change: -8
294 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
296 2021-04-12 Glenn Washburn <development@efficientek.com>
298 usb/usbhub: Use GRUB_USB_MAX_CONF macro instead of literal in hub for maximum configs
299 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
301 2021-04-12 Daniel Drake <drake@endlessm.com>
303 fs/minix: Avoid mistakenly probing ext2 filesystems
304 The ext2 (and ext3, ext4) filesystems write the number of free inodes to
307 On a MINIX filesystem, that same location is used for the MINIX superblock
310 If the number of free inodes on an ext2 filesystem is equal to any
311 of the four MINIX superblock magic values plus any multiple of 65536,
312 GRUB's MINIX filesystem code will probe it as a MINIX filesystem.
314 In the case of an OS using ext2 as the root filesystem, since there will
315 ordinarily be some amount of file creation and deletion on every bootup,
316 it effectively means that this situation has a 1:16384 chance of being hit
319 This will cause GRUB's filesystem probing code to mistakenly identify an
320 ext2 filesystem as MINIX. This can be seen by e.g. "search --label"
321 incorrectly indicating that no such ext2 partition with matching label
322 exists, whereas in fact it does.
324 After spotting the rough cause of the issue I was facing here, I borrowed
325 much of the diagnosis/explanation from meierfra who found and investigated
326 the same issue in util-linux in 2010:
328 https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/518582
330 This was fixed in util-linux by having the MINIX code check for the
331 ext2 magic. Do the same here.
333 Reviewed-by: Derek Foreman <derek@endlessos.org>
334 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
336 2021-03-12 Daniel Kiper <daniel.kiper@oracle.com>
340 2021-03-11 Ard Biesheuvel <ard.biesheuvel@arm.com>
342 arm/linux: Fix ARM Linux header layout
343 The hdr_offset member of the ARM Linux image header appears at
344 offset 0x3c, matching the PE/COFF spec's placement of the COFF
345 header offset in the MS-DOS header. We're currently off by four,
348 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
350 2021-03-10 Glenn Washburn <development@efficientek.com>
352 style: Format string macro should have a space between quotes
353 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
355 2021-03-10 Glenn Washburn <development@efficientek.com>
357 grub/err: Do compile-time format string checking on grub_error()
358 This should help prevent format string errors and thus improve the quality
361 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
363 2021-03-10 Glenn Washburn <development@efficientek.com>
365 fs/zfs/zfs: Use format code "%llu" for 64-bit uint bp->blk_prop in grub_error()
366 This is a temporary, less-intrusive change to get the build to success with
367 compiler format string checking turned on. There is a better fix which
368 addresses this issue, but it needs more testing. Use this change so that
369 format string checking on grub_error() can be turned on until the better
370 change is fully tested.
372 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
374 2021-03-10 Glenn Washburn <development@efficientek.com>
376 fs/hfsplus: Use format code PRIuGRUB_UINT64_T for 64-bit typed fileblock in grub_error()
377 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
379 2021-03-10 Glenn Washburn <development@efficientek.com>
381 dl/elf: Use format code PRIxGRUB_UINT64_T for 64-bit arg in grub_error()
382 The macro ELF_R_TYPE does not change the underlying type. Here its argument
383 is a 64-bit Elf64_Xword. Make sure the format code matches.
385 For the RISC-V architecture, rel->r_info could be either Elf32_Xword or
386 Elf64_Xword depending on if 32 or 64-bit RISC-V is being built. So cast
387 to 64-bit value regardless.
389 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
391 2021-03-10 Glenn Washburn <development@efficientek.com>
393 disk/ata: Use format code PRIxGRUB_UINT64_T for 64-bit uint argument in grub_error()
394 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
396 2021-03-10 Glenn Washburn <development@efficientek.com>
398 loader/i386/pc/linux: Use PRI* macros to get correct format string code across architectures
399 Also remove casting of format string args so that the architecture dependent
402 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
404 2021-03-10 Glenn Washburn <development@efficientek.com>
406 kern/efi/mm: Format string error in grub_error()
407 The second format string argument, GRUB_EFI_MAX_USABLE_ADDRESS, is a macro
408 to a number literal. However, depending on what the target architecture, the
409 type can be 32 or 64 bits. Cast to a 64-bit integer. Also, change the
410 format string literals "%llx" to use PRIxGRUB_UINT64_T.
412 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
414 2021-03-10 Glenn Washburn <development@efficientek.com>
416 commands/pgp: Format code for grub_error() is incorrect
417 The format code is for a 32-bit int, but the argument, keyid, is declared as
418 a 64 bit int. The comment above says keyid is 32-bit. I'm not sure if the
419 comment or declaration is wrong, so force the display of a 64-bit int for now.
421 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
423 2021-03-10 Glenn Washburn <development@efficientek.com>
425 grub_error: Use format code PRIuGRUB_SIZE for variables of type grub_size_t
426 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
428 2021-03-10 Glenn Washburn <development@efficientek.com>
430 disk/dmraid_nvidia: Format string error in grub_error()
431 The grub_error() has a format string expecting two arguments, but only one
432 provided. According to the comments in the struct grub_nv_super definition,
433 the version field looks like a version number where major.minor is encoded
434 as each a byte in the two-byte short.
436 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
438 2021-03-10 Glenn Washburn <development@efficientek.com>
440 video/bochs: grub_error() format string add missing format code
441 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
443 2021-03-10 Glenn Washburn <development@efficientek.com>
445 parttool/msdospart: grub_error() missing format string argument
446 Its obvious from the error message that the variable named "type" was
447 accidentally omitted.
449 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
451 2021-03-10 Glenn Washburn <development@efficientek.com>
453 misc: Format string for grub_error() should be a literal
454 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
456 2021-03-10 Philip Müller <philm@manjaro.org>
458 templates: Properly disable the os-prober by default
459 This patch does the following:
460 - really disables os-prober by default in the util/grub-mkconfig.in
461 by setting GRUB_DISABLE_OS_PROBER to true,
462 - fixes the logic in the util/grub.d/30_os-prober.in,
463 - updates the grub_warn() lines.
465 Reason for the code shuffling in the util/grub-mkconfig.in:
467 The default was GRUB_DISABLE_OS_PROBER=false if you don't set
468 GRUB_DISABLE_OS_PROBER at all. To prevent os-prober from starting we
469 have to set it by default to true and shuffle GRUB_DISABLE_OS_PROBER to
470 code section, which is executed by the script. However we still give an
471 option to the user to overwrite it with false, if he wants to execute
474 Fixes: e3464147 (templates: Disable the os-prober by default)
476 Reported-by: Didier Spaier <didier@slint.fr>
477 Reported-by: Lennart Sorensen <lsorense@csclub.uwaterloo.ca>
478 Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
479 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
481 2021-03-10 Michael Chang <mchang@suse.com>
483 kern/efi/sb: Add chainloaded image as shim's verifiable object
484 While attempting to dual boot Microsoft Windows with UEFI chainloader,
485 it failed with below error when UEFI Secure Boot was enabled:
487 error ../../grub-core/kern/verifiers.c:119:verification requested but
488 nobody cares: /EFI/Microsoft/Boot/bootmgfw.efi.
490 It is a regression, as previously it worked without any problem.
492 It turns out chainloading PE image has been locked down by commit
493 578c95298 (kern: Add lockdown support). However, we should consider it
494 as verifiable object by shim to allow booting in UEFI Secure Boot mode.
495 The chainloaded PE image could also have trusted signature created by
496 vendor with their pubkey cert in db. For that matters it's usage should
497 not be locked down under UEFI Secure Boot, and instead shim should be
498 allowed to validate a PE binary signature before running it.
500 Fixes: 578c95298 (kern: Add lockdown support)
502 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
504 2021-03-10 Glenn Washburn <development@efficientek.com>
506 disk/pata: Suppress error message "no device connected"
507 This error message comes from the grub_print_error() in
508 grub_pata_device_initialize(), which does not pass on the error, and is
509 raised in check_device(). The function check_device() needs to return this
510 as an error because check_device() is also used in grub_pata_open(), which
511 does pass on this error to indicate that the device can not be used.
513 This is actually not an error when displayed by grub_pata_device_initialize()
514 because it just indicates that there are no pata devices seen. This may be
515 confusing to end users who do not have pata devices yet are loading the
516 pata module (perhaps implicitly via nativedisk). This also causes unnecessary
517 output which may need to be accounted for in functional testing.
519 Instead print to the debug log when check_device() raises this "error" and
520 pop the error from the error stack. If there is another error on the stack
521 then print the error stack as those should be real errors.
523 Acked-by: Paul Menzel <pmenzel@molgen.mpg.de>
524 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
526 2021-03-10 Yi Zhao <yi.zhao@windriver.com>
528 fs/ext2: Fix a file not found error when a symlink filesize is equal to 60
529 We encountered a file not found error when the symlink filesize is
533 lrwxrwxrwx 1 root root 60 Jan 6 16:37 initrd -> secure-core-image-initramfs-5.10.2-yoctodev-standard.cpio.gz
535 When booting, we got the following error in the GRUB:
537 error: file `/initrd' not found
539 The root cause is that the size of diro->inode.symlink is equal to 60
540 and a symlink name has to be terminated with NUL there. So, if the
541 symlink filesize is exactly 60 then it is also stored in a separate
542 block rather than in the inode itself.
544 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
546 2021-03-02 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
548 loader/i386/linux: Do not use grub_le_to_cpu32() for relocatable variable
549 The relocatable variable is defined as grub_uint8_t. Relevant
550 member in setup_header structure is also defined as one byte
551 in Linux boot protocol. By semantic definition it is a bool type.
552 It is not appropriate to treat it as a four bytes. This patch
555 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
557 2021-03-02 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
559 loader/i386/linux: Remove redundant code from in grub_cmd_linux()
560 The preferred_address has been assigned to GRUB_LINUX_BZIMAGE_ADDR
561 during initialization in grub_cmd_linux(). The assignment here
562 is redundant and should be removed.
564 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
566 2021-03-02 Heinrich Schuchardt <xypron.glpk@gmx.de>
568 efi: The device-tree must be in EfiACPIReclaimMemory
569 According to the Embedded Base Boot Requirements (EBBR) specification the
570 device-tree passed to Linux as a configuration table must reside in
571 EfiACPIReclaimMemory.
573 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
575 2021-03-02 Heinrich Schuchardt <xypron.glpk@gmx.de>
577 commands/efi/lsefisystab: Add short text for EFI_RT_PROPERTIES_TABLE_GUID
578 UEFI specification 2.8 errata B introduced the EFI_RT_PROPERTIES_TABLE
579 describing the services available at runtime.
581 The lsefisystab command is used to display installed EFI configuration
582 tables. Currently it only shows the GUID but not a short text for the
585 Provide a short text for the EFI_RT_PROPERTIES_TABLE_GUID.
587 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
589 2021-03-02 Petr Vorel <pvorel@suse.cz>
591 docs/luks2: Mention key derivation function support
592 To give users hint why Argon2, the default in cryptsetup for LUKS2, does
595 Acked-by: Paul Menzel <pmenzel@molgen.mpg.de>
596 Reviewed-by: Patrick Steinhardt <ps@pks.im>
597 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
599 2021-03-02 Derek Foreman <derek@endlessos.org>
601 commands/file: Fix array/enum desync
602 The commit f1957dc8a (RISC-V: Add to build system) added two entries to
603 the options array, but only 1 entry to the enum. This resulted in
604 everything after the insertion point being off by one.
606 This broke at least the "file --is-hibernated-hiberfil" command.
608 Bring the two back in sync by splitting the IS_RISCV_EFI enum entry into
609 two, as is done for other architectures.
611 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
613 2021-03-02 Marco A Benatto <mbenatto@redhat.com>
615 kern/mm: Fix grub_debug_calloc() compilation error
616 Fix compilation error due to missing parameter to
617 grub_printf() when MM_DEBUG is defined.
619 Fixes: 64e26162e (calloc: Make sure we always have an overflow-checking calloc() available)
621 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
623 2021-03-02 Alex Burmashev <alexander.burmashev@oracle.com>
625 templates: Disable the os-prober by default
626 The os-prober is enabled by default what may lead to potentially
627 dangerous use cases and borderline opening attack vectors. This
628 patch disables the os-prober, adds warning messages and updates
629 GRUB_DISABLE_OS_PROBER configuration option documentation. This
630 way we make it clear that the os-prober usage is not recommended.
632 Simplistic nature of this change allows downstream vendors, who
633 really want os-prober to be enabled out of the box in their
634 relevant products, easily revert to it's old behavior.
636 Reported-by: NyankoSec (<nyanko@10x.moe>, https://twitter.com/NyankoSec),
637 working with SSD Secure Disclosure
638 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
640 2021-03-02 Thomas Frauendorfer | Miray Software <tf@miray.de>
642 gfxmenu/gui: Check printf() format in the gui_progress_bar and gui_label
643 The gui_progress_bar and gui_label components can display the timeout
644 value. The format string can be set through a theme file. This patch
645 adds a validation step to the format string.
647 If a user loads a theme file into the GRUB without this patch then
648 a GUI label with the following settings
656 will interpret the current timeout value as string pointer and print the
657 memory at that position on the screen. It is not desired behavior.
659 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
661 2021-03-02 Thomas Frauendorfer | Miray Software <tf@miray.de>
663 kern/misc: Add function to check printf() format against expected format
664 The grub_printf_fmt_check() function parses the arguments of an untrusted
665 printf() format and an expected printf() format and then compares the
666 arguments counts and arguments types. The arguments count in the untrusted
667 format string must be less or equal to the arguments count in the expected
668 format string and both arguments types must match.
670 To do this the parse_printf_arg_fmt() helper function is extended in the
673 1. Add a return value to report errors to the grub_printf_fmt_check().
675 2. Add the fmt_check argument to enable stricter format verification:
676 - the function expects that arguments definitions are always
677 terminated by a supported conversion specifier.
678 - positional parameters, "$", are not allowed, as they cannot be
679 validated correctly with the current implementation. For example
680 "%s%1$d" would assign the first args entry twice while leaving the
681 second one unchanged.
682 - Return an error if preallocated space in args is too small and
683 allocation fails for the needed size. The grub_printf_fmt_check()
684 should verify all arguments. So, if validation is not possible for
685 any reason it should return an error.
686 This also adds a case entry to handle "%%", which is the escape
687 sequence to print "%" character.
689 3. Add the max_args argument to check for the maximum allowed arguments
690 count in a printf() string. This should be set to the arguments count
691 of the expected format. Then the parse_printf_arg_fmt() function will
692 return an error if the arguments count is exceeded.
694 The two additional arguments allow us to use parse_printf_arg_fmt() in
695 printf() and grub_printf_fmt_check() calls.
697 When parse_printf_arg_fmt() is used by grub_printf_fmt_check() the
698 function parse user provided untrusted format string too. So, in
699 that case it is better to be too strict than too lenient.
701 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
703 2021-03-02 Thomas Frauendorfer | Miray Software <tf@miray.de>
705 kern/misc: Add STRING type for internal printf() format handling
706 Set printf() argument type for "%s" to new type STRING. This is in
707 preparation for a follow up patch to compare a printf() format string
708 against an expected printf() format string.
710 For "%s" the corresponding printf() argument is dereferenced as pointer
711 while all other argument types are defined as integer value. However,
712 when validating a printf() format it is necessary to differentiate "%s"
713 from "%p" and other integers. So, let's do that.
715 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
717 2021-03-02 Thomas Frauendorfer | Miray Software <tf@miray.de>
719 kern/misc: Split parse_printf_args() into format parsing and va_list handling
720 This patch is preparing for a follow up patch which will use
721 the format parsing part to compare the arguments in a printf()
722 format from an external source against a printf() format with
725 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
727 2021-03-02 Dimitri John Ledkov <xnox@ubuntu.com>
729 shim_lock: Only skip loading shim_lock verifier with explicit consent
730 Commit 32ddc42c (efi: Only register shim_lock verifier if shim_lock
731 protocol is found and SB enabled) reintroduced CVE-2020-15705 which
732 previously only existed in the out-of-tree linuxefi patches and was
733 fixed as part of the BootHole patch series.
735 Under Secure Boot enforce loading shim_lock verifier. Allow skipping
736 shim_lock verifier if SecureBoot/MokSBState EFI variables indicate
737 skipping validations, or if GRUB image is built with --disable-shim-lock.
739 Fixes: 132ddc42c (efi: Only register shim_lock verifier if shim_lock
740 protocol is found and SB enabled)
741 Fixes: CVE-2020-15705
744 Reported-by: Dimitri John Ledkov <xnox@ubuntu.com>
745 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
747 2021-03-02 Dimitri John Ledkov <xnox@ubuntu.com>
749 grub-install-common: Add --sbat option
750 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
752 2021-03-02 Peter Jones <pjones@redhat.com>
754 util/mkimage: Add an option to import SBAT metadata into a .sbat section
755 Add a --sbat option to the grub-mkimage tool which allows us to import
756 an SBAT metadata formatted as a CSV file into a .sbat section of the
759 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
761 2021-03-02 Peter Jones <pjones@redhat.com>
763 util/mkimage: Refactor section setup to use a helper
764 Add a init_pe_section() helper function to setup PE sections. This makes
765 the code simpler and easier to read.
767 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
769 2021-03-02 Peter Jones <pjones@redhat.com>
771 util/mkimage: Improve data_size value calculation
772 According to "Microsoft Portable Executable and Common Object File Format
773 Specification", the Optional Header SizeOfInitializedData field contains:
775 Size of the initialized data section, or the sum of all such sections if
776 there are multiple data sections.
778 Make this explicit by adding the GRUB kernel data size to the sum of all
779 the modules sizes. The ALIGN_UP() is not required by the PE spec but do
780 it to avoid alignment issues.
782 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
784 2021-03-02 Peter Jones <pjones@redhat.com>
786 util/mkimage: Reorder PE optional header fields set-up
787 This makes the PE32 and PE32+ header fields set-up easier to follow by
788 setting them closer to the initialization of their related sections.
790 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
792 2021-03-02 Peter Jones <pjones@redhat.com>
794 util/mkimage: Unify more of the PE32 and PE32+ header set-up
795 There's quite a bit of code duplication in the code that sets the optional
796 header for PE32 and PE32+. The two are very similar with the exception of
797 a few fields that have type grub_uint64_t instead of grub_uint32_t.
799 Factor out the common code and add a PE_OHDR() macro that simplifies the
800 set-up and make the code more readable.
802 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
804 2021-03-02 Peter Jones <pjones@redhat.com>
806 util/mkimage: Always use grub_host_to_target32() to initialize PE stack and heap stuff
807 This change does not impact final result of initialization itself.
808 However, it eases PE code unification in subsequent patches.
810 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
812 2021-03-02 Peter Jones <pjones@redhat.com>
814 util/mkimage: Use grub_host_to_target32() instead of grub_cpu_to_le32()
815 The latter doesn't take into account the target image endianness. There is
816 a grub_cpu_to_le32_compile_time() but no compile time variant for function
817 grub_host_to_target32(). So, let's keep using the other one for this case.
819 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
821 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
823 util/mkimage: Remove unused code to add BSS section
824 The code is compiled out so there is no reason to keep it.
826 Additionally, don't set bss_size field since we do not add a BSS section.
828 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
830 2021-03-02 Chris Coulson <chris.coulson@canonical.com>
832 kern/efi: Add initial stack protector implementation
833 It works only on UEFI platforms but can be quite easily extended to
834 others architectures and platforms if needed.
836 Reviewed-by: Marco A Benatto <mbenatto@redhat.com>
837 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
839 2021-03-02 Chris Coulson <chris.coulson@canonical.com>
841 kern/parser: Fix a stack buffer overflow
842 grub_parser_split_cmdline() expands variable names present in the supplied
843 command line in to their corresponding variable contents and uses a 1 kiB
844 stack buffer for temporary storage without sufficient bounds checking. If
845 the function is called with a command line that references a variable with
846 a sufficiently large payload, it is possible to overflow the stack
847 buffer via tab completion, corrupt the stack frame and potentially
850 Fixes: CVE-2020-27749
852 Reported-by: Chris Coulson <chris.coulson@canonical.com>
853 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
855 2021-03-02 Chris Coulson <chris.coulson@canonical.com>
857 kern/buffer: Add variable sized heap buffer
858 Add a new variable sized heap buffer type (grub_buffer_t) with simple
859 operations for appending data, accessing the data and maintaining
862 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
864 2021-03-02 Chris Coulson <chris.coulson@canonical.com>
866 kern/parser: Refactor grub_parser_split_cmdline() cleanup
867 Introduce a common function epilogue used for cleaning up on all
868 return paths, which will simplify additional error handling to be
869 introduced in a subsequent commit.
871 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
873 2021-03-02 Chris Coulson <chris.coulson@canonical.com>
875 kern/parser: Introduce terminate_arg() helper
876 process_char() and grub_parser_split_cmdline() use similar code for
877 terminating the most recent argument. Add a helper function for this.
879 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
881 2021-03-02 Chris Coulson <chris.coulson@canonical.com>
883 kern/parser: Introduce process_char() helper
884 grub_parser_split_cmdline() iterates over each command line character.
885 In order to add error checking and to simplify the subsequent error
886 handling, split the character processing in to a separate function.
888 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
890 2021-03-02 Chris Coulson <chris.coulson@canonical.com>
892 kern/parser: Fix a memory leak
893 The getline() function supplied to grub_parser_split_cmdline() returns
894 a newly allocated buffer and can be called multiple times, but the
895 returned buffer is never freed.
897 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
899 2021-03-02 Daniel Axtens <dja@axtens.net>
901 fs/btrfs: Squash some uninitialized reads
902 We need to check errors before calling into a function that uses the result.
904 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
906 2021-03-02 Daniel Axtens <dja@axtens.net>
908 fs/btrfs: Validate the number of stripes/parities in RAID5/6
909 This prevents a divide by zero if nstripes == nparities, and
910 also prevents propagation of invalid values if nstripes ends up
913 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
915 2021-03-02 Daniel Axtens <dja@axtens.net>
917 disk/lvm: Do not allow a LV to be it's own segment's node's LV
918 This prevents infinite recursion in the diskfilter verification code.
920 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
922 2021-03-02 Daniel Axtens <dja@axtens.net>
924 disk/lvm: Sanitize rlocn->offset to prevent wild read
925 rlocn->offset is read directly from disk and added to the metadatabuf
926 pointer to create a pointer to a block of metadata. It's a 64-bit
927 quantity so as long as you don't overflow you can set subsequent
928 pointers to point anywhere in memory.
930 Require that rlocn->offset fits within the metadata buffer size.
932 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
934 2021-03-02 Daniel Axtens <dja@axtens.net>
936 disk/lvm: Do not overread metadata
937 We could reach the end of valid metadata and not realize, leading to
938 some buffer overreads. Check if we have reached the end and bail.
940 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
942 2021-03-02 Daniel Axtens <dja@axtens.net>
944 disk/lvm: Do not crash if an expected string is not found
945 Clean up a bunch of cases where we could have strstr() fail and lead to
946 us dereferencing NULL.
948 We'll still leak memory in some cases (loops don't clean up allocations
949 from earlier iterations if a later iteration fails) but at least we're
952 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
954 2021-03-02 Daniel Axtens <dja@axtens.net>
956 disk/lvm: Bail on missing PV list
957 There's an if block for the presence of "physical_volumes {", but if
958 that block is absent, then p remains NULL and a NULL-deref will result
959 when looking for logical volumes.
961 It doesn't seem like LVM makes sense without physical volumes, so error
962 out rather than crashing.
964 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
966 2021-03-02 Daniel Axtens <dja@axtens.net>
968 disk/lvm: Don't blast past the end of the circular metadata buffer
969 This catches at least some OOB reads, and it's possible I suppose that
970 if 2 * mda_size is less than GRUB_LVM_MDA_HEADER_SIZE it might catch some
971 OOB writes too (although that hasn't showed up as a crash in fuzzing yet).
973 It's a bit ugly and I'd appreciate better suggestions.
975 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
977 2021-03-02 Daniel Axtens <dja@axtens.net>
979 disk/lvm: Don't go beyond the end of the data we read from disk
980 We unconditionally trusted offset_xl from the LVM label header, even if
981 it told us that the PV header/disk locations were way off past the end
982 of the data we read from disk.
984 Require that the offset be sane, fixing an OOB read and crash.
986 Fixes: CID 314367, CID 314371
988 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
990 2021-03-02 Daniel Axtens <dja@axtens.net>
992 io/gzio: Zero gzio->tl/td in init_dynamic_block() if huft_build() fails
993 If huft_build() fails, gzio->tl or gzio->td could contain pointers that
994 are no longer valid. Zero them out.
996 This prevents a double free when grub_gzio_close() comes through and
997 attempts to free them again.
999 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1001 2021-03-02 Daniel Axtens <dja@axtens.net>
1003 io/gzio: Catch missing values in huft_build() and bail
1004 In huft_build(), "v" is a table of values in order of bit length.
1005 The code later (when setting up table entries in "r") assumes that all
1006 elements of this array corresponding to a code are initialized and less
1007 than N_MAX. However, it doesn't enforce this.
1009 With sufficiently manipulated inputs (e.g. from fuzzing), there can be
1010 elements of "v" that are not filled. Therefore a lookup into "e" or "d"
1011 will use an uninitialized value. This can lead to an invalid/OOB read on
1012 those values, often leading to a crash.
1014 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1016 2021-03-02 Daniel Axtens <dja@axtens.net>
1018 io/gzio: Add init_dynamic_block() clean up if unpacking codes fails
1019 init_dynamic_block() didn't clean up gzio->tl and td in some error
1020 paths. This left td pointing to part of tl. Then in grub_gzio_close(),
1021 when tl was freed the storage for td would also be freed. The code then
1022 attempts to free td explicitly, performing a UAF and then a double free.
1024 Explicitly clean up tl and td in the error paths.
1026 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1028 2021-03-02 Daniel Axtens <dja@axtens.net>
1030 io/gzio: Bail if gzio->tl/td is NULL
1031 This is an ugly fix that doesn't address why gzio->tl comes to be NULL.
1032 However, it seems to be sufficient to patch up a bunch of NULL derefs.
1034 It would be good to revisit this in future and see if we can have
1035 a cleaner solution that addresses some of the causes of the unexpected
1038 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1040 2021-03-02 Daniel Axtens <dja@axtens.net>
1042 fs/nilfs2: Properly bail on errors in grub_nilfs2_btree_node_lookup()
1043 We just introduced an error return in grub_nilfs2_btree_node_lookup().
1044 Make sure the callers catch it.
1046 At the same time, make sure that grub_nilfs2_btree_node_lookup() always
1047 inits the index pointer passed to it.
1049 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1051 2021-03-02 Daniel Axtens <dja@axtens.net>
1053 fs/nilfs2: Don't search children if provided number is too large
1054 NILFS2 reads the number of children a node has from the node. Unfortunately,
1055 that's not trustworthy. Check if it's beyond what the filesystem permits and
1058 This blocks some OOB reads. I'm not sure how controllable the read is and what
1059 could be done with invalidly read data later on.
1061 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1063 2021-03-02 Daniel Axtens <dja@axtens.net>
1065 fs/nilfs2: Reject too-large keys
1066 NILFS2 has up to 7 keys, per the data structure. Do not permit array
1067 indices in excess of that.
1069 This catches some OOB reads. I don't know how controllable the invalidly
1070 read data is or if that could be used later in the program.
1072 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1074 2021-03-02 Daniel Axtens <dja@axtens.net>
1076 fs/jfs: Catch infinite recursion
1077 It's possible with a fuzzed filesystem for JFS to keep getblk()-ing
1078 the same data over and over again, leading to stack exhaustion.
1080 Check if we'd be calling the function with exactly the same data as
1081 was passed in, and if so abort.
1083 I'm not sure what the performance impact of this is and am open to
1086 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1088 2021-03-02 Daniel Axtens <dja@axtens.net>
1090 fs/jfs: Limit the extents that getblk() can consider
1091 getblk() implicitly trusts that treehead->count is an accurate count of
1092 the number of extents. However, that value is read from disk and is not
1093 trustworthy, leading to OOB reads and crashes. I am not sure to what
1094 extent the data read from OOB can influence subsequent program execution.
1096 Require callers to pass in the maximum number of extents for which
1099 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1101 2021-03-02 Daniel Axtens <dja@axtens.net>
1103 fs/jfs: Do not move to leaf level if name length is negative
1104 Fuzzing JFS revealed crashes where a negative number would be passed
1105 to le_to_cpu16_copy(). There it would be cast to a large positive number
1106 and the copy would read and write off the end of the respective buffers.
1108 Catch this at the top as well as the bottom of the loop.
1110 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1112 2021-03-02 Daniel Axtens <dja@axtens.net>
1114 fs/sfs: Fix over-read of root object name
1115 There's a read of the name of the root object that assumes that the name
1116 is nul-terminated within the root block. This isn't guaranteed - it seems
1117 SFS would require you to read multiple blocks to get a full name in general,
1118 but maybe that doesn't apply to the root object.
1120 Either way, figure out how much space is left in the root block and don't
1121 over-read it. This fixes some OOB reads.
1123 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1125 2021-03-02 Daniel Axtens <dja@axtens.net>
1127 fs/hfs: Disable under lockdown
1128 HFS has issues such as infinite mutual recursion that are simply too
1129 complex to fix for such a legacy format. So simply do not permit
1130 it to be loaded under lockdown.
1132 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1134 2021-03-02 Daniel Axtens <dja@axtens.net>
1136 fs/hfsplus: Don't use uninitialized data on corrupt filesystems
1137 Valgrind identified the following use of uninitialized data:
1139 ==2782220== Conditional jump or move depends on uninitialised value(s)
1140 ==2782220== at 0x42B364: grub_hfsplus_btree_search (hfsplus.c:566)
1141 ==2782220== by 0x42B21D: grub_hfsplus_read_block (hfsplus.c:185)
1142 ==2782220== by 0x42A693: grub_fshelp_read_file (fshelp.c:386)
1143 ==2782220== by 0x42C598: grub_hfsplus_read_file (hfsplus.c:219)
1144 ==2782220== by 0x42C598: grub_hfsplus_mount (hfsplus.c:330)
1145 ==2782220== by 0x42B8C5: grub_hfsplus_dir (hfsplus.c:958)
1146 ==2782220== by 0x4C1AE6: grub_fs_probe (fs.c:73)
1147 ==2782220== by 0x407C94: grub_ls_list_files (ls.c:186)
1148 ==2782220== by 0x407C94: grub_cmd_ls (ls.c:284)
1149 ==2782220== by 0x4D7130: grub_extcmd_dispatcher (extcmd.c:55)
1150 ==2782220== by 0x4045A6: execute_command (grub-fstest.c:59)
1151 ==2782220== by 0x4045A6: fstest (grub-fstest.c:433)
1152 ==2782220== by 0x4045A6: main (grub-fstest.c:772)
1153 ==2782220== Uninitialised value was created by a heap allocation
1154 ==2782220== at 0x483C7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
1155 ==2782220== by 0x4C0305: grub_malloc (mm.c:42)
1156 ==2782220== by 0x42C21D: grub_hfsplus_mount (hfsplus.c:239)
1157 ==2782220== by 0x42B8C5: grub_hfsplus_dir (hfsplus.c:958)
1158 ==2782220== by 0x4C1AE6: grub_fs_probe (fs.c:73)
1159 ==2782220== by 0x407C94: grub_ls_list_files (ls.c:186)
1160 ==2782220== by 0x407C94: grub_cmd_ls (ls.c:284)
1161 ==2782220== by 0x4D7130: grub_extcmd_dispatcher (extcmd.c:55)
1162 ==2782220== by 0x4045A6: execute_command (grub-fstest.c:59)
1163 ==2782220== by 0x4045A6: fstest (grub-fstest.c:433)
1164 ==2782220== by 0x4045A6: main (grub-fstest.c:772)
1166 This happens when the process of reading the catalog file goes sufficiently
1167 wrong that there's an attempt to read the extent overflow file, which has
1168 not yet been loaded. Keep track of when the extent overflow file is
1169 fully loaded and refuse to use it before then.
1171 The load valgrind doesn't like is btree->nodesize, and that's then used
1172 to allocate a data structure. It looks like there are subsequently a lot
1173 of reads based on that pointer so OOB reads are likely, and indeed crashes
1174 (albeit difficult-to-replicate ones) have been observed in fuzzing.
1176 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1178 2021-03-02 Daniel Axtens <dja@axtens.net>
1180 fs/hfsplus: Don't fetch a key beyond the end of the node
1181 Otherwise you get a wild pointer, leading to a bunch of invalid reads.
1182 Check it falls inside the given node.
1184 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1186 2021-03-02 Daniel Axtens <dja@axtens.net>
1188 fs/fshelp: Catch impermissibly large block sizes in read helper
1189 A fuzzed HFS+ filesystem had log2blocksize = 22. This gave
1190 log2blocksize + GRUB_DISK_SECTOR_BITS = 31. 1 << 31 = 0x80000000,
1191 which is -1 as an int. This caused some wacky behavior later on in
1192 the function, leading to out-of-bounds writes on the destination buffer.
1194 Catch log2blocksize + GRUB_DISK_SECTOR_BITS >= 31. We could be stricter,
1195 but this is the minimum that will prevent integer size weirdness.
1197 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1199 2021-03-02 Daniel Axtens <dja@axtens.net>
1201 term/gfxterm: Don't set up a font with glyphs that are too big
1202 Catch the case where we have a font so big that it causes the number of
1203 rows or columns to be 0. Currently we continue and allocate a
1204 virtual_screen.text_buffer of size 0. We then try to use that for glpyhs
1205 and things go badly.
1207 On the emu platform, malloc() may give us a valid pointer, in which case
1208 we'll access heap memory which we shouldn't. Alternatively, it may give us
1209 NULL, in which case we'll crash. For other platforms, if I understand
1210 grub_memalign() correctly, we will receive a valid but small allocation
1211 that we will very likely later overrun.
1213 Prevent the creation of a virtual screen that isn't at least 40 cols
1214 by 12 rows. This is arbitrary, but it seems that if your width or height
1215 is half a standard 80x24 terminal, you're probably going to struggle to
1216 read anything anyway.
1218 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1220 2021-03-02 Daniel Axtens <dja@axtens.net>
1222 video/readers/jpeg: Don't decode data before start of stream
1223 When a start of stream marker is encountered, we call grub_jpeg_decode_sos()
1224 which allocates space for a bitmap.
1226 When a restart marker is encountered, we call grub_jpeg_decode_data() which
1227 then fills in that bitmap.
1229 If we get a restart marker before the start of stream marker, we will
1230 attempt to write to a bitmap_ptr that hasn't been allocated. Catch this
1231 and bail out. This fixes an attempt to write to NULL.
1233 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1235 2021-03-02 Daniel Axtens <dja@axtens.net>
1237 video/readers/jpeg: Catch OOB reads/writes in grub_jpeg_decode_du()
1240 du[jpeg_zigzag_order[pos]] = val * (int) data->quan_table[qt][pos];
1242 jpeg_zigzag_order is grub_uint8_t[64].
1244 I don't understand JPEG decoders quite well enough to explain what's
1245 going on here. However, I observe sometimes pos=64, which leads to an
1246 OOB read of the jpeg_zigzag_order global then an OOB write to du.
1247 That leads to various unpleasant memory corruption conditions.
1249 Catch where pos >= ARRAY_SIZE(jpeg_zigzag_order) and bail.
1251 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1253 2021-03-02 Daniel Axtens <dja@axtens.net>
1255 video/readers/jpeg: Catch files with unsupported quantization or Huffman tables
1256 Our decoder only supports 2 quantization tables. If a file asks for
1257 a quantization table with index > 1, reject it.
1259 Similarly, our decoder only supports 4 Huffman tables. If a file asks
1260 for a Huffman table with index > 3, reject it.
1262 This fixes some out of bounds reads. It's not clear what degree of control
1263 over subsequent execution could be gained by someone who can carefully
1264 set up the contents of memory before loading an invalid JPEG file.
1266 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1268 2021-03-02 Daniel Axtens <dja@axtens.net>
1270 kern/misc: Always set *end in grub_strtoull()
1271 Currently, if there is an error in grub_strtoull(), *end is not set.
1272 This differs from the usual behavior of strtoull(), and also means that
1273 some callers may use an uninitialized value for *end.
1275 Set *end unconditionally.
1277 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1279 2021-03-02 Daniel Axtens <dja@axtens.net>
1281 commands/menuentry: Fix quoting in setparams_prefix()
1282 Commit 9acdcbf32542 (use single quotes in menuentry setparams command)
1283 says that expressing a quoted single quote will require 3 characters. It
1284 actually requires (and always did require!) 4 characters:
1287 len: 3 => 6 (2 for the letters + 4 for the quote)
1289 This leads to not allocating enough memory and thus out of bounds writes
1290 that have been observed to cause heap corruption.
1292 Allocate 4 bytes for each single quote.
1294 Commit 22e7dbb2bb81 (Fix quoting in legacy parser.) does the same
1295 quoting, but it adds 3 as extra overhead on top of the single byte that
1296 the quote already needs. So it's correct.
1298 Fixes: 9acdcbf32542 (use single quotes in menuentry setparams command)
1299 Fixes: CVE-2021-20233
1301 Reported-by: Daniel Axtens <dja@axtens.net>
1302 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1304 2021-03-02 Daniel Axtens <dja@axtens.net>
1306 script/execute: Don't crash on a "for" loop with no items
1307 The following crashes the parser:
1313 This is because grub_script_arglist_to_argv() doesn't consider the
1314 possibility that arglist is NULL. Catch that explicitly.
1316 This avoids a NULL pointer dereference.
1318 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1320 2021-03-02 Daniel Axtens <dja@axtens.net>
1322 lib/arg: Block repeated short options that require an argument
1323 Fuzzing found the following crash:
1325 search -hhhhhhhhhhhhhf
1327 We didn't allocate enough option space for 13 hints because the
1328 allocation code counts the number of discrete arguments (i.e. argc).
1329 However, the shortopt parsing code will happily keep processing
1330 a combination of short options without checking if those short
1331 options require an argument. This means you can easily end writing
1332 past the allocated option space.
1334 This fixes a OOB write which can cause heap corruption.
1336 Fixes: CVE-2021-20225
1338 Reported-by: Daniel Axtens <dja@axtens.net>
1339 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1341 2021-03-02 Daniel Axtens <dja@axtens.net>
1343 script/execute: Avoid crash when using "$#" outside a function scope
1344 "$#" represents the number of arguments to a function. It is only
1345 defined in a function scope, where "scope" is non-NULL. Currently,
1346 if we attempt to evaluate "$#" outside a function scope, "scope" will
1347 be NULL and we will crash with a NULL pointer dereference.
1349 Do not attempt to count arguments for "$#" if "scope" is NULL. This
1350 will result in "$#" being interpreted as an empty string if evaluated
1351 outside a function scope.
1353 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1355 2021-03-02 Daniel Axtens <dja@axtens.net>
1357 commands/ls: Require device_name is not NULL before printing
1358 This can be triggered with:
1360 and causes a NULL deref in grub_normal_print_device_info().
1362 I'm not sure if there's any implication with the IEEE 1275 platform.
1364 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1366 2021-03-02 Daniel Axtens <dja@axtens.net>
1368 script/execute: Fix NULL dereference in grub_script_execute_cmdline()
1369 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1371 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1373 util/glue-efi: Fix incorrect use of a possibly negative value
1374 It is possible for the ftell() function to return a negative value,
1375 although it is fairly unlikely here, we should be checking for
1376 a negative value before we assign it to an unsigned value.
1380 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1382 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1384 util/grub-editenv: Fix incorrect casting of a signed value
1385 The return value of ftell() may be negative (-1) on error. While it is
1386 probably unlikely to occur, we should not blindly cast to an unsigned
1387 value without first testing that it is not negative.
1391 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1393 2021-03-02 Daniel Kiper <daniel.kiper@oracle.com>
1395 util/grub-install: Fix NULL pointer dereferences
1396 Two grub_device_open() calls does not have associated NULL checks
1397 for returned values. Fix that and appease the Coverity.
1401 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
1403 2021-03-02 Paulo Flabiano Smorigo <pfsmorigo@canonical.com>
1405 loader/xnu: Check if pointer is NULL before using it
1408 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1410 2021-03-02 Marco A Benatto <mbenatto@redhat.com>
1412 loader/xnu: Free driverkey data when an error is detected in grub_xnu_writetree_toheap()
1413 ... to avoid memory leaks.
1417 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1419 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1421 loader/xnu: Fix memory leak
1422 The code here is finished with the memory stored in name, but it only
1423 frees it if there curvalue is valid, while it could actually free it
1426 The fix is a simple relocation of the grub_free() to before the test
1431 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1433 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1435 loader/bsd: Check for NULL arg up-front
1436 The code in the next block suggests that it is possible for .set to be
1437 true but .arg may still be NULL.
1439 This code assumes that it is never NULL, yet later is testing if it is
1440 NULL - that is inconsistent.
1442 So we should check first if .arg is not NULL, and remove this check that
1443 is being flagged by Coverity since it is no longer required.
1447 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1449 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1451 gfxmenu/gui_list: Remove code that coverity is flagging as dead
1452 The test of value for NULL before calling grub_strdup() is not required,
1453 since the if condition prior to this has already tested for value being
1454 NULL and cannot reach this code if it is.
1458 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1460 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1462 video/readers/jpeg: Test for an invalid next marker reference from a jpeg file
1463 While it may never happen, and potentially could be caught at the end of
1464 the function, it is worth checking up front for a bad reference to the
1465 next marker just in case of a maliciously crafted file being provided.
1469 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1471 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1473 video/fb/video_fb: Fix possible integer overflow
1474 It is minimal possibility that the values being used here will overflow.
1475 So, change the code to use the safemath function grub_mul() to ensure
1476 that doesn't happen.
1480 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1482 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1484 video/fb/video_fb: Fix multiple integer overflows
1485 The calculation of the unsigned 64-bit value is being generated by
1486 multiplying 2, signed or unsigned, 32-bit integers which may overflow
1487 before promotion to unsigned 64-bit. Fix all of them.
1489 Fixes: CID 73703, CID 73767, CID 73833
1491 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1493 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1495 video/fb/fbfill: Fix potential integer overflow
1496 The multiplication of 2 unsigned 32-bit integers may overflow before
1497 promotion to unsigned 64-bit. We should ensure that the multiplication
1498 is done with overflow detection. Additionally, use grub_sub() for
1501 Fixes: CID 73640, CID 73697, CID 73702, CID 73823
1503 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1505 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1507 video/efi_gop: Remove unnecessary return value of grub_video_gop_fill_mode_info()
1508 The return value of grub_video_gop_fill_mode_info() is never able to be
1509 anything other than GRUB_ERR_NONE. So, rather than continue to return
1510 a value and checking it each time, it is more correct to redefine the
1511 function to not return anything and remove checks of its return value
1516 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1518 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1520 commands/probe: Fix a resource leak when probing disks
1521 Every other return statement in this code is calling grub_device_close()
1522 to clean up dev before returning. This one should do that too.
1526 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1528 2021-03-02 Chris Coulson <chris.coulson@canonical.com>
1530 commands/hashsum: Fix a memory leak
1531 check_list() uses grub_file_getline(), which allocates a buffer.
1532 If the hash list file contains invalid lines, the function leaks
1533 this buffer when it returns an error.
1537 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1539 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1541 normal/completion: Fix leaking of memory when processing a completion
1542 It is possible for the code to reach the end of the function without
1543 freeing the memory allocated to argv and argc still to be 0.
1545 We should always call grub_free(argv). The grub_free() will handle
1546 a NULL argument correctly if it reaches that code without the memory
1551 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1553 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1555 syslinux: Fix memory leak while parsing
1556 In syslinux_parse_real() the 2 points where return is being called
1557 didn't release the memory stored in buf which is no longer required.
1561 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1563 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1565 libgcrypt/mpi: Fix possible NULL dereference
1566 The code in gcry_mpi_scan() assumes that buffer is not NULL, but there
1567 is no explicit check for that, so we add one.
1571 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1573 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1575 libgcrypt/mpi: Fix possible unintended sign extension
1576 The array of unsigned char gets promoted to a signed 32-bit int before
1577 it is finally promoted to a size_t. There is the possibility that this
1578 may result in the signed-bit being set for the intermediate signed
1579 32-bit int. We should ensure that the promotion is to the correct type
1580 before we bitwise-OR the values.
1584 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1586 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1588 affs: Fix memory leaks
1589 The node structure reference is being allocated but not freed if it
1590 reaches the end of the function. If any of the hooks had returned
1591 a non-zero value, then node would have been copied in to the context
1592 reference, but otherwise node is not stored and should be freed.
1594 Similarly, the call to grub_affs_create_node() replaces the allocated
1595 memory in node with a newly allocated structure, leaking the existing
1596 memory pointed by node.
1598 Finally, when dir->parent is set, then we again replace node with newly
1599 allocated memory, which seems unnecessary when we copy in the values
1600 from dir->parent immediately after.
1604 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1606 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1608 zfsinfo: Correct a check for error allocating memory
1609 While arguably the check for grub_errno is correct, we should really be
1610 checking the return value from the function since it is always possible
1611 that grub_errno was set elsewhere, making this code behave incorrectly.
1615 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1617 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1619 zfs: Fix possible integer overflows
1620 In all cases the problem is that the value being acted upon by
1621 a left-shift is a 32-bit number which is then being used in the
1622 context of a 64-bit number.
1624 To avoid overflow we ensure that the number being shifted is 64-bit
1625 before the shift is done.
1627 Fixes: CID 73684, CID 73695, CID 73764
1629 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1631 2021-03-02 Paulo Flabiano Smorigo <pfsmorigo@canonical.com>
1633 zfs: Fix resource leaks while constructing path
1634 There are several exit points in dnode_get_path() that are causing possible
1637 In the while(1) the correct exit mechanism should not be to do a direct return,
1638 but to instead break out of the loop, setting err first if it is not already set.
1640 The reason behind this is that the dnode_path is a linked list, and while doing
1641 through this loop, it is being allocated and built up - the only way to
1642 correctly unravel it is to traverse it, which is what is being done at the end
1643 of the function outside of the loop.
1645 Several of the existing exit points correctly did a break, but not all so this
1646 change makes that more consistent and should resolve the leaking of memory as
1651 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1653 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1655 zfs: Fix possible negative shift operation
1656 While it is possible for the return value from zfs_log2() to be zero
1657 (0), it is quite unlikely, given that the previous assignment to blksz
1658 is shifted up by SPA_MINBLOCKSHIFT (9) before 9 is subtracted at the
1661 But, while unlikely during a normal operation, it may be that a carefully
1662 crafted ZFS filesystem could result in a zero (0) value to the
1663 dn_datalbkszsec field, which means that the shift left does nothing
1664 and assigns zero (0) to blksz, resulting in a negative epbs value.
1668 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1670 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1672 hfsplus: Check that the volume name length is valid
1673 HFS+ documentation suggests that the maximum filename and volume name is
1674 255 Unicode characters in length.
1676 So, when converting from big-endian to little-endian, we should ensure
1677 that the name of the volume has a length that is between 0 and 255,
1682 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1684 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1686 disk/cryptodisk: Fix potential integer overflow
1687 The encrypt and decrypt functions expect a grub_size_t. So, we need to
1688 ensure that the constant bit shift is using grub_size_t rather than
1689 unsigned int when it is performing the shift.
1693 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1695 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1697 disk/ldm: Fix memory leak on uninserted lv references
1698 The problem here is that the memory allocated to the variable lv is not
1699 yet inserted into the list that is being processed at the label fail2.
1701 As we can already see at line 342, which correctly frees lv before going
1702 to fail2, we should also be doing that at these earlier jumps to fail2.
1706 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1708 2021-03-02 Paulo Flabiano Smorigo <pfsmorigo@canonical.com>
1710 disk/ldm: If failed then free vg variable too
1713 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1715 2021-03-02 Marco A Benatto <mbenatto@redhat.com>
1717 disk/ldm: Make sure comp data is freed before exiting from make_vg()
1718 Several error handling paths in make_vg() do not free comp data before
1719 jumping to fail2 label and returning from the function. This will leak
1720 memory. So, let's fix all issues of that kind.
1724 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1726 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1728 kern/partition: Check for NULL before dereferencing input string
1729 There is the possibility that the value of str comes from an external
1730 source and continuing to use it before ever checking its validity is
1731 wrong. So, needs fixing.
1733 Additionally, drop unneeded part initialization.
1737 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1739 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1741 zstd: Initialize seq_t structure fully
1742 While many compilers will initialize this to zero, not all will, so it
1743 is better to be sure that fields not being explicitly set are at known
1744 values, and there is code that checks this fields value elsewhere in the
1749 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1751 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1753 io/lzopio: Resolve unnecessary self-assignment errors
1754 These 2 assignments are unnecessary since they are just assigning
1759 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1761 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1763 gnulib/regcomp: Fix uninitialized re_token
1764 This issue has been fixed in the latest version of gnulib, so to
1765 maintain consistency, I've backported that change rather than doing
1766 something different.
1770 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1772 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1774 gnulib/regexec: Fix possible null-dereference
1775 It appears to be possible that the mctx->state_log field may be NULL,
1776 and the name of this function, clean_state_log_if_needed(), suggests
1777 that it should be checking that it is valid to be cleaned before
1778 assuming that it does.
1782 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1784 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1786 gnulib/argp-help: Fix dereference of a possibly NULL state
1787 All other instances of call to __argp_failure() where there is
1788 a dgettext() call is first checking whether state is NULL before
1789 attempting to dereference it to get the root_argp->argp_domain.
1793 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1795 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1797 gnulib/regcomp: Fix uninitialized token structure
1798 The code is assuming that the value of br_token.constraint was
1799 initialized to zero when it wasn't.
1801 While some compilers will ensure that, not all do, so it is better to
1802 fix this explicitly than leave it to chance.
1806 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1808 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1810 gnulib/regexec: Resolve unused variable
1811 This is a really minor issue where a variable is being assigned to but
1812 not checked before it is overwritten again.
1814 The reason for this issue is that we are not building with DEBUG set and
1815 this in turn means that the assert() that reads the value of the
1816 variable match_last is being processed out.
1818 The solution, move the assignment to match_last in to an ifdef DEBUG too.
1822 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1824 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1826 kern/efi/mm: Fix possible NULL pointer dereference
1827 The model of grub_efi_get_memory_map() is that if memory_map is NULL,
1828 then the purpose is to discover how much memory should be allocated to
1829 it for the subsequent call.
1831 The problem here is that with grub_efi_is_finished set to 1, there is no
1832 check at all that the function is being called with a non-NULL memory_map.
1834 While this MAY be true, we shouldn't assume it.
1836 The solution to this is to behave as expected, and if memory_map is NULL,
1837 then don't try to use it and allow memory_map_size to be filled in, and
1838 return 0 as is done later in the code if the buffer is too small (or NULL).
1840 Additionally, drop unneeded ret = 1.
1844 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1846 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1848 kern/efi: Fix memory leak on failure
1849 Free the memory allocated to name before returning on failure.
1853 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1855 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1857 kern/parser: Fix resource leak if argc == 0
1858 After processing the command-line yet arriving at the point where we are
1859 setting argv, we are allocating memory, even if argc == 0, which makes
1860 no sense since we never put anything into the allocated argv.
1862 The solution is to simply return that we've successfully processed the
1863 arguments but that argc == 0, and also ensure that argv is NULL when
1864 we're not allocating anything in it.
1866 There are only 2 callers of this function, and both are handling a zero
1867 value in argc assuming nothing is allocated in argv.
1871 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1873 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1875 net/tftp: Fix dangling memory pointer
1876 The static code analysis tool, Parfait, reported that the valid of
1877 file->data was left referencing memory that was freed by the call to
1878 grub_free(data) where data was initialized from file->data.
1880 To ensure that there is no unintentional access to this memory
1881 referenced by file->data we should set the pointer to NULL.
1883 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1885 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1887 net/net: Fix possible dereference to of a NULL pointer
1888 It is always possible that grub_zalloc() could fail, so we should check for
1889 a NULL return. Otherwise we run the risk of dereferencing a NULL pointer.
1893 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1895 2021-03-02 Darren Kenny <darren.kenny@oracle.com>
1897 mmap: Fix memory leak when iterating over mapped memory
1898 When returning from grub_mmap_iterate() the memory allocated to present
1899 is not being released causing it to leak.
1903 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1905 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
1907 usb: Avoid possible out-of-bound accesses caused by malicious devices
1908 The maximum number of configurations and interfaces are fixed but there is
1909 no out-of-bound checking to prevent a malicious USB device to report large
1910 values for these and cause accesses outside the arrays' memory.
1912 Fixes: CVE-2020-25647
1914 Reported-by: Joseph Tartaro <joseph.tartaro@ioactive.com>
1915 Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
1916 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1918 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
1920 dl: Only allow unloading modules that are not dependencies
1921 When a module is attempted to be removed its reference counter is always
1922 decremented. This means that repeated rmmod invocations will cause the
1923 module to be unloaded even if another module depends on it.
1925 This may lead to a use-after-free scenario allowing an attacker to execute
1926 arbitrary code and by-pass the UEFI Secure Boot protection.
1928 While being there, add the extern keyword to some function declarations in
1931 Fixes: CVE-2020-25632
1933 Reported-by: Chris Coulson <chris.coulson@canonical.com>
1934 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1936 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
1938 docs: Document the cutmem command
1939 The command is not present in the docs/grub.texi user documentation.
1941 Reported-by: Daniel Kiper <daniel.kiper@oracle.com>
1942 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
1944 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
1946 loader/xnu: Don't allow loading extension and packages when locked down
1947 The shim_lock verifier validates the XNU kernels but no its extensions
1948 and packages. Prevent these to be loaded when the GRUB is locked down.
1950 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1952 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
1954 gdb: Restrict GDB access when locked down
1955 The gdbstub* commands allow to start and control a GDB stub running on
1956 local host that can be used to connect from a remote debugger. Restrict
1957 this functionality when the GRUB is locked down.
1959 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1961 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
1963 commands/hdparm: Restrict hdparm command when locked down
1964 The command can be used to get/set ATA disk parameters. Some of these can
1965 be dangerous since change the disk behavior. Restrict it when locked down.
1967 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1969 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
1971 commands/setpci: Restrict setpci command when locked down
1972 This command can set PCI devices register values, which makes it dangerous
1973 in a locked down configuration. Restrict it so can't be used on this setup.
1975 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1977 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
1979 commands: Restrict commands that can load BIOS or DT blobs when locked down
1980 There are some more commands that should be restricted when the GRUB is
1981 locked down. Following is the list of commands and reasons to restrict:
1983 * fakebios: creates BIOS-like structures for backward compatibility with
1984 existing OSes. This should not be allowed when locked down.
1986 * loadbios: reads a BIOS dump from storage and loads it. This action
1987 should not be allowed when locked down.
1989 * devicetree: loads a Device Tree blob and passes it to the OS. It replaces
1990 any Device Tree provided by the firmware. This also should
1991 not be allowed when locked down.
1993 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
1995 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
1997 mmap: Don't register cutmem and badram commands when lockdown is enforced
1998 The cutmem and badram commands can be used to remove EFI memory regions
1999 and potentially disable the UEFI Secure Boot. Prevent the commands to be
2000 registered if the GRUB is locked down.
2002 Fixes: CVE-2020-27779
2004 Reported-by: Teddy Reed <teddy.reed@gmail.com>
2005 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2007 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
2009 acpi: Don't register the acpi command when locked down
2010 The command is not allowed when lockdown is enforced. Otherwise an
2011 attacker can instruct the GRUB to load an SSDT table to overwrite
2012 the kernel lockdown configuration and later load and execute
2015 Fixes: CVE-2020-14372
2017 Reported-by: Máté Kukri <km@mkukri.xyz>
2018 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
2022 efi: Use grub_is_lockdown() instead of hardcoding a disabled modules list
2023 Now the GRUB can check if it has been locked down and this can be used to
2024 prevent executing commands that can be utilized to circumvent the UEFI
2025 Secure Boot mechanisms. So, instead of hardcoding a list of modules that
2026 have to be disabled, prevent the usage of commands that can be dangerous.
2028 This not only allows the commands to be disabled on other platforms, but
2029 also properly separate the concerns. Since the shim_lock verifier logic
2030 should be only about preventing to run untrusted binaries and not about
2031 defining these kind of policies.
2033 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2035 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
2037 efi: Lockdown the GRUB when the UEFI Secure Boot is enabled
2038 If the UEFI Secure Boot is enabled then the GRUB must be locked down
2039 to prevent executing code that can potentially be used to subvert its
2040 verification mechanisms.
2042 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2044 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
2046 kern/lockdown: Set a variable if the GRUB is locked down
2047 It may be useful for scripts to determine whether the GRUB is locked
2048 down or not. Add the lockdown variable which is set to "y" when the GRUB
2051 Suggested-by: Dimitri John Ledkov <xnox@ubuntu.com>
2052 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2054 2021-03-02 Javier Martinez Canillas <javierm@redhat.com>
2056 kern: Add lockdown support
2057 When the GRUB starts on a secure boot platform, some commands can be
2058 used to subvert the protections provided by the verification mechanism and
2059 could lead to booting untrusted system.
2061 To prevent that situation, allow GRUB to be locked down. That way the code
2062 may check if GRUB has been locked down and further restrict the commands
2063 that are registered or what subset of their functionality could be used.
2065 The lockdown support adds the following components:
2067 * The grub_lockdown() function which can be used to lockdown GRUB if,
2068 e.g., UEFI Secure Boot is enabled.
2070 * The grub_is_lockdown() function which can be used to check if the GRUB
2073 * A verifier that flags OS kernels, the GRUB modules, Device Trees and ACPI
2074 tables as GRUB_VERIFY_FLAGS_DEFER_AUTH to defer verification to other
2075 verifiers. These files are only successfully verified if another registered
2076 verifier returns success. Otherwise, the whole verification process fails.
2078 For example, PE/COFF binaries verification can be done by the shim_lock
2079 verifier which validates the signatures using the shim_lock protocol.
2080 However, the verification is not deferred directly to the shim_lock verifier.
2081 The shim_lock verifier is hooked into the verification process instead.
2083 * A set of grub_{command,extcmd}_lockdown functions that can be used by
2084 code registering command handlers, to only register unsafe commands if
2085 the GRUB has not been locked down.
2087 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2089 2021-03-02 Marco A Benatto <mbenatto@redhat.com>
2091 efi: Move the shim_lock verifier to the GRUB core
2092 Move the shim_lock verifier from its own module into the core image. The
2093 Secure Boot lockdown mechanism has the intent to prevent the load of any
2094 unsigned code or binary when Secure Boot is enabled.
2096 The reason is that GRUB must be able to prevent executing untrusted code
2097 if UEFI Secure Boot is enabled, without depending on external modules.
2099 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2101 2021-03-02 Marco A Benatto <mbenatto@redhat.com>
2103 verifiers: Move verifiers API to kernel image
2104 Move verifiers API from a module to the kernel image, so it can be
2105 used there as well. There are no functional changes in this patch.
2107 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2109 2020-12-18 Glenn Washburn <development@efficientek.com>
2111 docs: Add documentation of disk size limitations
2112 Document the artificially imposed 1 EiB disk size limit and size limitations
2115 Fix a few punctuation issues.
2117 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2119 2020-12-18 Glenn Washburn <development@efficientek.com>
2121 luks2: Use grub_log2ull() to calculate log_sector_size and improve readability
2122 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2124 misc: Add grub_log2ull() macro for calculating log base 2 of 64-bit integers
2125 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2127 2020-12-18 Glenn Washburn <development@efficientek.com>
2129 mips: Enable __clzdi2()
2130 This patch is similar to commit 9dab2f51e (sparc: Enable __clzsi2() and
2131 __clzdi2()) but for MIPS target and __clzdi2() only, __clzsi2() was
2134 Suggested-by: Daniel Kiper <dkiper@net-space.pl>
2135 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2137 2020-12-18 Glenn Washburn <development@efficientek.com>
2139 luks2: Better error handling when setting up the cryptodisk
2140 Do some sanity checking on data coming from the LUKS2 header. If segment.size
2141 is "dynamic", verify that the offset is not past the end of disk. Otherwise,
2142 check for errors from grub_strtoull() when converting segment size from
2143 string. If a GRUB_ERR_BAD_NUMBER error was returned, then the string was
2144 not a valid parsable number, so skip the key. If GRUB_ERR_OUT_OF_RANGE was
2145 returned, then there was an overflow in converting to a 64-bit unsigned
2146 integer. So this could be a very large disk (perhaps large RAID array).
2147 In this case skip the key too. Additionally, enforce some other limits
2150 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2152 2020-12-18 Glenn Washburn <development@efficientek.com>
2154 luks2: Do not handle disks of size GRUB_DISK_SIZE_UNKNOWN for now
2155 Check to make sure that source disk has a known size. If not, print
2156 a message and return error. There are 4 cases where GRUB_DISK_SIZE_UNKNOWN
2157 is set (biosdisk, obdisk, ofdisk, and uboot), and in all those cases
2158 processing continues. So this is probably a bit conservative. However,
2159 3 of the cases seem pathological, and the other, biosdisk, happens when
2160 booting from a CD-ROM. Since I doubt booting from a LUKS2 volume on
2161 a CD-ROM is a big use case, we'll error until someone complains.
2163 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2165 2020-12-18 Glenn Washburn <development@efficientek.com>
2167 luks2: Convert to crypt sectors from GRUB native sectors
2168 The function grub_disk_native_sectors(source) returns the number of sectors
2169 of source in GRUB native (512-byte) sectors, not source sized sectors. So
2170 the conversion needs to use GRUB_DISK_SECTOR_BITS, the GRUB native sector
2173 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2175 2020-12-12 Glenn Washburn <development@efficientek.com>
2177 luks2: Error check segment.sector_size
2178 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2180 2020-12-12 Glenn Washburn <development@efficientek.com>
2182 cryptodisk: Properly handle non-512 byte sized sectors
2183 By default, dm-crypt internally uses an IV that corresponds to 512-byte
2184 sectors, even when a larger sector size is specified. What this means is
2185 that when using a larger sector size, the IV is incremented every sector.
2186 However, the amount the IV is incremented is the number of 512 byte blocks
2187 in a sector (i.e. 8 for 4K sectors). Confusingly the IV does not correspond
2188 to the number of, for example, 4K sectors. So each 512 byte cipher block in
2189 a sector will be encrypted with the same IV and the IV will be incremented
2190 afterwards by the number of 512 byte cipher blocks in the sector.
2192 There are some encryption utilities which do it the intuitive way and have
2193 the IV equal to the sector number regardless of sector size (ie. the fifth
2194 sector would have an IV of 4 for each cipher block). And this is supported
2195 by dm-crypt with the iv_large_sectors option and also cryptsetup as of 2.3.3
2196 with the --iv-large-sectors, though not with LUKS headers (only with --type
2197 plain). However, support for this has not been included as grub does not
2198 support plain devices right now.
2200 One gotcha here is that the encrypted split keys are encrypted with a hard-
2201 coded 512-byte sector size. So even if your data is encrypted with 4K sector
2202 sizes, the split key encrypted area must be decrypted with a block size of
2203 512 (ie the IV increments every 512 bytes). This made these changes less
2204 aesthetically pleasing than desired.
2206 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2208 2020-12-12 Glenn Washburn <development@efficientek.com>
2210 luks2: grub_cryptodisk_t->total_sectors is the max number of device native sectors
2211 We need to convert the sectors from the size of the underlying device to the
2212 cryptodisk sector size; segment.size is in bytes which need to be converted
2213 to cryptodisk sectors as well.
2215 Also, removed an empty statement.
2217 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2219 2020-12-12 Glenn Washburn <development@efficientek.com>
2221 cryptodisk: Add macros GRUB_TYPE_U_MAX/MIN(type) to replace literals
2222 Add GRUB_TYPE_U_MAX/MIN(type) macros to get the max/min values for an
2223 unsigned number with size of type.
2225 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2227 2020-12-12 Glenn Washburn <development@efficientek.com>
2229 cryptodisk: Add macro GRUB_TYPE_BITS() to replace some literals
2230 The new macro GRUB_TYPE_BITS(type) returns the number of bits
2233 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2235 2020-12-12 Glenn Washburn <development@efficientek.com>
2237 luks2: Add string "index" to user strings using a json index
2238 This allows error messages to be more easily distinguishable between indexes
2239 and slot keys. The former include the string "index" in the error/debug
2240 string, and the later are surrounded in quotes.
2242 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2244 2020-12-12 Glenn Washburn <development@efficientek.com>
2246 luks2: Rename json index variables to names that they are obviously json indexes
2247 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2249 2020-12-12 Glenn Washburn <development@efficientek.com>
2251 luks2: Use more intuitive object name instead of json index in user messages
2252 Use the object name in the json array rather than the 0 based index in the
2253 json array for keyslots, segments, and digests. This is less confusing for
2254 the end user. For example, say you have a LUKS2 device with a key in slot 1
2255 and slot 4. When using the password for slot 4 to unlock the device, the
2256 messages using the index of the keyslot will mention keyslot 1 (its a
2257 zero-based index). Furthermore, with this change the keyslot number will
2258 align with the number used to reference the keyslot when using the
2259 --key-slot argument to cryptsetup.
2261 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2263 2020-12-12 Glenn Washburn <development@efficientek.com>
2265 luks2: Add idx member to struct grub_luks2_keyslot/segment/digest
2266 This allows code using these structs to know the named key associated with
2267 these json data structures. In the future we can use these to provide better
2268 error messages to the user.
2270 Get rid of idx local variable in luks2_get_keyslot() which was overloaded to
2271 be used for both keyslot and segment slot keys.
2273 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2275 2020-12-12 Glenn Washburn <development@efficientek.com>
2277 luks2: Make sure all fields of output argument in luks2_parse_digest() are written to
2278 We should assume that the output argument "out" is uninitialized and could
2279 have random data. So, make sure to initialize the segments and keyslots bit
2280 fields because potentially not all bits of those fields are written to.
2281 Otherwise, the digest could say it belongs to keyslots and segments that it
2284 Reviewed-by: Patrick Steinhardt <ps@pks.im>
2285 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2287 2020-12-12 Glenn Washburn <development@efficientek.com>
2289 luks2: Remove unused argument in grub_error() call
2290 Reviewed-by: Patrick Steinhardt <ps@pks.im>
2291 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2293 luks2: Convert 8 spaces to tabs
2294 Reviewed-by: Patrick Steinhardt <ps@pks.im>
2295 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2297 2020-12-12 Glenn Washburn <development@efficientek.com>
2299 misc: Add parentheses around ALIGN_UP() and ALIGN_DOWN() arguments
2300 This ensures that expected order of operations is preserved when arguments
2303 Reviewed-by: Patrick Steinhardt <ps@pks.im>
2304 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2306 2020-12-12 Glenn Washburn <development@efficientek.com>
2308 disk: Rename grub_disk_get_size() to grub_disk_native_sectors()
2309 The function grub_disk_get_size() is confusingly named because it actually
2310 returns a sector count where the sectors are sized in the GRUB native sector
2311 size. Rename to something more appropriate.
2313 Suggested-by: Daniel Kiper <daniel.kiper@oracle.com>
2314 Reviewed-by: Patrick Steinhardt <ps@pks.im>
2315 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2317 2020-12-12 Glenn Washburn <development@efficientek.com>
2319 loopback: Do not automaticaly replace existing loopback dev, error instead
2320 If there is a loopback device with the same name as the one to be created,
2321 instead of closing the old one and replacing it with the new one, return an
2322 error instead. If the loopback device was created, its probably being used
2323 by something and just replacing it may cause GRUB to crash unexpectedly.
2324 This fixes obvious problems like "loopback d (d)/somefile". Its not too
2325 onerous to force the user to delete the loopback first with the "-d" switch.
2327 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2329 2020-12-12 Glenn Washburn <development@efficientek.com>
2331 disk: Move hardcoded max disk size literal to a GRUB_DISK_MAX_SECTORS in disk.h
2332 There is a hardcoded maximum disk size that can be read or written from,
2333 currently set at 1 EiB in grub_disk_adjust_range(). Move the literal into a
2334 macro in disk.h, so our assumptions are more visible. This hard coded limit
2335 does not prevent using larger disks, just GRUB won't read/write past the
2336 limit. The comment accompanying this restriction didn't quite make sense to
2337 me, so its been modified too.
2339 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2341 2020-12-12 Glenn Washburn <development@efficientek.com>
2343 fs: Fix block lists not being able to address to end of disk sometimes
2344 When checking if a block list goes past the end of the disk, make sure
2345 the total size of the disk is in GRUB native sector sizes, otherwise there
2346 will be blocks at the end of the disk inaccessible by block lists.
2348 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2350 2020-12-12 Vladimir Serbinenko <phcoder@gmail.com>
2352 mbr: Document new limitations on MBR gap support
2353 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2355 2020-12-12 Vladimir Serbinenko <phcoder@google.com>
2357 mbr: Warn if MBR gap is small and user uses advanced modules
2358 We don't want to support small MBR gap in pair with anything but the
2359 simplest config of biosdisk + part_msdos + simple filesystem. In this
2360 path "simple filesystems" are all current filesystems except ZFS and
2363 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2365 2020-12-12 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
2367 efi/tpm: Extract duplicate code into independent functions
2368 Part of the code logic for processing the return value of efi
2369 log_extend_event is repetitive and complicated. Extract the
2370 repetitive code into an independent function.
2372 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2374 2020-12-12 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
2376 efi/tpm: Add debug information for device protocol and eventlog
2377 Add a number of debug logs to the tpm module. The condition tag
2378 for opening debugging is "tpm". On TPM machines, this will bring
2379 great convenience to diagnosis and debugging.
2381 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2383 2020-12-12 Daniel Kiper <daniel.kiper@oracle.com>
2385 loader/linux: Report the UEFI Secure Boot status to the Linux kernel
2386 Now that the GRUB has a grub_efi_get_secureboot() function to check the
2387 UEFI Secure Boot status, use it to report that to the Linux kernel.
2389 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2391 2020-12-12 Javier Martinez Canillas <javierm@redhat.com>
2393 efi: Only register shim_lock verifier if shim_lock protocol is found and SB enabled
2394 The shim_lock module registers a verifier to call shim's verify, but the
2395 handler is registered even when the shim_lock protocol was not installed.
2397 This doesn't cause a NULL pointer dereference in shim_lock_write() because
2398 the shim_lock_init() function just returns GRUB_ERR_NONE if sl isn't set.
2400 But in that case there's no point to even register the shim_lock verifier
2401 since won't do anything. Additionally, it is only useful when Secure Boot
2404 Finally, don't assume that the shim_lock protocol will always be present
2405 when the shim_lock_write() function is called, and check for it on every
2406 call to this function.
2408 Reported-by: Michael Chang <mchang@suse.com>
2409 Reported-by: Peter Jones <pjones@redhat.com>
2410 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2412 2020-12-11 Daniel Kiper <daniel.kiper@oracle.com>
2414 efi: Add secure boot detection
2415 Introduce grub_efi_get_secureboot() function which returns whether
2416 UEFI Secure Boot is enabled or not on UEFI systems.
2418 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2420 2020-12-11 Daniel Kiper <daniel.kiper@oracle.com>
2422 efi: Add a function to read EFI variables with attributes
2423 It will be used to properly detect and report UEFI Secure Boot status to
2424 the x86 Linux kernel. The functionality will be added by subsequent patches.
2426 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2428 2020-12-11 Daniel Kiper <daniel.kiper@oracle.com>
2430 efi: Return grub_efi_status_t from grub_efi_get_variable()
2431 This is needed to properly detect and report UEFI Secure Boot status
2432 to the x86 Linux kernel. The functionality will be added by subsequent
2435 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2437 2020-12-11 Daniel Kiper <daniel.kiper@oracle.com>
2439 efi: Make shim_lock GUID and protocol type public
2440 The GUID will be used to properly detect and report UEFI Secure Boot
2441 status to the x86 Linux kernel. The functionality will be added by
2442 subsequent patches. The shim_lock protocol type is made public for
2445 Additionally, fix formatting of four preceding GUIDs.
2447 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2449 2020-12-11 Javier Martinez Canillas <javierm@redhat.com>
2451 arm/term: Fix linking error due multiple ps2_state definitions
2452 When building with --target=arm-linux-gnu --with-platform=coreboot
2453 a linking error occurs caused by multiple definitions of the
2456 Mark them as static since they aren't used outside their compilation unit.
2458 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2460 2020-12-11 Javier Martinez Canillas <javierm@redhat.com>
2462 include/grub/i386/linux.h: Include missing <grub/types.h> header
2463 This header uses types defined in <grub/types.h> but does not include it,
2464 which leads to compile errors like the following:
2466 In file included from ../include/grub/cpu/linux.h:19,
2467 from kern/efi/sb.c:21:
2468 ../include/grub/i386/linux.h:80:3: error: unknown type name ‘grub_uint64_t’
2469 80 | grub_uint64_t addr;
2471 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2473 2020-12-11 Javier Martinez Canillas <javierm@redhat.com>
2475 i386: Don't include <grub/cpu/linux.h> in coreboot and ieee1275 startup.S
2476 Nothing defined in the header file is used in the assembly code but it
2477 may lead to build errors if some headers are included through this and
2478 contains definitions that are not recognized by the assembler, e.g.:
2480 ../include/grub/types.h: Assembler messages:
2481 ../include/grub/types.h:76: Error: no such instruction: `typedef signed char grub_int8_t'
2482 ../include/grub/types.h:77: Error: no such instruction: `typedef short grub_int16_t'
2483 ../include/grub/types.h:78: Error: no such instruction: `typedef int grub_int32_t'
2485 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2487 2020-11-20 Glenn Washburn <development@efficientek.com>
2489 luks2: Rename index variable "j" to "i" in luks2_get_keyslot()
2490 Looping variable "j" was named such because the variable name "i" was taken.
2491 Since "i" has been renamed in the previous patch, we can rename "j" to "i".
2493 Reviewed-by: Patrick Steinhardt <ps@pks.im>
2494 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2496 2020-11-20 Glenn Washburn <development@efficientek.com>
2498 luks2: Rename variable "i" to "keyslot_idx" in luks2_get_keyslot()
2499 Variables named "i" are usually looping variables. So, rename it to
2500 "keyslot_idx" to ease luks2_get_keyslot() reading.
2502 Reviewed-by: Patrick Steinhardt <ps@pks.im>
2503 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2505 2020-11-20 Glenn Washburn <development@efficientek.com>
2507 luks2: Use correct index variable when looping in luks2_get_keyslot()
2508 The loop variable "j" should be used to index the digests and segments json
2509 array, instead of the variable "i", which is the keyslot index.
2511 Reviewed-by: Patrick Steinhardt <ps@pks.im>
2512 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2514 2020-11-20 Glenn Washburn <development@efficientek.com>
2516 luks2: Rename source disk variable named "disk" to "source" as in luks.c
2517 This makes it more obvious to the reader that the disk referred to is the
2518 source disk, as opposed to say the disk holding the cryptodisk.
2520 Reviewed-by: Patrick Steinhardt <ps@pks.im>
2521 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2523 2020-11-20 Glenn Washburn <development@efficientek.com>
2525 cryptodisk: Rename "offset" in grub_cryptodisk_t to "offset_sectors"
2526 This makes it clear that the offset represents sectors, not bytes, in
2527 order to improve readability.
2529 Reviewed-by: Patrick Steinhardt <ps@pks.im>
2530 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2532 2020-11-20 Glenn Washburn <development@efficientek.com>
2534 cryptodisk: Rename "total_length" field in grub_cryptodisk_t to "total_sectors"
2535 This creates an alignment with grub_disk_t naming of the same field and is
2536 more intuitive as to how it should be used.
2538 Reviewed-by: Patrick Steinhardt <ps@pks.im>
2539 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2541 2020-11-20 Glenn Washburn <development@efficientek.com>
2543 types: Define GRUB_CHAR_BIT based on compiler macro instead of using literal
2544 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2546 2020-11-20 Javier Martinez Canillas <javierm@redhat.com>
2548 include/grub/arm64/linux.h: Include missing <grub/types.h> header
2549 This header uses types defined in <grub/types.h> but does not include it,
2550 which leads to compile errors like the following:
2552 ../include/grub/cpu/linux.h:27:3: error: unknown type name ‘grub_uint32_t’
2553 27 | grub_uint32_t code0; /* Executable code */
2556 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2558 2020-11-20 Javier Martinez Canillas <javierm@redhat.com>
2560 include/grub/arm/system.h: Include missing <grub/symbol.h> header
2561 The header uses the EXPORT_FUNC() macro defined in <grub/types.h> but
2562 doesn't include it, which leads to the following compile error on arm:
2564 ../include/grub/cpu/system.h:12:13: error: ‘EXPORT_FUNC’ declared as function returning a function
2565 12 | extern void EXPORT_FUNC(grub_arm_disable_caches_mmu) (void);
2567 ../include/grub/cpu/system.h:12:1: warning: parameter names (without types) in function declaration
2568 12 | extern void EXPORT_FUNC(grub_arm_disable_caches_mmu) (void);
2570 make[3]: *** [Makefile:36581: kern/efi/kernel_exec-sb.o] Error 1
2572 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2574 2020-11-20 Daniel Axtens <dja@axtens.net>
2576 docs: grub-install --pubkey has been supported for some time
2577 grub-install --pubkey is supported, so we can now document it.
2579 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2581 2020-11-20 Daniel Axtens <dja@axtens.net>
2583 docs: grub-install is no longer a shell script
2584 Since commit cd46aa6cefab in 2013, grub-install hasn't been a shell
2585 script. The para doesn't really add that much, especially since it's
2586 the user manual, so just drop it.
2588 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2590 2020-10-30 Jacob Kroon <jacob.kroon@gmail.com>
2592 Makefile: Remove unused GRUB_PKGLIBDIR definition
2593 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2595 2020-10-30 Daniel Axtens <dja@axtens.net>
2597 lzma: Fix compilation error under clang 10
2598 Compiling under clang 10 gives:
2600 grub-core/lib/LzmaEnc.c:1362:9: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
2603 grub-core/lib/LzmaEnc.c:1358:7: note: previous statement is here
2608 It's not really that unclear in context: there's a commented-out
2609 if-statement. But tweak the alignment anyway so that clang is happy.
2611 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2613 2020-10-30 Cao jin <caoj.fnst@cn.fujitsu.com>
2615 kern/i386/realmode: Update comment
2616 Commit b81d609e4c did not update it.
2618 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2620 2020-10-30 Glenn Washburn <development@efficientek.com>
2622 cryptodisk: Fix cipher IV mode "plain64" always being set as "plain"
2623 When setting cipher IV mode, detection is done by prefix matching the
2624 cipher IV mode part of the cipher mode string. Since "plain" matches
2625 "plain64", we must check for "plain64" first. Otherwise, "plain64" will
2626 be detected as "plain".
2628 Reviewed-by: Patrick Steinhardt <ps@pks.im>
2629 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2631 2020-09-18 Glenn Washburn <development@efficientek.com>
2633 crypto: Remove GPG_ERROR_CFLAGS from gpg_err_code_t enum
2634 This was probably added by accident when originally creating the file.
2636 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2638 2020-09-18 Glenn Washburn <development@efficientek.com>
2640 script: Do not allow a delimiter between function name and block start
2641 Currently the following is valid syntax but should be a syntax error:
2643 grub> function f; { echo HERE; }
2647 This fix is not backward compatible, but current syntax is not documented
2648 either and has no functional value. So any scripts with this unintended
2649 syntax are technically syntactically incorrect and should not be relying
2652 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2654 2020-09-18 Glenn Washburn <development@efficientek.com>
2656 docs: Support for loading and concatenating multiple initrds
2657 This has been available since January of 2012 but has not been documented.
2659 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2661 2020-09-18 Glenn Washburn <development@efficientek.com>
2663 lexer: char const * should be const char *
2664 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2666 cryptodisk: Use cipher name instead of object in error message
2667 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2669 2020-09-18 Glenn Washburn <development@efficientek.com>
2671 tests: F2FS test should use MOUNTDEVICE like other tests
2672 LODEVICES is not an array variable and should not be accessed as such.
2673 This allows the f2fs test to pass as it was failing because a device
2674 name had a space prepended to the path.
2676 Acked-by: Jaegeuk Kim <jaegeuk@kernel.org>
2677 Tested-by: Paul Menzel <pmenzel@molgen.mpg.de>
2678 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2680 2020-09-18 Florian La Roche <Florian.LaRoche@gmail.com>
2682 grub-mkconfig: If $hints is not set reduce the output into grub.cfg to just 1 line
2683 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2685 2020-09-18 Petr Vorel <pvorel@suse.cz>
2687 travis: Run bootstrap to fix build
2688 autogen.sh isn't enough:
2691 Gnulib not yet bootstrapped; run ./bootstrap instead.
2692 The command "./autogen.sh" exited with 1.
2694 Additionally, using bootstrap requires to install autopoint package.
2696 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2698 2020-09-18 Patrick Steinhardt <ps@pks.im>
2700 luks2: Strip dashes off of the UUID
2701 The UUID header for LUKS2 uses a format with dashes, same as for
2702 LUKS(1). But while we strip these dashes for the latter, we don't for
2703 the former. This isn't wrong per se, but it's definitely inconsistent
2704 for users as they need to use the dashed format for LUKS2 and the
2705 non-dashed format for LUKS when e.g. calling "cryptomount -u $UUID".
2707 Fix this inconsistency by stripping dashes off of the LUKS2 UUID.
2709 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2711 2020-09-18 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
2713 efi/tpm: Remove unused functions and structures
2714 Although the tpm_execute() series of functions are defined they are not
2715 used anywhere. Several structures in the include/grub/efi/tpm.h header
2716 file are not used too. There is even nonexistent grub_tpm_init()
2717 declaration in this header. Delete all that unneeded stuff.
2719 If somebody needs the functionality implemented in the dropped code then
2720 he/she can re-add it later. Now it needlessly increases the GRUB
2723 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2725 2020-09-18 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
2727 shim_lock: Enable module for all EFI architectures
2728 Like the tpm the shim_lock module is only enabled for x86_64 target.
2729 However, there's nothing specific to x86_64 in the implementation and
2730 it can be enabled for all EFI architectures.
2732 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2734 2020-09-18 Daniel Kiper <daniel.kiper@oracle.com>
2736 efi/tpm: Fix typo in grub_efi_tpm2_protocol struct
2737 Rename get_active_pcr_blanks() to get_active_pcr_banks().
2739 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
2741 2020-09-18 Daniel Kiper <daniel.kiper@oracle.com>
2743 i386/efi/init: Drop bogus include
2744 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
2746 2020-09-18 Daniel Kiper <daniel.kiper@oracle.com>
2748 docs: Fix devicetree command description
2749 Specifically fix the subsection and drop bogus reference to the GNU/Linux.
2751 Reported-by: Patrick Higgins <higgi1pt@gmail.com>
2752 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
2754 2020-09-18 Martin Whitaker <fsf@martin-whitaker.me.uk>
2756 grub-install: Fix inverted test for NLS enabled when copying locales
2757 Commit 3d8439da8 (grub-install: Locale depends on nls) attempted to avoid
2758 copying locale files to the target directory when NLS was disabled.
2759 However the test is inverted, and it does the opposite.
2761 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
2763 2020-09-11 Javier Martinez Canillas <javierm@redhat.com>
2765 tftp: Roll-over block counter to prevent data packets timeouts
2766 Commit 781b3e5efc3 (tftp: Do not use priority queue) caused a regression
2767 when fetching files over TFTP whose size is bigger than 65535 * block size.
2769 grub> linux /images/pxeboot/vmlinuz
2772 grub> initrd /images/pxeboot/initrd.img
2773 error: timeout reading '/images/pxeboot/initrd.img'.
2777 It is caused by the block number counter being a 16-bit field, which leads
2778 to a maximum file size of ((1 << 16) - 1) * block size. Because GRUB sets
2779 the block size to 1024 octets (by using the TFTP Blocksize Option from RFC
2780 2348 [0]), the maximum file size that can be transferred is 67107840 bytes.
2782 The TFTP PROTOCOL (REVISION 2) RFC 1350 [1] does not mention what a client
2783 should do when a file size is bigger than the maximum, but most TFTP hosts
2784 support the block number counter to be rolled over. That is, acking a data
2785 packet with a block number of 0 is taken as if the 65356th block was acked.
2787 It was working before because the block counter roll-over was happening due
2788 an overflow. But that got fixed by the mentioned commit, which led to the
2789 regression when attempting to fetch files larger than the maximum size.
2791 To allow TFTP file transfers of unlimited size again, re-introduce a block
2792 counter roll-over so the data packets are acked preventing the timeouts.
2794 [0]: https://tools.ietf.org/html/rfc2348
2795 [1]: https://tools.ietf.org/html/rfc1350
2797 Fixes: 781b3e5efc3 (tftp: Do not use priority queue)
2799 Suggested-by: Peter Jones <pjones@redhat.com>
2800 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2802 2020-09-11 Florian La Roche <Florian.LaRoche@gmail.com>
2804 templates: Remove unnecessary trailing semicolon
2805 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2807 2020-09-11 Glenn Washburn <development@efficientek.com>
2809 cryptodisk: Fix incorrect calculation of start sector
2810 Here dev is a grub_cryptodisk_t and dev->offset is offset in sectors of size
2811 native to the cryptodisk device. The sector is correctly transformed into
2812 native grub sector size, but then added to dev->offset which is not
2813 transformed. It would be nice if the type system would help us with this.
2815 Reviewed-by: Patrick Steinhardt <ps@pks.im>
2816 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2818 2020-09-11 Glenn Washburn <development@efficientek.com>
2820 cryptodisk: Unregister cryptomount command when removing module
2821 Reviewed-by: Patrick Steinhardt <ps@pks.im>
2822 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2824 2020-09-11 Patrick Steinhardt <ps@pks.im>
2826 luks2: Improve error reporting when decrypting/verifying key
2827 While we already set up error messages in both luks2_verify_key() and
2828 luks2_decrypt_key(), we do not ever print them. This makes it really
2829 hard to discover why a given key actually failed to decrypt a disk.
2831 Improve this by including the error message in the user-visible output.
2833 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2835 2020-09-11 Patrick Steinhardt <ps@pks.im>
2837 luks: Fix out-of-bounds copy of UUID
2838 When configuring a LUKS disk, we copy over the UUID from the LUKS header
2839 into the new grub_cryptodisk_t structure via grub_memcpy(). As size
2840 we mistakenly use the size of the grub_cryptodisk_t UUID field, which
2841 is guaranteed to be strictly bigger than the LUKS UUID field we're
2842 copying. As a result, the copy always goes out-of-bounds and copies some
2843 garbage from other surrounding fields. During runtime, this isn't
2844 noticed due to the fact that we always NUL-terminate the UUID and thus
2845 never hit the trailing garbage.
2847 Fix the issue by using the size of the local stripped UUID field.
2849 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2851 2020-09-11 Patrick Steinhardt <ps@pks.im>
2853 json: Remove invalid typedef redefinition
2854 The C standard does not allow for typedef redefinitions, even if they
2855 map to the same underlying type. In order to avoid including the
2856 jsmn.h in json.h and thus exposing jsmn's internals, we have exactly
2857 such a forward-declaring typedef in json.h. If enforcing the GNU99 C
2858 standard, clang may generate a warning about this non-standard
2861 Fix the issue by using a simple "struct jsmntok" forward declaration
2862 instead of using a typedef.
2864 Tested-by: Chuck Tuffli <chuck@freebsd.org>
2865 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2867 2020-09-11 Cao jin <caoj.fnst@cn.fujitsu.com>
2869 i386/relocator_common: Drop empty #ifdef
2870 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2872 2020-09-11 Ave Milia <avemilia@protonmail.com>
2874 video/bochs: Fix typo
2875 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2877 2020-07-29 Colin Watson <cjwatson@debian.org>
2879 linux: Fix integer overflows in initrd size handling
2880 These could be triggered by a crafted filesystem with very large files.
2882 Fixes: CVE-2020-15707
2884 Reviewed-by: Jan Setje-Eilers <jan.setjeeilers@oracle.com>
2885 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2887 2020-07-29 Peter Jones <pjones@redhat.com>
2889 loader/linux: Avoid overflow on initrd size calculation
2890 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2892 2020-07-29 Alexey Makhalov <amakhalov@vmware.com>
2894 efi: Fix use-after-free in halt/reboot path
2895 commit 92bfc33db984 ("efi: Free malloc regions on exit")
2896 introduced memory freeing in grub_efi_fini(), which is
2897 used not only by exit path but by halt/reboot one as well.
2898 As result of memory freeing, code and data regions used by
2899 modules, such as halt, reboot, acpi (used by halt) also got
2900 freed. After return to module code, CPU executes, filled
2901 by UEFI firmware (tested with edk2), 0xAFAFAFAF pattern as
2902 a code. Which leads to #UD exception later.
2905 !!!! X64 Exception Type - 06(#UD - Invalid Opcode) CPU Apic ID - 00000000 !!!!
2906 RIP - 0000000003F4EC28, CS - 0000000000000038, RFLAGS - 0000000000200246
2907 RAX - 0000000000000000, RCX - 00000000061DA188, RDX - 0A74C0854DC35D41
2908 RBX - 0000000003E10E08, RSP - 0000000007F0F860, RBP - 0000000000000000
2909 RSI - 00000000064DB768, RDI - 000000000832C5C3
2910 R8 - 0000000000000002, R9 - 0000000000000000, R10 - 00000000061E2E52
2911 R11 - 0000000000000020, R12 - 0000000003EE5C1F, R13 - 00000000061E0FF4
2912 R14 - 0000000003E10D80, R15 - 00000000061E2F60
2913 DS - 0000000000000030, ES - 0000000000000030, FS - 0000000000000030
2914 GS - 0000000000000030, SS - 0000000000000030
2915 CR0 - 0000000080010033, CR2 - 0000000000000000, CR3 - 0000000007C01000
2916 CR4 - 0000000000000668, CR8 - 0000000000000000
2917 DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
2918 DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
2919 GDTR - 00000000079EEA98 0000000000000047, LDTR - 0000000000000000
2920 IDTR - 0000000007598018 0000000000000FFF, TR - 0000000000000000
2921 FXSAVE_STATE - 0000000007F0F4C0
2923 Proposal here is to continue to free allocated memory for
2924 exit boot services path but keep it for halt/reboot path
2925 as it won't be much security concern here.
2926 Introduced GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY
2927 loader flag to be used by efi halt/reboot path.
2929 Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
2930 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2932 2020-07-29 Daniel Kiper <daniel.kiper@oracle.com>
2934 efi/chainloader: Propagate errors from copy_file_path()
2935 Without any error propagated to the caller, make_file_path()
2936 would then try to advance the invalid device path node with
2937 GRUB_EFI_NEXT_DEVICE_PATH(), which would fail, returning a NULL
2938 pointer that would subsequently be dereferenced. Hence, propagate
2939 errors from copy_file_path().
2941 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2943 2020-07-29 Peter Jones <pjones@redhat.com>
2945 efi: Fix some malformed device path arithmetic errors
2946 Several places we take the length of a device path and subtract 4 from
2947 it, without ever checking that it's >= 4. There are also cases where
2948 this kind of malformation will result in unpredictable iteration,
2949 including treating the length from one dp node as the type in the next
2950 node. These are all errors, no matter where the data comes from.
2952 This patch adds a checking macro, GRUB_EFI_DEVICE_PATH_VALID(), which
2953 can be used in several places, and makes GRUB_EFI_NEXT_DEVICE_PATH()
2954 return NULL and GRUB_EFI_END_ENTIRE_DEVICE_PATH() evaluate as true when
2955 the length is too small. Additionally, it makes several places in the
2956 code check for and return errors in these cases.
2958 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2960 2020-07-29 Peter Jones <pjones@redhat.com>
2962 emu: Make grub_free(NULL) safe
2963 The grub_free() implementation in grub-core/kern/mm.c safely handles
2964 NULL pointers, and code at many places depends on this. We don't know
2965 that the same is true on all host OSes, so we need to handle the same
2966 behavior in grub-emu's implementation.
2968 Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
2969 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2971 2020-07-29 Peter Jones <pjones@redhat.com>
2973 lvm: Fix two more potential data-dependent alloc overflows
2974 It appears to be possible to make a (possibly invalid) lvm PV with
2975 a metadata size field that overflows our type when adding it to the
2976 address we've allocated. Even if it doesn't, it may be possible to do so
2977 with the math using the outcome of that as an operand. Check them both.
2979 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2981 2020-07-29 Peter Jones <pjones@redhat.com>
2983 hfsplus: Fix two more overflows
2984 Both node->size and node->namelen come from the supplied filesystem,
2985 which may be user-supplied. We can't trust them for the math unless we
2986 know they don't overflow. Making sure they go through grub_add() or
2987 grub_calloc() first will give us that.
2989 Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
2990 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2992 2020-07-29 Alexey Makhalov <amakhalov@vmware.com>
2994 relocator: Fix grub_relocator_alloc_chunk_align() top memory allocation
2995 Current implementation of grub_relocator_alloc_chunk_align()
2996 does not allow allocation of the top byte.
2998 Assuming input args are:
2999 max_addr = 0xfffff000;
3002 And this is valid. But following overflow protection will
3003 unnecessarily move max_addr one byte down (to 0xffffefff):
3004 if (max_addr > ~size)
3007 ~size + 1 will fix the situation. In addition, check size
3008 for non zero to do not zero max_addr.
3010 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3012 2020-07-29 Chris Coulson <chris.coulson@canonical.com>
3014 script: Avoid a use-after-free when redefining a function during execution
3015 Defining a new function with the same name as a previously defined
3016 function causes the grub_script and associated resources for the
3017 previous function to be freed. If the previous function is currently
3018 executing when a function with the same name is defined, this results
3019 in use-after-frees when processing subsequent commands in the original
3022 Instead, reject a new function definition if it has the same name as
3023 a previously defined function, and that function is currently being
3024 executed. Although a behavioural change, this should be backwards
3025 compatible with existing configurations because they can't be
3026 dependent on the current behaviour without being broken.
3028 Fixes: CVE-2020-15706
3030 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3032 2020-07-29 Chris Coulson <chris.coulson@canonical.com>
3034 script: Remove unused fields from grub_script_function struct
3035 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3037 2020-07-29 Alexey Makhalov <amakhalov@vmware.com>
3039 relocator: Protect grub_relocator_alloc_chunk_align() max_addr against integer underflow
3040 This commit introduces integer underflow mitigation in max_addr calculation
3041 in grub_relocator_alloc_chunk_align() invocation.
3043 It consists of 2 fixes:
3044 1. Introduced grub_relocator_alloc_chunk_align_safe() wrapper function to perform
3045 sanity check for min/max and size values, and to make safe invocation of
3046 grub_relocator_alloc_chunk_align() with validated max_addr value. Replace all
3047 invocations such as grub_relocator_alloc_chunk_align(..., min_addr, max_addr - size, size, ...)
3048 by grub_relocator_alloc_chunk_align_safe(..., min_addr, max_addr, size, ...).
3049 2. Introduced UP_TO_TOP32(s) macro for the cases where max_addr is 32-bit top
3050 address (0xffffffff - size + 1) or similar.
3052 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3054 2020-07-29 Alexey Makhalov <amakhalov@vmware.com>
3056 relocator: Protect grub_relocator_alloc_chunk_addr() input args against integer underflow/overflow
3057 Use arithmetic macros from safemath.h to accomplish it. In this commit,
3058 I didn't want to be too paranoid to check every possible math equation
3059 for overflow/underflow. Only obvious places (with non zero chance of
3060 overflow/underflow) were refactored.
3062 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3064 2020-07-29 Alexey Makhalov <amakhalov@vmware.com>
3066 tftp: Do not use priority queue
3067 There is not need to reassemble the order of blocks. Per RFC 1350,
3068 server must wait for the ACK, before sending next block. Data packets
3069 can be served immediately without putting them to priority queue.
3071 Logic to handle incoming packet is this:
3072 - if packet block id equal to expected block id, then
3074 - if packet block id is less than expected - this is retransmit
3075 of old packet, then ACK it and drop the packet,
3076 - if packet block id is more than expected - that shouldn't
3077 happen, just drop the packet.
3079 It makes the tftp receive path code simpler, smaller and faster.
3080 As a benefit, this change fixes CID# 73624 and CID# 96690, caused
3081 by following while loop:
3083 while (cmp_block (grub_be_to_cpu16 (tftph->u.data.block), data->block + 1) == 0)
3085 where tftph pointer is not moving from one iteration to another, causing
3086 to serve same packet again. Luckily, double serving didn't happen due to
3087 data->block++ during the first iteration.
3089 Fixes: CID 73624, CID 96690
3091 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3093 2020-07-29 Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
3095 multiboot2: Fix memory leak if grub_create_loader_cmdline() fails
3098 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3100 2020-07-29 Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
3102 udf: Fix memory leak
3105 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3106 Reviewed-by: Jan Setje-Eilers <jan.setjeeilers@oracle.com>
3108 2020-07-29 Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
3110 term: Fix overflow on user inputs
3111 This requires a very weird input from the serial interface but can cause
3112 an overflow in input_buf (keys) overwriting the next variable (npending)
3113 with the user choice:
3117 struct grub_terminfo_input_state {
3118 int input_buf[6]; /* 0 24 */
3119 int npending; /* 24 4 */ <- CORRUPT
3122 The magic string requires causing this is "ESC,O,],0,1,2,q" and we overflow
3123 npending with "q" (aka increase npending to 161). The simplest fix is to
3124 just to disallow overwrites input_buf, which exactly what this patch does.
3128 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3130 2020-07-29 Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
3132 lzma: Make sure we don't dereference past array
3133 The two dimensional array p->posSlotEncoder[4][64] is being dereferenced
3134 using the GetLenToPosState() macro which checks if len is less than 5,
3135 and if so subtracts 2 from it. If len = 0, that is 0 - 2 = 4294967294.
3136 Obviously we don't want to dereference that far out so we check if the
3137 position found is greater or equal kNumLenToPosStates (4) and bail out.
3139 N.B.: Upstream LZMA 18.05 and later has this function completely rewritten
3140 without any history.
3144 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3146 2020-07-29 Chris Coulson <chris.coulson@canonical.com>
3148 json: Avoid a double-free when parsing fails.
3149 When grub_json_parse() succeeds, it returns the root object which
3150 contains a pointer to the provided JSON string. Callers are
3151 responsible for ensuring that this string outlives the root
3152 object and for freeing its memory when it's no longer needed.
3154 If grub_json_parse() fails to parse the provided JSON string,
3155 it frees the string before returning an error. This results
3156 in a double free in luks2_recover_key(), which also frees the
3157 same string after grub_json_parse() returns an error.
3159 This changes grub_json_parse() to never free the JSON string
3160 passed to it, and updates the documentation for it to make it
3161 clear that callers are responsible for ensuring that the string
3162 outlives the root JSON object.
3166 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3168 2020-07-29 Alexey Makhalov <amakhalov@vmware.com>
3170 xnu: Fix double free in grub_xnu_devprop_add_property()
3171 grub_xnu_devprop_add_property() should not free utf8 and utf16 as it get
3172 allocated and freed in the caller.
3174 Minor improvement: do prop fields initialization after memory allocations.
3176 Fixes: CID 292442, CID 292457, CID 292460, CID 292466
3178 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3180 2020-07-29 Alexey Makhalov <amakhalov@vmware.com>
3182 gfxmenu: Fix double free in load_image()
3183 self->bitmap should be zeroed after free. Otherwise, there is a chance
3184 to double free (USE_AFTER_FREE) it later in rescale_image().
3188 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3190 2020-07-29 Daniel Kiper <daniel.kiper@oracle.com>
3192 font: Do not load more than one NAME section
3193 The GRUB font file can have one NAME section only. Though if somebody
3194 crafts a broken font file with many NAME sections and loads it then the
3195 GRUB leaks memory. So, prevent against that by loading first NAME
3196 section and failing in controlled way on following one.
3198 Reported-by: Chris Coulson <chris.coulson@canonical.com>
3199 Reviewed-by: Jan Setje-Eilers <jan.setjeeilers@oracle.com>
3201 2020-07-29 Peter Jones <pjones@redhat.com>
3203 iso9660: Don't leak memory on realloc() failures
3204 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3206 2020-07-29 Peter Jones <pjones@redhat.com>
3208 malloc: Use overflow checking primitives where we do complex allocations
3209 This attempts to fix the places where we do the following where
3210 arithmetic_expr may include unvalidated data:
3212 X = grub_malloc(arithmetic_expr);
3214 It accomplishes this by doing the arithmetic ahead of time using grub_add(),
3215 grub_sub(), grub_mul() and testing for overflow before proceeding.
3217 Among other issues, this fixes:
3218 - allocation of integer overflow in grub_video_bitmap_create()
3219 reported by Chris Coulson,
3220 - allocation of integer overflow in grub_png_decode_image_header()
3221 reported by Chris Coulson,
3222 - allocation of integer overflow in grub_squash_read_symlink()
3223 reported by Chris Coulson,
3224 - allocation of integer overflow in grub_ext2_read_symlink()
3225 reported by Chris Coulson,
3226 - allocation of integer overflow in read_section_as_string()
3227 reported by Chris Coulson.
3229 Fixes: CVE-2020-14309, CVE-2020-14310, CVE-2020-14311
3231 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3233 2020-07-29 Peter Jones <pjones@redhat.com>
3235 calloc: Use calloc() at most places
3236 This modifies most of the places we do some form of:
3240 to use calloc(Y, Z) instead.
3242 Among other issues, this fixes:
3243 - allocation of integer overflow in grub_png_decode_image_header()
3244 reported by Chris Coulson,
3245 - allocation of integer overflow in luks_recover_key()
3246 reported by Chris Coulson,
3247 - allocation of integer overflow in grub_lvm_detect()
3248 reported by Chris Coulson.
3250 Fixes: CVE-2020-14308
3252 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3254 2020-07-29 Peter Jones <pjones@redhat.com>
3256 calloc: Make sure we always have an overflow-checking calloc() available
3257 This tries to make sure that everywhere in this source tree, we always have
3258 an appropriate version of calloc() (i.e. grub_calloc(), xcalloc(), etc.)
3259 available, and that they all safely check for overflow and return NULL when
3262 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3264 2020-07-29 Peter Jones <pjones@redhat.com>
3266 safemath: Add some arithmetic primitives that check for overflow
3267 This adds a new header, include/grub/safemath.h, that includes easy to
3268 use wrappers for __builtin_{add,sub,mul}_overflow() declared like:
3272 where OP is grub_add, grub_sub or grub_mul. OP() returns true in the
3273 case where the operation would overflow and res is not modified.
3274 Otherwise, false is returned and the operation is executed.
3276 These arithmetic primitives require newer compiler versions. So, bump
3277 these requirements in the INSTALL file too.
3279 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3281 2020-07-29 Peter Jones <pjones@redhat.com>
3283 yylex: Make lexer fatal errors actually be fatal
3284 When presented with a command that can't be tokenized to anything
3285 smaller than YYLMAX characters, the parser calls YY_FATAL_ERROR(errmsg),
3286 expecting that will stop further processing, as such:
3288 #define YY_DO_BEFORE_ACTION \
3289 yyg->yytext_ptr = yy_bp; \
3290 yyleng = (int) (yy_cp - yy_bp); \
3291 yyg->yy_hold_char = *yy_cp; \
3293 if ( yyleng >= YYLMAX ) \
3294 YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \
3295 yy_flex_strncpy( yytext, yyg->yytext_ptr, yyleng + 1 , yyscanner); \
3296 yyg->yy_c_buf_p = yy_cp;
3298 The code flex generates expects that YY_FATAL_ERROR() will either return
3299 for it or do some form of longjmp(), or handle the error in some way at
3300 least, and so the strncpy() call isn't in an "else" clause, and thus if
3301 YY_FATAL_ERROR() is *not* actually fatal, it does the call with the
3302 questionable limit, and predictable results ensue.
3304 Unfortunately, our implementation of YY_FATAL_ERROR() is:
3306 #define YY_FATAL_ERROR(msg) \
3308 grub_printf (_("fatal error: %s\n"), _(msg)); \
3311 The same pattern exists in yyless(), and similar problems exist in users
3312 of YY_INPUT(), several places in the main parsing loop,
3313 yy_get_next_buffer(), yy_load_buffer_state(), yyensure_buffer_stack,
3314 yy_scan_buffer(), etc.
3316 All of these callers expect YY_FATAL_ERROR() to actually be fatal, and
3317 the things they do if it returns after calling it are wildly unsafe.
3319 Fixes: CVE-2020-10713
3321 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3323 2020-05-25 Marc Zyngier <maz@kernel.org>
3325 arm: Fix 32-bit ARM handling of the CTR register
3326 When booting on an ARMv8 core that implements either CTR.IDC or CTR.DIC
3327 (indicating that some of the cache maintenance operations can be
3328 removed when dealing with I/D-cache coherency, GRUB dies with a
3329 "Unsupported cache type 0x........" message.
3331 This is pretty likely to happen when running in a virtual machine
3332 hosted on an arm64 machine (I've triggered it on a system built around
3333 a bunch of Cortex-A55 cores, which implements CTR.IDC).
3335 It turns out that the way GRUB deals with the CTR register is a bit
3336 harsh for anything from ARMv7 onwards. The layout of the register is
3337 backward compatible, meaning that nothing that gets added is allowed to
3338 break earlier behaviour. In this case, ignoring IDC is completely fine,
3339 and only results in unnecessary cache maintenance.
3341 We can thus avoid being paranoid, and align the 32bit behaviour with
3342 its 64bit equivalent.
3344 This patch has the added benefit that it gets rid of a (gnu-specific)
3347 Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3348 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3350 2020-05-25 Ian Jackson <ian.jackson@eu.citrix.com>
3352 templates/20_linux_xen: Support Xen Security Modules (XSM/FLASK)
3353 XSM is enabled by adding "flask=enforcing" as a Xen command line
3354 argument, and providing the policy file as a grub module.
3356 We make entries for both with and without XSM. If XSM is not compiled
3357 into Xen, then there are no policy files, so no change to the boot
3360 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3362 2020-05-25 Ian Jackson <ian.jackson@eu.citrix.com>
3364 templates/20_linux_xen: Ignore xenpolicy and config files too
3365 file_is_not_sym() currently only checks for xen-syms. Extend it to
3366 disregard xenpolicy (XSM policy files) and files ending .config (which
3367 are built by the Xen upstream build system in some configurations and
3368 can therefore end up in /boot).
3370 Rename the function accordingly, to file_is_not_xen_garbage().
3372 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3374 2020-05-25 Javier Martinez Canillas <javierm@redhat.com>
3376 net: Break out nested function
3377 Nested functions are not supported in C, but are permitted as an extension
3378 in the GNU C dialect. Commit cb2f15c5448 ("normal/main: Search for specific
3379 config files for netboot") added a nested function which caused the build
3380 to break when compiling with clang.
3382 Break that out into a static helper function to make the code portable again.
3384 Reported-by: Daniel Axtens <dja@axtens.net>
3385 Tested-by: Daniel Axtens <dja@axtens.net>
3386 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3388 2020-05-25 Javier Martinez Canillas <javierm@redhat.com>
3390 tpm: Enable module for all EFI platforms
3391 The module is only enabled for x86_64, but there's nothing specific to
3392 x86_64 in the implementation and can be enabled for all EFI platforms.
3394 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3396 2020-05-25 Daniel Kiper <daniel.kiper@oracle.com>
3398 INSTALL/configure: Update install doc and configure comment
3399 ..to reflect the GRUB build reality in them.
3401 Additionally, fix text formatting a bit.
3403 Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3405 2020-05-25 Daniel Kiper <daniel.kiper@oracle.com>
3407 configure: Set gnu99 C language standard by default
3408 Commit d5a32255d (misc: Make grub_strtol() "end" pointers have safer
3409 const qualifiers) introduced "restrict" keyword into some functions
3410 definitions. This keyword was introduced in C99 standard. However, some
3411 compilers by default may use C89 or something different. This behavior
3412 leads to the breakage during builds when c89 or gnu89 is in force. So,
3413 let's set gnu99 C language standard for all compilers by default. This
3414 way a bit random build issue will be fixed and the GRUB source will be
3415 build consistently regardless of type and version of the compiler.
3417 It was decided to use gnu99 C language standard because it fixes the
3418 issue mentioned above and also provides some useful extensions which are
3419 used here and there in the GRUB source. Potentially we can use gnu11
3420 too. However, this may reduce pool of older compilers which can be used
3421 to build the GRUB. So, let's live with gnu99 until we discover that we
3422 strongly require a feature from newer C standard.
3424 The user is still able to override C language standard using relevant
3427 Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3429 2020-05-15 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
3431 tpm: Rename function grub_tpm_log_event() to grub_tpm_measure()
3432 grub_tpm_log_event() and grub_tpm_measure() are two functions that
3433 have the same effect. So, keep grub_tpm_log_event() and rename it
3434 to grub_tpm_measure(). This way we get also a more clear semantics.
3436 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3438 2020-05-15 Daniel Kiper <daniel.kiper@oracle.com>
3440 autogen: Replace -iname with -ipath in find command
3441 ..because -iname cannot be used to match paths.
3443 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
3444 Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3445 Reviewed-by: Daniel Axtens <dja@axtens.net>
3447 2020-05-15 Daniel Kiper <daniel.kiper@oracle.com>
3449 INSTALL: Update configure example
3450 ..to make it more relevant.
3452 Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3454 2020-05-15 Daniel Kiper <daniel.kiper@oracle.com>
3456 configure: Drop unneeded TARGET_CFLAGS expansion
3457 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
3458 Reviewed-by: Leif Lindholm <leif@nuviainc.com>
3460 2020-05-15 Jacob Kroon <jacob.kroon@gmail.com>
3462 docs/grub: Support for probing partition UUID on MSDOS disks
3463 Support was implemented in commit c7cb11b21 (probe: Support probing for
3466 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3468 2020-05-15 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
3470 verifiers: Add verify string debug message
3471 Like grub_verifiers_open(), the grub_verify_string() should also
3472 display this debug message, which is very helpful for debugging.
3474 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3476 2020-05-15 Javier Martinez Canillas <javierm@redhat.com>
3478 envblk: Fix buffer overrun when attempting to shrink a variable value
3479 If an existing variable is set with a value whose length is smaller than
3480 the current value, a memory corruption can happen due copying padding '#'
3481 characters outside of the environment block buffer.
3483 This is caused by a wrong calculation of the previous free space position
3484 after moving backward the characters that followed the old variable value.
3486 That position is calculated to fill the remaining of the buffer with the
3487 padding '#' characters. But since isn't calculated correctly, it can lead
3488 to copies outside of the buffer.
3490 The issue can be reproduced by creating a variable with a large value and
3491 then try to set a new value that is much smaller:
3493 $ grub2-editenv --version
3494 grub2-editenv (GRUB) 2.04
3496 $ grub2-editenv env create
3498 $ grub2-editenv env set a="$(for i in {1..500}; do var="b$var"; done; echo $var)"
3503 $ grub2-editenv env set a="$(for i in {1..50}; do var="b$var"; done; echo $var)"
3504 malloc(): corrupted top size
3505 Aborted (core dumped)
3510 Reported-by: Renaud Métrich <rmetrich@redhat.com>
3511 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3513 2020-05-15 Hans Ulrich Niedermann <hun@n-dimensional.de>
3515 docs: Remove docs for non-existing uppermem command
3516 Remove all documentation of and mentions of the uppermem
3517 command from the docs/grub.texi file.
3519 The uppermem command is not implemented in the GRUB source
3520 at all and appears to never have been implemented despite
3521 former plans to add an uppermem command.
3523 To reduce user confusion, this even removes the paragraph
3524 describing how GRUB's uppermem command was supposed to
3525 complement the Linux kernel's mem= parameter.
3527 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3529 2020-05-15 Hans Ulrich Niedermann <hun@n-dimensional.de>
3531 docs: Remove docs for non-existing pxe_unload command
3532 Remove the documentation of the pxe_unload command from the
3533 docs/grub.texi file.
3535 The pxe_unload command is not implemented in the grub source
3536 at this time at all. It appears to have been removed in commit
3537 671a78acb (cleanup pxe and efi network release).
3539 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3541 2020-05-15 Hans Ulrich Niedermann <hun@n-dimensional.de>
3543 gitignore: Add a few forgotten file patterns
3544 Add a few patterns to .gitignore to cover files which are generated
3545 by building grub ("make", "make check", "make dist") but which have
3546 been forgotten to add to .gitignore in the past.
3548 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3550 2020-05-15 Hans Ulrich Niedermann <hun@n-dimensional.de>
3552 gitignore: Add leading slashes where appropriate
3553 Going through the list of gitignore patterns without a leading slash,
3554 this adds a leading slash where it appears to have been forgotten.
3556 Some gitignore patterns like ".deps/" or "Makefile" clearly should
3557 match everywhere, so those definitively need no leading slash.
3559 For some patterns like "ascii.bitmaps", it is unclear where in the
3560 source tree they should match. Those patterns are kept as they are,
3561 matching the patterns in the whole tree of subdirectories.
3563 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3565 2020-05-15 Hans Ulrich Niedermann <hun@n-dimensional.de>
3567 gitignore: Add trailing slashes for directories
3568 Add trailing slashes for all patterns matching directories.
3570 Note that we do *not* add trailing slashes for *symlinks*
3573 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3575 2020-05-15 Hans Ulrich Niedermann <hun@n-dimensional.de>
3577 gitignore: Sort both pattern groups alphabetically
3578 Alphabetically sort the two groups of gitignore patterns:
3580 * The group of patterns without slashes, matching anywhere
3581 in the directory subtree.
3583 * The group of patterns with slashes, matching relative to the
3584 .gitignore file's directory
3586 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3588 2020-05-15 Hans Ulrich Niedermann <hun@n-dimensional.de>
3590 gitignore: Group patterns with and without slash
3591 Group the .gitignore patterns into two groups:
3593 * Pattern not including a slash, i.e. matching files anywhere in
3594 the .gitignore file's directory and all of its subdirectories.
3596 * Patterns including a slash, i.e. matching only relative to the
3597 .gitignore file's directory.
3599 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3601 2020-05-15 Hans Ulrich Niedermann <hun@n-dimensional.de>
3603 gitignore: Consistent leading slash is easier to read
3604 As all gitignore patterns containing a left or middle slash match
3605 only relative to the .gitignore file's directory, we write them
3606 all in the same manner with a leading slash.
3608 This makes the file significantly easier to read.
3610 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3612 2020-05-15 Daniel Kiper <daniel.kiper@oracle.com>
3614 mips/cache: Add missing nop's in delay slots
3615 Lack of them causes random instructions to be executed before the
3616 jump really happens.
3618 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3620 2020-04-21 Patrick Steinhardt <ps@pks.im>
3622 luks2: Propagate error when reading area key fails
3623 When decrypting a given keyslot, all error cases except for one set up
3624 an error and return the error code. The only exception is when we try to
3625 read the area key: instead of setting up an error message, we directly
3626 print it via grub_dprintf().
3628 Convert the outlier to use grub_error() to allow more uniform handling
3631 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3633 2020-04-21 Patrick Steinhardt <ps@pks.im>
3635 json: Get rid of casts for "jsmntok_t"
3636 With the upstream change having landed that adds a name to the
3637 previously anonymous "jsmntok" typedef, we can now add a forward
3638 declaration for that struct in our code. As a result, we no longer have
3639 to store the "tokens" member of "struct grub_json" as a void pointer but
3640 can instead use the forward declaration, allowing us to get rid of casts
3643 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3645 2020-04-21 Patrick Steinhardt <ps@pks.im>
3647 json: Update jsmn library to upstream commit 053d3cd
3648 Update our embedded version of the jsmn library to upstream commit
3649 053d3cd (Merge pull request #175 from pks-t/pks/struct-type,
3652 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3654 2020-04-21 Steve Langasek <steve.langasek@ubuntu.com>
3656 templates: Output a menu entry for firmware setup on UEFI FastBoot systems
3657 The fwsetup command allows to reboot into the EFI firmware setup menu, add
3658 a template to include a menu entry on EFI systems that makes use of that
3659 command to reboot into the EFI firmware settings.
3661 This is useful for users since the hotkey to enter into the EFI setup menu
3662 may not be the same on all systems so users can use the menu entry without
3663 needing to figure out what key needs to be pressed.
3665 Also, if fastboot is enabled in the BIOS then often it is not possible to
3666 enter the firmware setup menu. So the entry is again useful for this case.
3668 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3670 2020-04-21 Hans de Goede <hdegoede@redhat.com>
3672 kern/term: Accept ESC, F4 and holding SHIFT as user interrupt keys
3673 On some devices the ESC key is the hotkey to enter the BIOS/EFI setup
3674 screen, making it really hard to time pressing it right. Besides that
3675 ESC is also pretty hard to discover for a user who does not know it
3676 will unhide the menu.
3678 This commit makes F4, which was chosen because is not used as a hotkey
3679 to enter the BIOS setup by any vendor, also interrupt sleeps / stop the
3682 This solves the ESC gets into the BIOS setup and also somewhat solves
3683 the discoverability issue, but leaves the timing issue unresolved.
3685 This commit fixes the timing issue by also adding support for keeping
3686 SHIFT pressed during boot to stop the menu countdown. This matches
3687 what Ubuntu is doing, which should also help with discoverability.
3689 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3691 2020-04-21 Hans de Goede <hdegoede@redhat.com>
3693 efi/console: Do not set text-mode until we actually need it
3694 If we're running with a hidden menu we may never need text mode, so do not
3695 change the video-mode to text until we actually need it.
3697 This allows to boot a machine without unnecessary graphical transitions and
3698 provide a seamless boot experience to users.
3700 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3702 2020-04-21 Hans de Goede <hdegoede@redhat.com>
3704 efi/console: Implement getkeystatus() support
3705 Implement getkeystatus() support in the EFI console driver.
3707 This is needed because the logic to determine if a key was pressed to make
3708 the menu countdown stop will be changed by a later patch to also take into
3709 account the SHIFT key being held down.
3711 For this reason the EFI console driver has to support getkeystatus() to
3712 allow detecting that event.
3714 Note that if a non-modifier key gets pressed and repeated calls to
3715 getkeystatus() are made then it will return the modifier status at the
3716 time of the non-modifier key, until that key-press gets consumed by a
3719 This is a side-effect of how the EFI simple-text-input protocol works
3720 and cannot be avoided.
3722 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3724 2020-04-21 Hans de Goede <hdegoede@redhat.com>
3726 efi/console: Add grub_console_read_key_stroke() helper function
3727 This is a preparatory patch for adding getkeystatus() support to the
3730 We can get modifier status through the simple_text_input read_key_stroke()
3731 method, but if a non-modifier key is (also) pressed the read_key_stroke()
3732 call will consume that key from the firmware's queue.
3734 The new grub_console_read_key_stroke() helper buffers upto 1 key-stroke.
3735 If it has a non-modifier key buffered, it will return that one, if its
3736 buffer is empty, it will fills its buffer by getting a new key-stroke.
3738 If called with consume=1 it will empty its buffer after copying the
3739 key-data to the callers buffer, this is how getkey() will use it.
3741 If called with consume=0 it will keep the last key-stroke buffered, this
3742 is how getkeystatus() will call it. This means that if a non-modifier
3743 key gets pressed, repeated getkeystatus() calls will return the modifiers
3744 of that key-press until it is consumed by a getkey() call.
3746 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3748 2020-04-21 Hans de Goede <hdegoede@redhat.com>
3750 kern/term: Make grub_getkeystatus() helper function available everywhere
3751 Move grub_getkeystatushelper() function from grub-core/commands/keystatus.c
3752 to grub-core/kern/term.c and export it so that it can be used outside of
3753 the keystatus command code too.
3755 There's no logic change in this patch. The function definition is moved so
3756 it can be called from grub-core/kern/term.c in a subsequent patch. It will
3757 be used to determine if a SHIFT key has was held down and use that also to
3758 interrupt the countdown, without the need to press a key at the right time.
3760 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3762 2020-04-21 Javier Martinez Canillas <javierm@redhat.com>
3764 efi/console: Move grub_console_set{colorstate,cursor} higher in the file
3765 This is just a preparatory patch to move the functions higher in the file,
3766 since these will be called by the grub_prepare_for_text_output() function
3767 that will be introduced in a later patch.
3769 The logic is unchanged by this patch. Functions definitions are just moved
3770 to avoid a forward declaration in a later patch, keeping the code clean.
3772 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3774 2020-04-21 Paul Menzel <pmenzel@molgen.mpg.de>
3776 docs/grub: Fix typo in *preferred*
3777 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3779 2020-04-21 Daniel Axtens <dja@axtens.net>
3781 powerpc/mkimage: Fix CHRP note descsz
3782 Currently, an image generated with 'grub-mkimage -n' causes an error when
3783 read with 'readelf -a':
3785 Displaying notes found at file offset 0x000106f0 with length 0x0000002c:
3786 Owner Data size Description
3787 readelf: Warning: note with invalid namesz and/or descsz found at offset 0x0
3788 readelf: Warning: type: 0x1275, namesize: 0x00000008, descsize: 0x0000002c, alignment: 4
3790 This is because the descsz of the CHRP note is set to
3791 sizeof (struct grub_ieee1275_note)
3792 which is the size of the entire note, including name and elf header. The
3793 desczs should contain only the contents, not the name and header sizes.
3795 Set the descsz instead to 'sizeof (struct grub_ieee1275_note_desc)'
3797 Resultant readelf output:
3799 Displaying notes found at file offset 0x00010710 with length 0x0000002c:
3800 Owner Data size Description
3801 PowerPC 0x00000018 Unknown note type: (0x00001275)
3802 description data: ff ff ff ff 00 c0 00 00 ff ff ff ff ff ff ff ff ff ff ff ff 00 00 40 00
3804 So far as I can tell this issue has existed for as long as the note
3805 generation code has existed, but I guess nothing really checks descsz.
3807 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3809 2020-03-31 Flavio Suligoi <f.suligoi@asem.it>
3811 efi: Add missed space in GRUB_EFI_GLOBAL_VARIABLE_GUID
3812 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3814 2020-03-31 Michael Chang <mchang@suse.com>
3816 zfs: Fix gcc10 error -Werror=zero-length-bounds
3817 We bumped into the build error while testing gcc-10 pre-release.
3819 In file included from ../../include/grub/file.h:22,
3820 from ../../grub-core/fs/zfs/zfs.c:34:
3821 ../../grub-core/fs/zfs/zfs.c: In function 'zap_leaf_lookup':
3822 ../../grub-core/fs/zfs/zfs.c:2263:44: error: array subscript '<unknown>' is outside the bounds of an interior zero-length array 'grub_uint16_t[0]' {aka 'short unsigned int[0]'} [-Werror=zero-length-bounds]
3823 2263 | for (chunk = grub_zfs_to_cpu16 (l->l_hash[LEAF_HASH (blksft, h, l)], endian);
3824 ../../include/grub/types.h:241:48: note: in definition of macro 'grub_le_to_cpu16'
3825 241 | # define grub_le_to_cpu16(x) ((grub_uint16_t) (x))
3827 ../../grub-core/fs/zfs/zfs.c:2263:16: note: in expansion of macro 'grub_zfs_to_cpu16'
3828 2263 | for (chunk = grub_zfs_to_cpu16 (l->l_hash[LEAF_HASH (blksft, h, l)], endian);
3830 In file included from ../../grub-core/fs/zfs/zfs.c:48:
3831 ../../include/grub/zfs/zap_leaf.h:72:16: note: while referencing 'l_hash'
3832 72 | grub_uint16_t l_hash[0];
3835 Here I'd like to quote from the gcc document [1] which seems best to
3836 explain what is going on here.
3838 "Although the size of a zero-length array is zero, an array member of
3839 this kind may increase the size of the enclosing type as a result of
3840 tail padding. The offset of a zero-length array member from the
3841 beginning of the enclosing structure is the same as the offset of an
3842 array with one or more elements of the same type. The alignment of a
3843 zero-length array is the same as the alignment of its elements.
3845 Declaring zero-length arrays in other contexts, including as interior
3846 members of structure objects or as non-member objects, is discouraged.
3847 Accessing elements of zero-length arrays declared in such contexts is
3848 undefined and may be diagnosed."
3850 The l_hash[0] is apparnetly an interior member to the enclosed structure
3851 while l_entries[0] is the trailing member. And the offending code tries
3852 to access members in l_hash[0] array that triggers the diagnose.
3854 Given that the l_entries[0] is used to get proper alignment to access
3855 leaf chunks, we can accomplish the same thing through the ALIGN_UP macro
3856 thus eliminating l_entries[0] from the structure. In this way we can
3857 pacify the warning as l_hash[0] now becomes the last member to the
3860 [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
3862 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3864 2020-03-31 Michael Chang <mchang@suse.com>
3866 mdraid1x_linux: Fix gcc10 error -Werror=array-bounds
3867 We bumped into the build error while testing gcc-10 pre-release.
3869 ../../grub-core/disk/mdraid1x_linux.c: In function 'grub_mdraid_detect':
3870 ../../grub-core/disk/mdraid1x_linux.c:181:15: error: array subscript <unknown> is outside array bounds of 'grub_uint16_t[0]' {aka 'short unsigned int[0]'} [-Werror=array-bounds]
3871 181 | (char *) &sb.dev_roles[grub_le_to_cpu32 (sb.dev_number)]
3872 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3873 ../../grub-core/disk/mdraid1x_linux.c:98:17: note: while referencing 'dev_roles'
3874 98 | grub_uint16_t dev_roles[0]; /* Role in array, or 0xffff for a spare, or 0xfffe for faulty. */
3876 ../../grub-core/disk/mdraid1x_linux.c:127:33: note: defined here 'sb'
3877 127 | struct grub_raid_super_1x sb;
3879 cc1: all warnings being treated as errors
3881 Apparently gcc issues the warning when trying to access sb.dev_roles
3882 array's member, since it is a zero length array as the last element of
3883 struct grub_raid_super_1x that is allocated sparsely without extra
3884 chunks for the trailing bits, so the warning looks legitimate in this
3887 As the whole thing here is doing offset computation, it is undue to use
3888 syntax that would imply array member access then take address from it
3889 later. Instead we could accomplish the same thing through basic array
3890 pointer arithmetic to pacify the warning.
3892 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3894 2020-03-31 Simon Hardy <simon.hardy@itdev.co.uk>
3896 build: Fix GRUB i386-pc build with Ubuntu gcc
3897 With recent versions of gcc on Ubuntu a very large lzma_decompress.img file is
3898 output. (e.g. 134479600 bytes instead of 2864.) This causes grub-mkimage to
3899 fail with: "error: Decompressor is too big."
3901 This seems to be caused by a section .note.gnu.property that is placed at an
3902 offset such that objcopy needs to pad the img file with zeros.
3904 This issue is present on:
3905 Ubuntu 19.10 with gcc (Ubuntu 8.3.0-26ubuntu1~19.10) 8.3.0
3906 Ubuntu 19.10 with gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008
3908 This issue is not present on:
3909 Ubuntu 19.10 with gcc (Ubuntu 7.5.0-3ubuntu1~19.10) 7.5.0
3910 RHEL 8.0 with gcc 8.3.1 20190507 (Red Hat 8.3.1-4)
3912 The issue can be fixed by removing the section using objcopy as shown in
3915 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3917 2020-03-31 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
3919 efi/tpm: Fix memory leak in grub_tpm1/2_log_event()
3920 The memory requested for the event is not released here,
3921 causing memory leaks. This patch fixes this problem.
3923 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
3924 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3926 2020-03-31 Michael Chang <mchang@suse.com>
3928 docs: Document notes on LVM cache booting
3929 Add notes on LVM cache booting to the GRUB manual to help user understanding
3930 the outstanding issue and status.
3932 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3934 2020-03-31 Michael Chang <mchang@suse.com>
3936 lvm: Add LVM cache logical volume handling
3937 The LVM cache logical volume is the logical volume consisting of the original
3938 and the cache pool logical volume. The original is usually on a larger and
3939 slower storage device while the cache pool is on a smaller and faster one. The
3940 performance of the original volume can be improved by storing the frequently
3941 used data on the cache pool to utilize the greater performance of faster
3944 The default cache mode "writethrough" ensures that any data written will be
3945 stored both in the cache and on the origin LV, therefore grub can be straight
3946 to read the original lv as no data loss is guarenteed.
3948 The second cache mode is "writeback", which delays writing from the cache pool
3949 back to the origin LV to have increased performance. The drawback is potential
3950 data loss if losing the associated cache device.
3952 During the boot time grub reads the LVM offline i.e. LVM volumes are not
3953 activated and mounted, hence it should be fine to read directly from original
3954 lv since all cached data should have been flushed back in the process of taking
3957 It is also not much helpful to the situation by adding fsync calls to the
3958 install code. The fsync did not force to write back dirty cache to the original
3959 device and rather it would update associated cache metadata to complete the
3960 write transaction with the cache device. IOW the writes to cached blocks still
3961 go only to the cache device.
3963 To write back dirty cache, as LVM cache did not support dirty cache flush per
3964 block range, there'no way to do it for file. On the other hand the "cleaner"
3965 policy is implemented and can be used to write back "all" dirty blocks in a
3966 cache, which effectively drain all dirty cache gradually to attain and last in
3967 the "clean" state, which can be useful for shrinking or decommissioning a
3968 cache. The result and effect is not what we are looking for here.
3970 In conclusion, as it seems no way to enforce file writes to the original
3971 device, grub may suffer from power failure as it cannot assemble the cache
3972 device and read the dirty data from it. However since the case is only
3973 applicable to writeback mode which is sensitive to data lost in nature, I'd
3974 still like to propose my (relatively simple) patch and treat reading dirty
3975 cache as improvement.
3977 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3979 2020-03-10 Patrick Steinhardt <ps@pks.im>
3981 gnulib: Fix build of base64 when compiling with memory debugging
3982 When building GRUB with memory management debugging enabled, then the
3983 build fails because of `grub_debug_malloc()` and `grub_debug_free()`
3984 being undefined in the luks2 module. The cause is that we patch
3985 "base64.h" to unconditionaly include "config-util.h", which shouldn't be
3986 included for modules at all. As a result, `MM_DEBUG` is defined when
3987 building the module, causing it to use the debug memory allocation
3988 functions. As these are not built into modules, we end up with a linker
3991 Fix the issue by removing the <config-util.h> include altogether. The
3992 sole reason it was included was for the `_GL_ATTRIBUTE_CONST` macro,
3993 which we can simply define as empty in case it's not set.
3995 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
3997 2020-03-10 Patrick Steinhardt <ps@pks.im>
3999 build: Fix option to explicitly disable memory debugging
4000 The memory management system supports a debug mode that can be enabled
4001 at build time by passing "--enable-mm-debug" to the configure script.
4002 Passing the option will cause us define MM_DEBUG as expected, but in
4003 fact the reverse option "--disable-mm-debug" will do the exact same
4004 thing and also set up the define. This currently causes the build of
4005 "lib/gnulib/base64.c" to fail as it tries to use `grub_debug_malloc()`
4006 and `grub_debug_free()` even though both symbols aren't defined.
4008 Seemingly, `AC_ARG_ENABLE()` will always execute the third argument if
4009 either the positive or negative option was passed. Let's thus fix the
4010 issue by moving the call to`AC_DEFINE()` into an explicit `if test
4011 $xenable_mm_debug` block, similar to how other defines work.
4013 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4014 Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
4016 2020-03-10 David Michael <fedora.dm0@gmail.com>
4018 fat: Support file modification times
4019 This allows comparing file ages on EFI system partitions.
4021 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4023 2020-03-10 David Michael <fedora.dm0@gmail.com>
4025 exfat: Save the matching directory entry struct when searching
4026 This provides the node's attributes outside the iterator function
4027 so the file modification time can be accessed and reported.
4029 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4031 2020-03-10 Mike Gilbert <floppym@gentoo.org>
4033 datetime: Enable the datetime module for the emu platform
4034 Fixes a build failure:
4036 grub-core/commands/date.c:49: undefined reference to `grub_get_weekday_name'
4037 grub-core/commands/ls.c:155: undefined reference to `grub_unixtime2datetime'
4039 Bug: https://bugs.gentoo.org/711512
4041 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
4042 Tested-by: Javier Martinez Canillas <javierm@redhat.com>
4043 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4045 2020-03-10 John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
4047 build: Add soft-float handling for SuperH (sh4)
4048 While GRUB has no platform support for SuperH (sh4) yet, this change
4049 adds the target-specific handling of soft-floats such that the GRUB
4050 utilities can be built on this target.
4052 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4054 2020-03-10 Peter Jones <pjones@redhat.com>
4056 efi: Fix the type of grub_efi_status_t
4057 Currently, in some builds with some checkers, we see:
4059 1. grub-core/disk/efi/efidisk.c:601: error[shiftTooManyBitsSigned]: Shifting signed 64-bit value by 63 bits is undefined behaviour
4061 This is because grub_efi_status_t is defined as grub_efi_intn_t, which is
4062 signed, and shifting into the sign bit is not defined behavior. UEFI fixed
4063 this in the spec in 2.3:
4065 2.3 | Change the defined type of EFI_STATUS from INTN to UINTN | May 7, 2009
4067 And the current EDK2 code has:
4068 MdePkg/Include/Base.h-//
4069 MdePkg/Include/Base.h-// Status codes common to all execution phases
4070 MdePkg/Include/Base.h-//
4071 MdePkg/Include/Base.h:typedef UINTN RETURN_STATUS;
4072 MdePkg/Include/Base.h-
4073 MdePkg/Include/Base.h-/**
4074 MdePkg/Include/Base.h- Produces a RETURN_STATUS code with the highest bit set.
4075 MdePkg/Include/Base.h-
4076 MdePkg/Include/Base.h- @param StatusCode The status code value to convert into a warning code.
4077 MdePkg/Include/Base.h- StatusCode must be in the range 0x00000000..0x7FFFFFFF.
4078 MdePkg/Include/Base.h-
4079 MdePkg/Include/Base.h- @return The value specified by StatusCode with the highest bit set.
4080 MdePkg/Include/Base.h-
4081 MdePkg/Include/Base.h-**/
4082 MdePkg/Include/Base.h-#define ENCODE_ERROR(StatusCode) ((RETURN_STATUS)(MAX_BIT | (StatusCode)))
4083 MdePkg/Include/Base.h-
4084 MdePkg/Include/Base.h-/**
4085 MdePkg/Include/Base.h- Produces a RETURN_STATUS code with the highest bit clear.
4086 MdePkg/Include/Base.h-
4087 MdePkg/Include/Base.h- @param StatusCode The status code value to convert into a warning code.
4088 MdePkg/Include/Base.h- StatusCode must be in the range 0x00000000..0x7FFFFFFF.
4089 MdePkg/Include/Base.h-
4090 MdePkg/Include/Base.h- @return The value specified by StatusCode with the highest bit clear.
4091 MdePkg/Include/Base.h-
4092 MdePkg/Include/Base.h-**/
4093 MdePkg/Include/Base.h-#define ENCODE_WARNING(StatusCode) ((RETURN_STATUS)(StatusCode))
4094 MdePkg/Include/Base.h-
4095 MdePkg/Include/Base.h-/**
4096 MdePkg/Include/Base.h- Returns TRUE if a specified RETURN_STATUS code is an error code.
4097 MdePkg/Include/Base.h-
4098 MdePkg/Include/Base.h- This function returns TRUE if StatusCode has the high bit set. Otherwise, FALSE is returned.
4099 MdePkg/Include/Base.h-
4100 MdePkg/Include/Base.h- @param StatusCode The status code value to evaluate.
4101 MdePkg/Include/Base.h-
4102 MdePkg/Include/Base.h- @retval TRUE The high bit of StatusCode is set.
4103 MdePkg/Include/Base.h- @retval FALSE The high bit of StatusCode is clear.
4104 MdePkg/Include/Base.h-
4105 MdePkg/Include/Base.h-**/
4106 MdePkg/Include/Base.h-#define RETURN_ERROR(StatusCode) (((INTN)(RETURN_STATUS)(StatusCode)) < 0)
4108 Uefi/UefiBaseType.h:typedef RETURN_STATUS EFI_STATUS;
4110 This patch makes grub's implementation match the Edk2 declaration with regards
4111 to the signedness of the type.
4113 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4115 2020-03-10 Peter Jones <pjones@redhat.com>
4117 efi/gop: Add debug output on GOP probing
4118 Add debug information to EFI GOP video driver probing function.
4120 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4122 2020-03-10 Peter Jones <pjones@redhat.com>
4124 efi/uga: Use video instead of fb as debug condition
4125 All other video drivers use "video" as the debug condition instead of "fb"
4126 so change this in the efi/uga driver to make it consistent with the others.
4128 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4130 2020-03-10 Peter Jones <pjones@redhat.com>
4132 efi: Print error messages to grub_efi_allocate_pages_real()
4133 No messages were printed in this function, add some to ease debugging.
4135 Also, the function returns a void * pointer so return NULL instead of
4136 0 to make the code more readable.
4138 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4140 2020-03-10 Andrei Borzenkov <arvidjaar@gmail.com>
4142 efi/uga: Use 64 bit for fb_base
4143 We get 64 bit from PCI BAR but then truncate by assigning to 32 bit.
4144 Make sure to check that pointer does not overflow on 32 bit platform.
4148 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4150 2020-03-10 Alexander Graf <agraf@suse.de>
4152 efi/gop: Add support for BLT_ONLY adapters
4153 EFI GOP has support for multiple different bitness types of frame buffers
4154 and for a special "BLT only" type which is always defined to be RGBx.
4156 Because grub2 doesn't ever directly access the frame buffer but instead
4157 only renders graphics via the BLT interface anyway, we can easily support
4160 The reason this has come up now is the emerging support for virtio-gpu
4161 in OVMF. That adapter does not have the notion of a memory mapped frame
4162 buffer and thus is BLT only.
4164 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4166 2020-03-10 Peter Jones <pjones@redhat.com>
4168 normal/completion: Fix possible NULL pointer dereference
4169 Coverity Scan reports that the grub_strrchr() function can return NULL if
4170 the character is not found. Check if that's the case for dirfile pointer.
4172 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4174 2020-03-10 Peter Jones <pjones@redhat.com>
4176 kern: Add grub_debug_enabled()
4177 Add a grub_debug_enabled() helper function instead of open coding it.
4179 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4181 2020-03-10 Peter Jones <pjones@redhat.com>
4183 Makefile: Make libgrub.pp depend on config-util.h
4184 If you build with "make -j48" a lot, sometimes you see:
4186 gcc -E -DHAVE_CONFIG_H -I. -I.. -Wall -W -DGRUB_UTIL=1 -D_FILE_OFFSET_BITS=64 -I./include -DGRUB_FILE=\"grub_script.tab.h\" -I. -I.. -I. -I.. -I../include -I./include -I../grub-core/lib/libgcrypt-grub/src/ -I../grub-core/lib/minilzo -I../grub-core/lib/xzembed -DMINILZO_HAVE_CONFIG_H -Wall -W -DGRUB_UTIL=1 -D_FILE_OFFSET_BITS=64 -I./include -DGRUB_FILE=\"grub_script.tab.h\" -I. -I.. -I. -I.. -I../include -I./include -I../grub-core/lib/libgcrypt-grub/src/ -I./grub-core/gnulib -I../grub-core/gnulib -I/builddir/build/BUILD/grub-2.02/grub-aarch64-efi-2.02 -D_FILE_OFFSET_BITS=64 \
4187 -D'GRUB_MOD_INIT(x)=@MARKER@x@' grub_script.tab.h grub_script.yy.h ../grub-core/commands/blocklist.c ../grub-core/commands/macbless.c ../grub-core/commands/xnu_uuid.c ../grub-core/commands/testload.c ../grub-core/commands/ls.c ../grub-core/disk/dmraid_nvidia.c ../grub-core/disk/loopback.c ../grub-core/disk/lvm.c ../grub-core/disk/mdraid_linux.c ../grub-core/disk/mdraid_linux_be.c ../grub-core/disk/mdraid1x_linux.c ../grub-core/disk/raid5_recover.c ../grub-core/disk/raid6_recover.c ../grub-core/font/font.c ../grub-core/gfxmenu/font.c ../grub-core/normal/charset.c ../grub-core/video/fb/fbblit.c ../grub-core/video/fb/fbutil.c ../grub-core/video/fb/fbfill.c ../grub-core/video/fb/video_fb.c ../grub-core/video/video.c ../grub-core/video/capture.c ../grub-core/video/colors.c ../grub-core/unidata.c ../grub-core/io/bufio.c ../grub-core/fs/affs.c ../grub-core/fs/afs.c ../grub-core/fs/bfs.c ../grub-core/fs/btrfs.c ../grub-core/fs/cbfs.c ../grub-core/fs/cpio.c ../grub-core/fs/cpio_be.c ../grub-core/fs/odc.c ../grub-core/fs/newc.c ../grub-core/fs/ext2.c ../grub-core/fs/fat.c ../grub-core/fs/exfat.c ../grub-core/fs/fshelp.c ../grub-core/fs/hfs.c ../grub-core/fs/hfsplus.c ../grub-core/fs/hfspluscomp.c ../grub-core/fs/iso9660.c ../grub-core/fs/jfs.c ../grub-core/fs/minix.c ../grub-core/fs/minix2.c ../grub-core/fs/minix3.c ../grub-core/fs/minix_be.c ../grub-core/fs/minix2_be.c ../grub-core/fs/minix3_be.c ../grub-core/fs/nilfs2.c ../grub-core/fs/ntfs.c ../grub-core/fs/ntfscomp.c ../grub-core/fs/reiserfs.c ../grub-core/fs/romfs.c ../grub-core/fs/sfs.c ../grub-core/fs/squash4.c ../grub-core/fs/tar.c ../grub-core/fs/udf.c ../grub-core/fs/ufs2.c ../grub-core/fs/ufs.c ../grub-core/fs/ufs_be.c ../grub-core/fs/xfs.c ../grub-core/fs/zfs/zfscrypt.c ../grub-core/fs/zfs/zfs.c ../grub-core/fs/zfs/zfsinfo.c ../grub-core/fs/zfs/zfs_lzjb.c ../grub-core/fs/zfs/zfs_lz4.c ../grub-core/fs/zfs/zfs_sha256.c ../grub-core/fs/zfs/zfs_fletcher.c ../grub-core/lib/envblk.c ../grub-core/lib/hexdump.c ../grub-core/lib/LzFind.c ../grub-core/lib/LzmaEnc.c ../grub-core/lib/crc.c ../grub-core/lib/adler32.c ../grub-core/lib/crc64.c ../grub-core/normal/datetime.c ../grub-core/normal/misc.c ../grub-core/partmap/acorn.c ../grub-core/partmap/amiga.c ../grub-core/partmap/apple.c ../grub-core/partmap/sun.c ../grub-core/partmap/plan.c ../grub-core/partmap/dvh.c ../grub-core/partmap/sunpc.c ../grub-core/partmap/bsdlabel.c ../grub-core/partmap/dfly.c ../grub-core/script/function.c ../grub-core/script/lexer.c ../grub-core/script/main.c ../grub-core/script/script.c ../grub-core/script/argv.c ../grub-core/io/gzio.c ../grub-core/io/xzio.c ../grub-core/io/lzopio.c ../grub-core/kern/ia64/dl_helper.c ../grub-core/kern/arm/dl_helper.c ../grub-core/kern/arm64/dl_helper.c ../grub-core/lib/minilzo/minilzo.c ../grub-core/lib/xzembed/xz_dec_bcj.c ../grub-core/lib/xzembed/xz_dec_lzma2.c ../grub-core/lib/xzembed/xz_dec_stream.c ../util/misc.c ../grub-core/kern/command.c ../grub-core/kern/device.c ../grub-core/kern/disk.c ../grub-core/lib/disk.c ../util/getroot.c ../grub-core/osdep/unix/getroot.c ../grub-core/osdep/getroot.c ../grub-core/osdep/devmapper/getroot.c ../grub-core/osdep/relpath.c ../grub-core/kern/emu/hostdisk.c ../grub-core/osdep/devmapper/hostdisk.c ../grub-core/osdep/hostdisk.c ../grub-core/osdep/unix/hostdisk.c ../grub-core/osdep/exec.c ../grub-core/osdep/sleep.c ../grub-core/osdep/password.c ../grub-core/kern/emu/misc.c ../grub-core/kern/emu/mm.c ../grub-core/kern/env.c ../grub-core/kern/err.c ../grub-core/kern/file.c ../grub-core/kern/fs.c ../grub-core/kern/list.c ../grub-core/kern/misc.c ../grub-core/kern/partition.c ../grub-core/lib/crypto.c ../grub-core/disk/luks.c ../grub-core/disk/geli.c ../grub-core/disk/cryptodisk.c ../grub-core/disk/AFSplitter.c ../grub-core/lib/pbkdf2.c ../grub-core/commands/extcmd.c ../grub-core/lib/arg.c ../grub-core/disk/ldm.c ../grub-core/disk/diskfilter.c ../grub-core/partmap/gpt.c ../grub-core/partmap/msdos.c ../grub-core/fs/proc.c ../grub-core/fs/archelp.c > libgrub.pp || (rm -f libgrub.pp; exit 1)
4189 touch ../config-util.h.in
4190 cd . && /bin/sh ./config.status config-util.h
4191 config.status: creating config-util.h
4192 In file included from ../include/grub/mm.h:25:0,
4193 from ../include/grub/disk.h:29,
4194 from ../include/grub/file.h:26,
4195 from ../grub-core/fs/btrfs.c:21:
4196 ./config.h:38:10: fatal error: ./config-util.h: No such file or directory
4197 #include <config-util.h>
4199 compilation terminated.
4200 make: *** [Makefile:13098: libgrub.pp] Error 1
4202 This is because libgrub.pp is built with -DGRUB_UTIL=1, which means
4203 it'll try to include config-util.h, but a parallel make is actually
4204 building that file. I think.
4206 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4208 2020-03-10 Peter Jones <pjones@redhat.com>
4210 efi: Print more debug info in our module loader
4211 The function that searches the mods section base address does not have
4212 any debug information. Add some debugging outputs that could be useful.
4214 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4216 2020-03-10 Peter Jones <pjones@redhat.com>
4218 linux/getroot: Handle rssd storage device names
4219 The Micron PCIe SSDs Linux driver (mtip32xx) exposes block devices
4220 as /dev/rssd[a-z]+[0-9]*. Add support for these rssd device names.
4222 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4224 2020-03-10 Julian Andres Klode <julian.klode@canonical.com>
4226 smbios: Add a --linux argument to apply linux modalias-like filtering
4227 Linux creates modalias strings by filtering out non-ASCII, space,
4228 and colon characters. Provide an option that does the same filtering
4229 so people can create a modalias string in GRUB, and then match their
4230 modalias patterns against it.
4232 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4234 2020-03-10 Mike Gilbert <floppym@gentoo.org>
4236 po: Fix replacement of %m in sed programs
4237 When running make dist, I hit this error:
4239 rm -f en@arabic.gmo && /usr/bin/gmsgfmt -c --statistics --verbose -o en@arabic.gmo en@arabic.po
4240 en@arabic.po:5312: 'msgstr' is not a valid C format string, unlike 'msgid'.
4241 Reason: The character that terminates the directive number 3 is not a valid conversion specifier.
4242 /usr/bin/gmsgfmt: found 1 fatal error
4244 This was caused by "%m" being replaced with foreign Unicode characters.
4247 msgid "cannot rename the file %s to %s: %m"
4248 msgstr "ﺹﺎﻨﻧﻮﺗ ﺮﻌﻧﺎﻤﻋ ﺖﻬﻋ ﻒִﻴﻠﻋ %s ﺕﻭ %s: %ﻡ"
4250 Mimic the workaround used for "%s" by reversing the replacement of "%m" at
4251 the end of the sed programs.
4253 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4255 2020-03-10 Colin Watson <cjwatson@ubuntu.com>
4257 gettext: Restore patches to po/Makefile.in.in
4258 These were inadvertently lost during the conversion to Gnulib (gnulib:
4259 Upgrade Gnulib and switch to bootstrap tool; commit 35b909062). The
4260 files in po/gettext-patches/ can be imported using "git am" on top of
4261 the gettext tag corresponding to AM_GNU_GETTEXT_VERSION in configure.ac
4262 (currently 0.18.3). They handle translation of messages in shell files,
4263 make msgfmt output in little-endian format, and arrange to use @SHELL@
4264 rather than /bin/sh.
4266 There were some changes solely for the purpose of distributing extra
4267 files; for ease of maintenance, I've added these to
4268 conf/Makefile.extra-dist instead.
4270 Fixes: https://savannah.gnu.org/bugs/?57298
4272 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4274 2020-02-28 Peter Jones <pjones@redhat.com>
4276 misc: Make grub_strtol() "end" pointers have safer const qualifiers
4277 Currently the string functions grub_strtol(), grub_strtoul(), and
4278 grub_strtoull() don't declare the "end" pointer in such a way as to
4279 require the pointer itself or the character array to be immutable to the
4280 implementation, nor does the C standard do so in its similar functions,
4281 though it does require us not to change any of it.
4283 The typical declarations of these functions follow this pattern:
4286 strtol(const char * restrict nptr, char ** restrict endptr, int base);
4288 Much of the reason for this is historic, and a discussion of that
4289 follows below, after the explanation of this change. (GRUB currently
4290 does not include the "restrict" qualifiers, and we name the arguments a
4293 The implementation is semantically required to treat the character array
4294 as immutable, but such accidental modifications aren't stopped by the
4295 compiler, and the semantics for both the callers and the implementation
4296 of these functions are sometimes also helped by adding that requirement.
4298 This patch changes these declarations to follow this pattern instead:
4301 strtol(const char * restrict nptr,
4302 const char ** const restrict endptr,
4305 This means that if any modification to these functions accidentally
4306 introduces either an errant modification to the underlying character
4307 array, or an accidental assignment to endptr rather than *endptr, the
4308 compiler should generate an error. (The two uses of "restrict" in this
4309 case basically mean strtol() isn't allowed to modify the character array
4310 by going through *endptr, and endptr isn't allowed to point inside the
4313 It also means the typical use case changes to:
4319 l = strtol(s, &end, 10);
4323 const char *p = str;
4325 long l = strtol(p, &p, 10);
4329 This fixes 26 places where we discard our attempts at treating the data
4332 const char *p = str;
4335 l = strtol(p, (char **)&ptr, 10);
4337 It also adds 5 places where we do:
4341 long l = strtol(p, (const char ** const)&p, 10);
4343 /* more calls that need p not to be pointer-to-const */
4346 While moderately distasteful, this is a better problem to have.
4348 With one minor exception, I have tested that all of this compiles
4349 without relevant warnings or errors, and that /much/ of it behaves
4350 correctly, with gcc 9 using 'gcc -W -Wall -Wextra'. The one exception
4351 is the changes in grub-core/osdep/aros/hostdisk.c , which I have no idea
4354 Because the C standard defined type-qualifiers in a way that can be
4355 confusing, in the past there's been a slow but fairly regular stream of
4356 churn within our patches, which add and remove the const qualifier in many
4357 of the users of these functions. This change should help avoid that in
4358 the future, and in order to help ensure this, I've added an explanation
4359 in misc.h so that when someone does get a compiler warning about a type
4360 error, they have the fix at hand.
4362 The reason we don't have "const" in these calls in the standard is
4363 purely anachronistic: C78 (de facto) did not have type qualifiers in the
4364 syntax, and the "const" type qualifier was added for C89 (I think; it
4365 may have been later). strtol() appears to date from 4.3BSD in 1986,
4366 which means it could not be added to those functions in the standard
4367 without breaking compatibility, which is usually avoided.
4369 The syntax chosen for type qualifiers is what has led to the churn
4370 regarding usage of const, and is especially confusing on string
4371 functions due to the lack of a string type. Quoting from C99, the
4375 pointer[opt] direct-declarator
4379 direct-declarator [ type-qualifier-list[opt] assignment-expression[opt] ]
4381 direct-declarator [ type-qualifier-list[opt] * ]
4384 * type-qualifier-list[opt]
4385 * type-qualifier-list[opt] pointer
4386 type-qualifier-list:
4388 type-qualifier-list type-qualifier
4395 So the examples go like:
4397 const char foo; // immutable object
4398 const char *foo; // mutable pointer to object
4399 char * const foo; // immutable pointer to mutable object
4400 const char * const foo; // immutable pointer to immutable object
4401 const char const * const foo; // XXX extra const keyword in the middle
4402 const char * const * const foo; // immutable pointer to immutable
4403 // pointer to immutable object
4404 const char ** const foo; // immutable pointer to mutable pointer
4405 // to immutable object
4407 Making const left-associative for * and right-associative for everything
4408 else may not have been the best choice ever, but here we are, and the
4409 inevitable result is people using trying to use const (as they should!),
4410 putting it at the wrong place, fighting with the compiler for a bit, and
4411 then either removing it or typecasting something in a bad way. I won't
4412 go into describing restrict, but its syntax has exactly the same issue
4415 Anyway, the last example above actually represents the *behavior* that's
4416 required of strtol()-like functions, so that's our choice for the "end"
4419 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4421 2020-02-28 Mike Gilbert <floppym@gentoo.org>
4423 build: Disable PIE in TARGET_CCASFLAGS if needed
4424 PIE should be disabled in assembly sources as well, or else GRUB will
4427 Bug: https://bugs.gentoo.org/667852
4429 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4430 Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
4432 2020-02-28 Mike Gilbert <floppym@gentoo.org>
4434 build: Move TARGET_* assignments earlier
4435 On a 32-bit SPARC userland, configure fails to compile assembly and the
4438 checking for options to compile assembly... configure: error: could not compile assembly
4442 asm-tests/sparc64.S: Assembler messages:
4443 asm-tests/sparc64.S:5: Error: Architecture mismatch on "lduw [%o4+4],%o4".
4444 asm-tests/sparc64.S:5: (Requires v9|v9a|v9b|v9c|v9d|v9e|v9v|v9m|m8; requested architecture is sparclite.)
4445 asm-tests/sparc64.S:7: Error: Architecture mismatch on "stw %o5,[%o3]".
4446 asm-tests/sparc64.S:7: (Requires v9|v9a|v9b|v9c|v9d|v9e|v9v|v9m|m8; requested architecture is sparclite.)
4447 asm-tests/sparc64.S:8: Error: Architecture mismatch on "bne,pt %icc,1b ,pt %icc,1b".
4448 asm-tests/sparc64.S:8: (Requires v9|v9a|v9b|v9c|v9d|v9e|v9v|v9m|m8; requested architecture is sparclite.)
4450 Simply moving these blocks earlier in configure.ac is sufficient to
4451 ensure that the tests are executed with the appropriate flags
4452 (specifically -m64 in this case).
4454 Bug: https://bugs.gentoo.org/667850
4456 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4457 Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
4459 2020-02-28 Patrick Steinhardt <ps@pks.im>
4461 luks2: Add missing newline to debug message
4462 The debug message printed when decryption with a keyslot fails is
4463 missing its trailing newline. Add it to avoid mangling it with
4466 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4468 2020-02-18 Michael Chang <mchang@suse.com>
4470 verifiers: Fix calling uninitialized function pointer
4471 The necessary check for NULL before use of function ver->close is not
4472 taking place in the failure path. This patch simply adds the missing
4473 check and fixes the problem that GRUB hangs indefinitely after booting
4474 rogue image without valid signature if secure boot is turned on.
4476 Now it displays like this for booting rogue UEFI image:
4478 error: bad shim signature
4479 error: you need to load the kernel first
4481 Press any key to continue...
4483 and then you can go back to boot menu by pressing any key or after a few
4486 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
4487 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4489 2020-02-18 Peter Jones <pjones@redhat.com>
4491 grub-editenv: Make grub-editenv chase symlinks including those across devices
4492 The grub-editenv create command will wrongly overwrite /boot/grub2/grubenv
4493 with a regular file if grubenv is a symbolic link. But instead, it should
4494 create a new file in the path the symlink points to.
4496 This lets /boot/grub2/grubenv be a symlink to /boot/efi/EFI/fedora/grubenv
4497 even when they're different mount points, which allows grub2-editenv to be
4498 the same across platforms (i.e. UEFI vs BIOS).
4500 For example, in Fedora the GRUB EFI builds have prefix set to /EFI/fedora
4501 (on the EFI System Partition), but for BIOS machine it'll be /boot/grub2
4502 (which may or may not be its own mountpoint).
4504 With this patch, on EFI machines we can make /boot/grub2/grubenv a symlink
4505 to /boot/efi/EFI/fedora/grubenv, and the same copy of grub-set-default will
4506 work on both kinds of systems.
4508 Windows doesn't implement a readlink primitive, so the current behaviour is
4509 maintained for this operating system.
4511 Reviewed-by: Adam Jackson <ajax@redhat.com>
4512 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4514 2020-02-18 Peter Jones <pjones@redhat.com>
4516 grub-editenv: Add grub_util_readlink()
4517 Currently grub-editenv and related tools are not able to follow symbolic
4518 links when finding their config file. For example the grub-editenv create
4519 command will wrongly overwrite a symlink in /boot/grub2/grubenv with a new
4520 regular file, instead of creating a file in the path the symlink points to.
4522 A following patch will change that and add support in grub-editenv to
4523 follow symbolic links when finding the grub environment variables file.
4525 Add a grub_util_readlink() helper function that is just a wrapper around
4526 the platform specific function to read the value of a symbolic link. This
4527 helper function will be used by the following patch for grub-editenv.
4529 The helper function is not added for Windows, since this operating system
4530 doesn't have a primitive to read the contents of a symbolic link.
4532 Reviewed-by: Adam Jackson <ajax@redhat.com>
4533 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4535 2020-02-18 Robert Marshall <rmarshall@redhat.com>
4537 docs: Update info with grub.cfg netboot selection order
4538 Add documentation to the GRUB manual that specifies the order netboot
4539 clients use to select a GRUB configuration file.
4541 Also explain that the feature is enabled by default but can be disabled
4542 by setting the "feature_net_search_cfg" environment variable to "n" in
4543 an embedded configuration file.
4545 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4547 2020-02-18 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
4549 normal/main: Search for specific config files for netboot
4550 This patch implements a search for a specific configuration when the config
4551 file is on a remoteserver. It uses the following order:
4552 1) DHCP client UUID option.
4553 2) MAC address (in lower case hexadecimal with dash separators);
4554 3) IP (in upper case hexadecimal) or IPv6;
4555 4) The original grub.cfg file.
4557 This procedure is similar to what is used by pxelinux and yaboot:
4558 http://www.syslinux.org/wiki/index.php/PXELINUX#config
4560 It is enabled by default but can be disabled by setting the environment
4561 variable "feature_net_search_cfg" to "n" in an embedded configuration.
4563 Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=873406
4565 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4567 2020-02-18 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
4569 net/dhcp: Set net_<interface>_client{id, uuid} variables from DHCP options
4570 This patch sets a net_<interface>_clientid and net_<interface>_clientuuid
4571 GRUB environment variables, using the DHCP client ID and UUID options if
4574 In the same way than net_<interface>_<option> variables are set for other
4575 options such domain name, boot file, next server, etc.
4577 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4579 2020-02-18 Javier Martinez Canillas <javierm@redhat.com>
4581 net/dhcp: Consistently use decimal numbers for DHCP/BOOTP options enum
4582 The DHCP Options and BOOTP Vendor Extensions enum values are a mixture of
4583 decimal and hexadecimal numbers. Change this to consistently use decimal
4584 numbers for all since that is how these values are defined by RFC 2132.
4586 Suggested-by: Daniel Kiper <daniel.kiper@oracle.com>
4587 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4589 2020-02-18 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
4591 kern: Add %X option to printf functions
4592 The printf(3) function has support for the %X format specifier, to output
4593 an unsigned hexadecimal integer in uppercase.
4595 This can be achived in GRUB using the %x format specifier in grub_printf()
4596 and calling grub_toupper(), but it is more convenient if there is support
4597 for %X in grub_printf().
4599 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4601 2020-02-18 Javier Martinez Canillas <javierm@redhat.com>
4603 normal: Move common datetime functions out of the normal module
4604 The common datetime helper functions are currently included in the normal
4605 module, but this makes any other module that calls these functions to have
4606 a dependency with the normal module only for this reason.
4608 Since the normal module does a lot of stuff, it calls functions from other
4609 modules. But since other modules may depend on it for calling the datetime
4610 helpers, this could lead to circular dependencies between modules.
4612 As an example, when platform == xen the grub_get_datetime() function from
4613 the datetime module calls to the grub_unixtime2datetime() helper function
4614 from the normal module. Which leads to the following module dependency:
4618 and send_dhcp_packet() from the net module calls the grub_get_datetime()
4619 function, which leads to the following module dependency:
4621 net -> datetime -> normal
4623 but that means that the normal module is not allowed to depend on net or
4624 any other module that depends on it due the transitive dependency caused
4625 by datetime. A recent patch attempted to add support to fetch the config
4626 file over the network, which leads to the following circular dependency:
4628 normal -> net -> datetime -> normal
4630 So having the datetime helpers in the normal module makes it quite fragile
4631 and easy to add circular dependencies like these, that break the build due
4632 the genmoddep.awk script catching the issues.
4634 Fix this by taking the datetime helper functions out of the normal module
4635 and instead add them to the datetime module itself. Besides fixing these
4636 issues, it makes more sense to have these helper functions there anyways.
4638 Reported-by: Daniel Kiper <daniel.kiper@oracle.com>
4639 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4641 2020-02-11 Peter Jones <pjones@redhat.com>
4643 minilzo: Update to minilzo-2.08
4644 This patch updates the miniLZO library to a newer version, which among other
4645 things fixes "CVE-2014-4607 - lzo: lzo1x_decompress_safe() integer overflow"
4646 that is present in the current used in GRUB.
4648 It also updates the "GRUB Developers Manual", to mention that the library is
4649 used and describes the process to update it to a newer release when needed.
4651 Resolves: http://savannah.gnu.org/bugs/?42635
4653 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4655 2020-01-28 Peter Jones <pjones@redhat.com>
4657 squash4: Fix an uninitialized variable
4660 grub-core/fs/squash4.c: In function ‘direct_read’:
4661 grub-core/fs/squash4.c:868:10: error: ‘err’ may be used uninitialized in
4662 this function [-Werror=maybe-uninitialized]
4665 cc1: all warnings being treated as errors
4667 This patch initializes it to GRUB_ERR_NONE.
4669 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4671 2020-01-28 C. Masloch <pushbx@ulukai.org>
4673 freedos: Fix FreeDOS command booting large files (near or above 64 KiB)
4674 While testing the 86-DOS lDebug [1] booting from GRUB2, newer versions of the
4675 debugger would fail to load when booted using GRUB's freedos command. The
4676 behaviour observed in a qemu i386 machine was that the ROM-BIOS's boot load
4677 would start anew, instead of loading the selected debugger as kernel.
4679 It came to light that there was a size limit: Kernel files that were 58880
4680 bytes (E600h) long or shorter succeeded to boot, while files that were 64000
4681 bytes or longer failed in the manner described.
4683 Eventually it turned out that the relocator16 stub succeeded whenever it was
4684 placed completely within the first 64 KiB of the Low Memory Area. The chunk
4685 for the relocator is allocated with a minimum address of 0x8010 and a maximum
4686 address just below 0xA0000 [2]. That means if the kernel is, for instance,
4687 E600h bytes long, then the kernel will be allocated memory starting at 00600h
4688 (the fixed FreeDOS kernel load address) up to E600h + 00600h = 0EC00h, which
4689 leaves 1400h (5120) bytes for the relocator to stay in the first 64 KiB.
4690 If the kernel is 64000 bytes (FA00h) long, then the relocator must go to
4691 FA00h + 00600h = 10000h at least which is outside the first 64 KiB.
4693 The problem is that the relocator16 initialises the DS register with a
4694 "pseudo real mode" descriptor, which is defined with a segment limit of
4695 64 KiB and a segment base of zero. After that, the relocator addressed
4696 parts of itself (implicitly) using the DS register, with an offset from
4697 ESI, which holds the linear address of the relocator's base [3]. With the
4698 larger kernel files this would lead to accessing data beyond the 64 KiB
4699 segment limit, presumably leading to a fault and perhaps a subsequent
4700 triple-fault or such.
4702 This patch fixes the relocator to set the segment base of the descriptors
4703 to the base address of the relocator; then, the subsequent accesses to
4704 the relocator's variables are done without the ESI register as an index.
4705 This does not interfere with the relocator's or its target's normal
4706 operation; the segment limits are still loaded with 64 KiB and all the
4707 segment bases are subsequently reset by the relocator anyway.
4709 Current versions of the debugger to test are uploaded to [4]. The file
4710 ldebugnh.com (LZ4-compressed and built with -D_EXTHELP=0) at 58368 bytes
4711 loads successfully, whereas ldebug.com at 64000 bytes fails. Loading one
4712 of these files requires setting root to a FAT FS partition and using the
4713 freedos command to specify the file as kernel:
4715 set root='(hd0,msdos1)'
4719 Booting the file using the multiboot command (which uses a WIP entrypoint
4720 of the debugger) works, as it does not use GRUB's relocator16 but instead
4721 includes a loader in the kernel itself, which drops it back to 86 Mode.
4723 [1]: https://hg.ulukai.org/ecm/ldebug
4724 [2]: http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/lib/i386/relocator.c?id=495781f5ed1b48bf27f16c53940d6700c181c74c#n127
4725 [3]: http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/lib/i386/relocator16.S?id=495781f5ed1b48bf27f16c53940d6700c181c74c#n97
4726 [4]: https://ulukai.org/ecm/lDebug-5479a7988d21-nohelp.zip
4728 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4730 2020-01-10 Patrick Steinhardt <ps@pks.im>
4732 disk: Implement support for LUKS2
4733 With cryptsetup 2.0, a new version of LUKS was introduced that breaks
4734 compatibility with the previous version due to various reasons. GRUB
4735 currently lacks any support for LUKS2, making it impossible to decrypt
4736 disks encrypted with that version. This commit implements support for
4739 Note that LUKS1 and LUKS2 are quite different data formats. While they
4740 do share the same disk signature in the first few bytes, representation
4741 of encryption parameters is completely different between both versions.
4742 While the former version one relied on a single binary header, only,
4743 LUKS2 uses the binary header only in order to locate the actual metadata
4744 which is encoded in JSON. Furthermore, the new data format is a lot more
4745 complex to allow for more flexible setups, like e.g. having multiple
4746 encrypted segments and other features that weren't previously possible.
4747 Because of this, it was decided that it doesn't make sense to keep both
4748 LUKS1 and LUKS2 support in the same module and instead to implement it
4749 in two different modules luks and luks2.
4751 The proposed support for LUKS2 is able to make use of the metadata to
4752 decrypt such disks. Note though that in the current version, only the
4753 PBKDF2 key derival function is supported. This can mostly attributed to
4754 the fact that the libgcrypt library currently has no support for either
4755 Argon2i or Argon2id, which are the remaining KDFs supported by LUKS2. It
4756 wouldn't have been much of a problem to bundle those algorithms with
4757 GRUB itself, but it was decided against that in order to keep down the
4758 number of patches required for initial LUKS2 support. Adding it in the
4759 future would be trivial, given that the code structure is already in
4762 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4764 2020-01-10 Patrick Steinhardt <ps@pks.im>
4766 luks: Move configuration of ciphers into cryptodisk
4767 The luks module contains quite a lot of logic to parse cipher and
4768 cipher-mode strings like aes-xts-plain64 into constants to apply them
4769 to the grub_cryptodisk_t structure. This code will be required by the
4770 upcoming luks2 module, as well, which is why this commit moves it into
4771 its own function grub_cryptodisk_setcipher in the cryptodisk module.
4772 While the strings are probably rather specific to the LUKS modules, it
4773 certainly does make sense that the cryptodisk module houses code to set
4774 up its own internal ciphers instead of hosting that code in the luks
4777 Except for necessary adjustments around error handling, this commit does
4778 an exact move of the cipher configuration logic from luks.c to
4779 cryptodisk.c. Any behavior changes are unintentional.
4781 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4783 2020-01-10 Patrick Steinhardt <ps@pks.im>
4785 afsplitter: Move into its own module
4786 While the AFSplitter code is currently used only by the luks module,
4787 upcoming support for luks2 will add a second module that depends on it.
4788 To avoid any linker errors when adding the code to both modules because
4789 of duplicated symbols, this commit moves it into its own standalone
4790 module afsplitter as a preparatory step.
4792 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4794 2020-01-10 Patrick Steinhardt <ps@pks.im>
4796 bootstrap: Add gnulib's base64 module
4797 The upcoming support for LUKS2 disc encryption requires us to include a
4798 parser for base64-encoded data, as it is used to represent salts and
4799 digests. As gnulib already has code to decode such data, we can just
4800 add it to the boostrapping configuration in order to make it available
4803 The gnulib module makes use of booleans via the <stdbool.h> header. As
4804 GRUB does not provide any POSIX wrapper header for this, but instead
4805 implements support for bool in <sys/types.h>, we need to patch
4806 base64.h to not use <stdbool.h> anymore. We unfortunately cannot include
4807 <sys/types.h> instead, as it would then use gnulib's internal header
4808 while compiling the gnulib object but our own <sys/types.h> when
4809 including it in a GRUB module. Because of this, the patch replaces the
4810 include with a direct typedef.
4812 A second fix is required to make available _GL_ATTRIBUTE_CONST, which
4813 is provided by the configure script. As base64.h does not include
4814 <config.h>, it is thus not available and results in a compile error.
4815 This is fixed by adding an include of <config-util.h>.
4817 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4819 2020-01-10 Patrick Steinhardt <ps@pks.im>
4821 json: Implement wrapping interface
4822 While the newly added jsmn library provides the parsing interface, it
4823 does not provide any kind of interface to act on parsed tokens. Instead,
4824 the caller is expected to handle pointer arithmetics inside of the token
4825 array in order to extract required information. While simple, this
4826 requires users to know some of the inner workings of the library and is
4827 thus quite an unintuitive interface.
4829 This commit adds a new interface on top of the jsmn parser that provides
4830 convenience functions to retrieve values from the parsed json type, grub_json_t.
4832 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4834 2020-01-10 Patrick Steinhardt <ps@pks.im>
4836 json: Import upstream jsmn-1.1.0
4837 The upcoming support for LUKS2 encryption will require a JSON parser to
4838 decode all parameters required for decryption of a drive. As there is
4839 currently no other tool that requires JSON, and as gnulib does not
4840 provide a parser, we need to introduce a new one into the code base. The
4841 backend for the JSON implementation is going to be the jsmn library [1].
4842 It has several benefits that make it a very good fit for inclusion in
4845 - It is licensed under MIT.
4846 - It is written in C89.
4847 - It has no dependencies, not even libc.
4848 - It is small with only about 500 lines of code.
4849 - It doesn't do any dynamic memory allocation.
4850 - It is testen on x86, amd64, ARM and AVR.
4852 The library itself comes as a single header, only, that contains both
4853 declarations and definitions. The exposed interface is kind of
4854 simplistic, though, and does not provide any convenience features
4855 whatsoever. Thus there will be a separate interface provided by GRUB
4856 around this parser that is going to be implemented in the following
4857 commit. This change only imports jsmn.h from tag v1.1.0 and adds it
4858 unmodified to a new json module with the following command:
4860 curl -L https://raw.githubusercontent.com/zserge/jsmn/v1.1.0/jsmn.h \
4861 -o grub-core/lib/json/jsmn.h
4863 Upstream jsmn commit hash: fdcef3ebf886fa210d14956d3c068a653e76a24e
4864 Upstream jsmn commit name: Modernize (#149), 2019-04-20
4866 [1]: https://github.com/zserge/jsmn
4868 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4870 2019-12-20 Lukasz Hawrylko <lukasz.hawrylko@linux.intel.com>
4872 multiboot2: Set min address for mbi allocation to 0x1000
4873 In some cases GRUB2 allocates multiboot2 structure at 0 address, that is
4874 a confusing behavior. Consumers of that structure can have internal NULL-checks
4875 that will throw an error when get a pointer to data allocated at address 0.
4876 To prevent that, define min address for mbi allocation on x86 and x86_64
4879 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4881 2019-12-20 Paul Menzel <pmenzel@molgen.mpg.de>
4883 docs: Export "superusers" variable to apply to submenus
4884 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4886 2019-12-20 Daniel Kiper <daniel.kiper@oracle.com>
4888 loader/i386/linux: Fix an underflow in the setup_header length calculation
4889 Recent work around x86 Linux kernel loader revealed an underflow in the
4890 setup_header length calculation and another related issue. Both lead to
4891 the memory overwrite and later machine crash.
4893 Currently when the GRUB copies the setup_header into the linux_params
4894 (struct boot_params, traditionally known as "zero page") it assumes the
4895 setup_header size as sizeof(linux_i386_kernel_header/lh). This is
4896 incorrect. It should use the value calculated accordingly to the Linux
4897 kernel boot protocol. Otherwise in case of pretty old kernel, to be
4898 exact Linux kernel boot protocol, the GRUB may write more into
4899 linux_params than it was expected to. Fortunately this is not very big
4900 issue. Though it has to be fixed. However, there is also an underflow
4901 which is grave. It happens when
4903 sizeof(linux_i386_kernel_header/lh) > "real size of the setup_header".
4905 Then len value wraps around and grub_file_read() reads whole kernel into
4906 the linux_params overwriting memory past it. This leads to the GRUB
4907 memory allocator breakage and finally to its crash during boot.
4909 The patch fixes both issues. Additionally, it moves the code not related to
4910 grub_memset(linux_params)/grub_memcpy(linux_params)/grub_file_read(linux_params)
4911 section outside of it to not confuse the reader.
4913 Fixes: e683cfb0cf5 (loader/i386/linux: Calculate the setup_header length)
4915 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
4916 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
4917 Reviewed-by: Krystian Hebel <krystian.hebel@3mdeb.com>
4919 2019-12-06 David Sterba <dave@jikos.cz>
4921 btrfs: Add support for new RAID1C34 profiles
4922 New 3- and 4-copy variants of RAID1 were merged into Linux kernel 5.5.
4923 Add the two new profiles to the list of recognized ones. As this builds
4924 on the same code as RAID1, only the redundancy level needs to be
4925 adjusted, the rest is done by the existing code.
4927 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4929 2019-12-06 Lenny Szubowicz <lszubowi@redhat.com>
4931 tftp: Normalize slashes in TFTP paths
4932 Some TFTP servers do not handle multiple consecutive slashes correctly.
4933 This patch avoids sending TFTP requests with non-normalized paths.
4935 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4937 2019-11-18 Michael Chang <MChang@suse.com>
4939 grub-editenv: Warn a user against editing environment block
4940 The environment block is a preallocated 1024-byte file which serves as
4941 persistent storage for environment variables. It has its own format
4942 which is sensitive to corruption if an editor does not know how to
4943 process it. Besides that the editor may inadvertently change grubenv
4944 file size and/or make it sparse which can lead to unexpected results.
4946 This patch adds a message to the grubenv file to warn a user against
4947 editing it by tools other than grub-editenv.
4949 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
4950 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4952 2019-11-18 Michael Chang <MChang@suse.com>
4954 hostdisk: Set linux file descriptor to O_CLOEXEC as default
4955 We are often bothered by this sort of lvm warning while running grub-install
4958 File descriptor 4 (/dev/vda1) leaked on vgs invocation. Parent PID 1991: /usr/sbin/grub2-install
4960 The requirement related to the warning is dictated in the lvm man page:
4962 "On invocation, lvm requires that only the standard file descriptors stdin,
4963 stdout and stderr are available. If others are found, they get closed and
4964 messages are issued warning about the leak. This warning can be suppressed by
4965 setting the environment variable LVM_SUPPRESS_FD_WARNINGS."
4967 While it could be disabled through settings, most Linux distributions seem to
4968 enable it by default and the justification provided by the developer looks to
4969 be valid to me: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466138#15
4971 Rather than trying to close and reopen the file descriptor to the same file
4972 multiple times, which is rather cumbersome, for the sake of no vgs invocation
4973 could happen in between. This patch enables the close-on-exec flag (O_CLOEXEC)
4974 for new file descriptor returned by the open() system call, making it closed
4975 thus not inherited by the child process forked and executed by the exec()
4976 family of functions.
4978 Fixes Debian bug #466138.
4980 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4982 2019-10-28 Eli Schwartz <eschwartz@archlinux.org>
4984 grub-mkconfig: Use portable "command -v" to detect installed programs
4985 The "which" utility is not guaranteed to be installed either, and if it
4986 is, its behavior is not portable either.
4988 Conversely, the "command -v" shell builtin is required to exist in all
4989 POSIX 2008 compliant shells, and is thus guaranteed to work everywhere.
4991 Examples of open-source shells likely to be installed as /bin/sh on
4992 Linux, which implement the 11-year-old standard: ash, bash, busybox,
4993 dash, ksh, mksh and zsh.
4995 A side benefit of using the POSIX portable option is that it requires
4996 neither an external disk executable, nor (because unlike "which", the
4997 exit code is reliable) a subshell fork. This therefore represents a mild
5000 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5002 2019-10-28 Peter Jones <pjones@redhat.com>
5004 templates: Add GRUB_DISABLE_UUID
5005 The grub-mkconfig and 10_linux scripts by default attempt to use a UUID to
5006 set the root kernel command line parameter and the $root GRUB environment
5009 The former can be disabled by setting the GRUB_DISABLE_LINUX_UUID variable
5010 to "true", but there is currently no way to disable the latter.
5012 The generated grub config uses the search command with the --fs-uuid option
5013 to find the device that has to be set as $root, i.e:
5015 search --no-floppy --fs-uuid --set=root ...
5017 This is usually more reliable but in some cases it may not be appropriate,
5018 so this patch introduces a new GRUB_DISABLE_UUID variable that can be used
5019 to disable searching for the $root device by filesystem UUID.
5021 When disabled, the $root device will be set to the value specified in the
5022 device.map as found by the grub-probe --target=compatibility_hint option.
5024 When setting GRUB_DISABLE_UUID=true, the GRUB_DISABLE_LINUX_UUID and
5025 GRUB_DISABLE_LINUX_PARTUUID variables will also be set to "true" unless
5026 these have been explicitly set to "false".
5028 That way, the GRUB_DISABLE_UUID variable can be used to force using the
5029 device names for both GRUB and Linux.
5031 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5032 Reviewed-by: Nicholas Vinson <nvinson234@gmail.com>
5034 2019-10-21 Michael Bideau <mica.devel@gmail.com>
5036 at_keyboard: Fix unreliable key presses
5037 This patch fixes an issue that prevented the at_keyboard module to work
5038 (for me). The cause was a bad/wrong return value in the
5039 grub_at_keyboard_getkey() function in grub-core/term/at_keyboard.c file
5040 at line 237. My symptoms were to have an unresponsive keyboard. Keys
5041 needed to be pressed 10x and more to effectively be printed sometimes
5042 generating multiple key presses (after 1 or 2 sec of no printing). It
5043 was very problematic when typing passphrase in early stage (with
5044 GRUB_ENABLE_CRYPTODISK). When switched to "console" terminal input
5045 keyboard worked perfectly. It also worked great with the GRUB 2.02
5046 packaged by Debian (2.02+dfsg1-20). It was not an output issue but an
5049 I've managed to analyze the issue and found that it came from the commit
5050 216950a4e (at_keyboard: Split protocol from controller code.). Three
5051 lines where moved from the fetch_key() function in
5052 grub-core/term/at_keyboard.c file to the beginning of
5053 grub_at_keyboard_getkey() function (same file). However, returning -1
5054 made sense when it happened in fetch_key() function but not anymore in
5055 grub_at_keyboard_getkey() function which should return GRUB_TERM_NO_KEY.
5056 I think it was just an incomplete cut-paste missing a small manual
5057 correction. Let's fix it.
5059 Note: Commit message updated by Daniel Kiper.
5061 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5063 2019-10-21 Prarit Bhargava <prarit@redhat.com>
5065 templates: Fix bad test on GRUB_DISABLE_SUBMENU
5066 The GRUB_DISABLE_SUBMENU option is different than the others in the sense
5067 that it has to be set to "y" instead of "true" to be enabled.
5069 That causes a lot of confusion to users, some may wrongly set it to "true"
5070 expecting that will work the same than with most options, and some may set
5071 it to "yes" since for other options the value to set is a word and not a
5074 This patch changes all the grub.d scripts using the GRUB_DISABLE_SUBMENU
5075 option, so they check if it was set to "true" instead of "y", making it
5076 consistent with all the other options.
5078 But to keep backward compatibility for users that set the option to "y" in
5079 /etc/default/grub file, keep testing for this value. And also do it for
5080 "yes", since it is a common mistake made by users caused by this option
5081 being inconsistent with the others.
5083 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5085 2019-10-21 Nicholas Vinson <nvinson234@gmail.com>
5087 probe: Support probing for msdos PARTUUID
5088 Extend partition UUID probing support in GRUB core to display pseudo
5089 partition UUIDs for MBR (MSDOS) partitions.
5091 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5093 2019-09-23 Colin Watson <cjwatson@ubuntu.com>
5095 grub-mkconfig: Fix typo in --help output
5096 The short form of "--version" that grub-mkconfig accepts is "-V", not "-v".
5098 Fixes Debian bug #935504.
5100 Reviewed-by: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
5101 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5103 2019-09-23 Andreas Schwab <schwab@suse.de>
5105 grub-install: Define default platform for RISC-V
5106 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5107 Reviewed-by: Alexander Graf <agraf@csgraf.de>
5109 2019-09-23 Andreas Schwab <schwab@suse.de>
5111 RISC-V: Add __clzdi2 symbol
5112 This is needed for the zstd module build for riscv64-emu.
5114 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5116 2019-09-23 Peter Jones <pjones@redhat.com>
5118 gitattributes: Mark po/exclude.pot as binary so git won't try to diff nonprintables
5119 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5121 2019-09-23 Marcel Kolaja <mkolaja@redhat.com>
5123 grub-mkconfig: Honor a symlink when generating configuration by grub-mkconfig
5124 Honor a symlink when generating configuration by grub-mkconfig, so that
5125 the -o option follows it rather than overwriting it with a regular file.
5127 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5129 2019-09-23 Gustavo Luiz Duarte <gustavold@linux.vnet.ibm.com>
5131 net: Fix crash on http
5132 Don't free file->data on receiving FIN flag since it is used all over
5133 without checking. http_close() will be called later to free that memory.
5135 Fixes bug: https://bugzilla.redhat.com/show_bug.cgi?id=860834
5137 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5139 2019-09-23 Andre Przywara <andre.przywara@arm.com>
5141 docs: Document newly introduced net_dhcp command
5142 Commit 5bc41db756c5 ("net/dhcp: Add explicit net_dhcp command")
5143 introduced the new command "net_dhcp", which (for now) is an alias for
5144 the existing "net_bootp". Unfortunately the TEXI documentation was not
5145 adjusted accordingly.
5147 Rename the existing paragraph about net_bootp to read net_dhcp instead,
5148 and make the net_bootp stanza point to this new command.
5150 On the way add the newly parsed TFTP_SERVER_NAME and BOOTFILE_NAME
5151 packets to the list of supported DHCP options.
5153 Fixes bug: https://savannah.gnu.org/bugs/?56725
5155 Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5156 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5158 2019-07-18 James Clarke <jrtc27@jrtc27.com>
5160 [PATCH] sparc64: Fix BIOS Boot Partition support
5161 Currently, gpt_offset is uninitialised when using a BIOS Boot Partition
5162 but is used unconditionally inside save_blocklists. Instead, ensure it
5163 is always initialised to 0 (note that there is already separate code to
5164 do the equivalent adjustment after we call save_blocklists on this code
5167 This patch has been tested on a T5-2 LDOM.
5169 Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
5170 Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
5171 Reviewed-by: Eric Snowberg <eric.snowberg@oracle.com>
5174 util/setup.c | 4 +++-
5175 1 file changed, 3 insertions(+), 1 deletion(-)
5177 2019-07-11 Vladimir Serbinenko <phcoder@gmail.com>
5179 configure: Add -fno-ident when available
5180 MinGW for i386-pc without this option generates a .rdata$zzz symbol that is
5181 page-aligned and hence lzma_decompress no longer fits in its allocated space.
5182 Additionally, MinGW with -fno-ident also saves a bit of space in modules. In
5183 case of other compilers we already strip the relevant sections, so, this
5184 option has no effect.
5186 More info can be found at https://github.com/msys2/MINGW-packages/issues/21
5188 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5190 2019-07-11 Heinrich Schuchardt <xypron.glpk@gmx.de>
5192 lsefisystab: Add support for device tree table
5193 The device tree may passed by the firmware as UEFI configuration
5194 table. Let lsefisystab display a short text and not only the GUID
5195 for the device tree.
5197 Here is an example output:
5201 Signature: 5453595320494249 revision: 00020046
5202 Vendor: Das U-Boot, Version=20190700
5204 0xbe741000 eb9d2d31-2d88-11d3-9a160090273fc14d SMBIOS
5205 0x87f00000 b1b621d5-f19c-41a5-830bd9152c69aae0 DEVICE TREE
5207 Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
5208 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5210 2019-07-11 David Michael <fedora.dm0@gmail.com>
5212 smbios: Add a module for retrieving SMBIOS information
5213 The following are two use cases from Rajat Jain <rajatjain@juniper.net>:
5215 1) We have a board that boots Linux and this board itself can be plugged
5216 into one of different chassis types. We need to pass different
5217 parameters to the kernel based on the "CHASSIS_TYPE" information
5218 that is passed by the bios in the DMI/SMBIOS tables.
5220 2) We may have a USB stick that can go into multiple boards, and the
5221 exact kernel to be loaded depends on the machine information
5222 (PRODUCT_NAME etc) passed via the DMI.
5224 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5226 2019-07-11 David Michael <fedora.dm0@gmail.com>
5228 lsefisystab: Define SMBIOS3 entry point structures for EFI
5229 This adds the GUID and includes it in lsefisystab output.
5231 Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
5232 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5234 2019-07-11 David Michael <fedora.dm0@gmail.com>
5236 verifiers: Blocklist fallout cleanup
5237 Blocklist fallout cleanup after commit 5c6f9bc15 (generic/blocklist: Fix
5238 implicit declaration of function grub_file_filter_disable_compression()).
5240 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5242 2019-07-11 Andreas Schwab <schwab@suse.de>
5244 RISC-V: Fix computation of pc-relative relocation offset
5245 The offset calculation was missing the relocation addend.
5247 Tested-by: Chester Lin <clin@suse.com>
5248 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5250 2019-07-11 Leif Lindholm <leif.lindholm@linaro.org>
5252 configure: Disable arm movw/movt relocations for GCC
5253 When building for arm, we already disable movw/movt relocations for clang,
5254 since they are incompatible with PE.
5256 When building with bare metal GCC toolchains (like the one used in the
5257 travis ci scripts), we end up with these relocations again. So add an
5258 additional test for the '-mword-relocations' flag used by GCC.
5260 Reported-by: Alexander Graf <agraf@csgraf.de>
5261 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5263 2019-07-11 Jacob Kroon <jacob.kroon@gmail.com>
5265 probe: Support probing for partition UUID with --part-uuid
5266 Linux supports root=PARTUUID=<partuuid> boot argument, so add
5267 support for probing it. Compared to the fs UUID, the partition
5268 UUID does not change when reformatting a partition.
5270 For now, only disks using a GPT partition table are supported.
5272 Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
5273 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5275 2019-07-05 Daniel Kiper <daniel.kiper@oracle.com>
5277 Bump version to 2.05
5279 2019-07-04 Daniel Kiper <daniel.kiper@oracle.com>
5283 2019-06-24 Thomas Schmitt <scdbackup@gmx.net>
5285 docs: Document workaround for grub-mkrescue with older MacBooks
5286 Add a description of the workaround for firmware of older MacBooks
5287 which stalls with a grub-mkrescue ISO image for x86_64-efi target
5290 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5292 2019-06-24 Eric Snowberg <eric.snowberg@oracle.com>
5294 docs: Bootstrap changes required for older distros
5295 Some older distros do not contain gettext 0.18. Document the workaround
5296 to use the bootstrap utility on these systems.
5298 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5300 2019-06-07 Leif Lindholm <leif.lindholm@linaro.org>
5302 ia64: build fix in cache.h
5303 Add IA64 to the architectures excluding a declaration for
5304 grub_arch_sync_dma_caches().
5306 IA64 does not include any of the source files that require the function,
5307 but was overlooked for d8901e3ba115 ("cache: Fix compilation for ppc,
5310 Add it to the list of excluding architectures in order to not get
5311 missing symbol errors when running grub-mkimage.
5313 Reported-by: Alexander Graf <agraf@csgraf.de>
5314 Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
5315 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5317 2019-06-07 Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
5319 hostfs: #undef open and close.
5320 Unlike in case of disks in this case it's just a single place, so it's easier
5323 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5325 2019-06-03 John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
5327 f2fs: Disable gcc9 -Waddress-of-packed-member
5328 Disable the -Wadress-of-packaed-member diagnostic for the grub_f2fs_label
5329 function since the result is found to be false postive.
5331 A pointer to the 'volume_name' member of 'struct grub_f2fs_superblock' is
5332 guaranteed to be aligned as the offset of 'volume_name' within the struct
5333 is dividable by the natural alignment on both 32- and 64-bit targets.
5335 grub-core/fs/f2fs.c: In function ‘grub_f2fs_label’:
5336 grub-core/fs/f2fs.c:1253:60: error: taking address of packed member of ‘struct grub_f2fs_superblock’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
5337 1253 | *label = (char *) grub_f2fs_utf16_to_utf8 (data->sblock.volume_name);
5338 | ~~~~~~~~~~~~^~~~~~~~~~~~
5339 cc1: all warnings being treated as errors
5341 Reported-by: Neil MacLeod <neil@nmacleod.com>
5342 Tested-by: Neil MacLeod <neil@nmacleod.com>
5343 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5345 2019-05-20 Vincent Legoll <vincent.legoll@gmail.com>
5347 grub-mkrescue: Fix error message about the wrong command having failed: mformat instead of mcopy
5348 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5350 2019-05-20 Mathieu Trudel-Lapierre <mathieu.tl@gmail.com>
5352 video: skip 'text' gfxpayload if not supported, to fallback to default
5353 On UEFI, 'text' gfxpayload is not supported, but we still reach parse_modespec()
5354 with it, which will obviously fail. Fortunately, whatever gfxpayload is set,
5355 we still still have the 'auto' default to fall back to. Allow getting to this
5356 fallback by not trying to parse 'text' as a modespec.
5358 This is because 'text' correctly doesn't parse as a modespec, and ought to have
5359 been ignored before we got to that point, just like it is immediately picked if
5360 we're running on a system where 'text' is a supported video mode.
5362 Bug: https://savannah.gnu.org/bugs/index.php?56217
5364 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5366 2019-05-20 Ovidiu Panait <ovidiu.panait@windriver.com>
5368 grub-mkconfig: Use -c instead of --printf for stat
5369 "--printf" only works with the stat variant provided by coreutils.
5371 With busybox, stat will fail with the following error:
5372 stat: unrecognized option '--printf=%T'
5374 Usage: stat [OPTIONS] FILE...
5376 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5378 2019-05-20 Michael Chang <mchang@suse.com>
5380 f2fs: Fix gcc9 error -Werror=maybe-uninitialized
5381 The function grub_get_node_path() could return uninitialized offset with
5382 level == 0 if the block is greater than direct_index + 2 * direct_blks +
5383 2 * indirect_blks + dindirect_blks. The uninitialized offset is then used
5384 by function grub_f2fs_get_block() because level == 0 is valid and
5385 meaningful return to be processed.
5387 The fix is to set level = -1 as return value by grub_get_node_path() to
5388 signify an error that the input block cannot be handled. Any caller
5389 should therefore check level is negative or not before processing the
5392 Reported-by: Neil MacLeod <neil@nmacleod.com>
5393 Tested-by: Neil MacLeod <neil@nmacleod.com>
5394 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5396 2019-05-06 Alexander Graf <agraf@csgraf.de>
5398 arm: Align section alignment with manual relocation offset code
5399 The arm relocation code has a manual special case for EFI binaries to
5400 add the natural alignment to its own relocation awareness.
5402 Since commit a51f953f4ee87 ("mkimage: Align efi sections on 4k
5403 boundary") we changed that alignment from 0x400 to 0x1000 bytes. Reflect
5404 the change in that branch that we forgot as well.
5406 This fixes running 32bit arm grub efi binaries for me again.
5408 Fixes: a51f953f4ee87 ("mkimage: Align efi sections on 4k boundary")
5409 Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
5410 Reported-by: Steve McIntyre <steve@einval.com>
5411 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5412 Tested-by: Julien ROBIN <julien.robin28@free.fr>
5413 Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
5414 Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
5415 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5417 2019-05-06 Alexander Graf <agraf@csgraf.de>
5419 arm: Move trampolines into code section
5420 When creating T32->A32 transition jumps, the relocation code in grub
5421 will generate trampolines. These trampolines live in the .data section
5422 of our PE binary which means they are not marked as executable.
5424 This misbehavior was unmasked by commit a51f953f4ee87 ("mkimage: Align
5425 efi sections on 4k boundary") which made the X/NX boundary more obvious
5426 because everything became page aligned.
5428 To put things into proper order, let's move the arm trampolines into the
5429 .text section instead. That way everyone knows they are executable.
5431 Fixes: a51f953f4ee87 ("mkimage: Align efi sections on 4k boundary")
5432 Reported-by: Julien ROBIN <julien.robin28@free.fr>
5433 Reported-by: Leif Lindholm <leif.lindholm@linaro.org>
5434 Tested-by: Julien ROBIN <julien.robin28@free.fr>
5435 Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
5436 Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
5437 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5439 2019-04-23 Michael Chang <mchang@suse.com>
5441 efi: Fix gcc9 error -Waddress-of-packed-member
5442 The address of fp->path_name could be unaligned since seeking into the
5443 device path buffer for a given node could end in byte boundary.
5445 The fix is allocating aligned buffer by grub_malloc for holding the
5446 UTF16 string copied from fp->path_name, and after using that buffer as
5447 argument for grub_utf16_to_utf8 to convert it to UTF8 string.
5449 [ 255s] ../../grub-core/kern/efi/efi.c: In function 'grub_efi_get_filename':
5450 [ 255s] ../../grub-core/kern/efi/efi.c:410:60: error: taking address of packed member of 'struct grub_efi_file_path_device_path' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5451 [ 255s] 410 | p = (char *) grub_utf16_to_utf8 ((unsigned char *) p, fp->path_name, len);
5452 [ 255s] | ~~^~~~~~~~~~~
5453 [ 255s] ../../grub-core/kern/efi/efi.c: In function 'grub_efi_print_device_path':
5454 [ 255s] ../../grub-core/kern/efi/efi.c:900:33: error: taking address of packed member of 'struct grub_efi_file_path_device_path' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5455 [ 255s] 900 | *grub_utf16_to_utf8 (buf, fp->path_name,
5456 [ 255s] | ~~^~~~~~~~~~~
5458 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5460 2019-04-23 Michael Chang <mchang@suse.com>
5462 chainloader: Fix gcc9 error -Waddress-of-packed-member
5463 The address of fp->path_name could be unaligned since seeking into the
5464 device path buffer for a given node could end in byte boundary.
5466 The fix is using aligned buffer allocated by grub_malloc for receiving
5467 the converted UTF16 string by grub_utf8_to_utf16 and also the processing
5468 after. The resulting string then gets copied to fp->path_name.
5470 [ 243s] ../../grub-core/loader/efi/chainloader.c: In function 'copy_file_path':
5471 [ 243s] ../../grub-core/loader/efi/chainloader.c:136:32: error: taking address of packed member of 'struct grub_efi_file_path_device_path' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5472 [ 243s] 136 | size = grub_utf8_to_utf16 (fp->path_name, len * GRUB_MAX_UTF16_PER_UTF8,
5473 [ 243s] | ~~^~~~~~~~~~~
5474 [ 243s] ../../grub-core/loader/efi/chainloader.c:138:12: error: taking address of packed member of 'struct grub_efi_file_path_device_path' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5475 [ 243s] 138 | for (p = fp->path_name; p < fp->path_name + size; p++)
5478 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5480 2019-04-23 Michael Chang <mchang@suse.com>
5482 usbtest: Disable gcc9 -Waddress-of-packed-member
5483 Disable the -Wadress-of-packaed-member diagnostic for the
5484 grub_usb_get_string function since the result is false postive. The
5485 descstrp->str is found to be aligned in the buffer allocated for 'struct
5488 [ 229s] ../../grub-core/commands/usbtest.c: In function 'grub_usb_get_string':
5489 [ 229s] ../../grub-core/commands/usbtest.c:104:58: error: taking address of packed member of 'struct grub_usb_desc_str' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5490 [ 229s] 104 | *grub_utf16_to_utf8 ((grub_uint8_t *) *string, descstrp->str,
5491 [ 229s] | ~~~~~~~~^~~~~
5493 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5495 2019-04-23 Michael Chang <mchang@suse.com>
5497 acpi: Fix gcc9 error -Waddress-of-packed-member
5498 Simply adds the missing packed attribute to 'struct grub_acpi_madt'.
5500 [ 233s] ../../grub-core/commands/lsacpi.c: In function 'disp_acpi_xsdt_table':
5501 [ 233s] ../../grub-core/commands/lsacpi.c:201:27: error: converting a packed 'struct grub_acpi_table_header' pointer (alignment 1) to a 'struct grub_acpi_madt' pointer (alignment 4) may result in an unaligned pointer value [-Werror=address-of-packed-member]
5502 [ 233s] 201 | disp_madt_table ((struct grub_acpi_madt *) t);
5503 [ 233s] | ^~~~~~~~~~~~~~
5504 [ 233s] In file included from ../../grub-core/commands/lsacpi.c:23:
5505 [ 233s] ../../include/grub/acpi.h:50:8: note: defined here
5506 [ 233s] 50 | struct grub_acpi_table_header
5507 [ 233s] | ^~~~~~~~~~~~~~~~~~~~~~
5508 [ 233s] ../../include/grub/acpi.h:90:8: note: defined here
5509 [ 233s] 90 | struct grub_acpi_madt
5510 [ 233s] | ^~~~~~~~~~~~~~
5511 [ 233s] ../../grub-core/commands/lsacpi.c: In function 'disp_acpi_rsdt_table':
5512 [ 233s] ../../grub-core/commands/lsacpi.c:225:27: error: converting a packed 'struct grub_acpi_table_header' pointer (alignment 1) to a 'struct grub_acpi_madt' pointer (alignment 4) may result in an unaligned pointer value [-Werror=address-of-packed-member]
5513 [ 233s] 225 | disp_madt_table ((struct grub_acpi_madt *) t);
5514 [ 233s] | ^~~~~~~~~~~~~~
5515 [ 233s] In file included from ../../grub-core/commands/lsacpi.c:23:
5516 [ 233s] ../../include/grub/acpi.h:50:8: note: defined here
5517 [ 233s] 50 | struct grub_acpi_table_header
5518 [ 233s] | ^~~~~~~~~~~~~~~~~~~~~~
5519 [ 233s] ../../include/grub/acpi.h:90:8: note: defined here
5520 [ 233s] 90 | struct grub_acpi_madt
5521 [ 233s] | ^~~~~~~~~~~~~~
5523 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5525 2019-04-23 Michael Chang <mchang@suse.com>
5527 hfsplus: Fix gcc9 error with -Waddress-of-packed-member
5528 The catkey->name could be unaligned since the address of 'void* record'
5529 is calculated as offset in bytes to a malloc buffer.
5531 The fix is using aligned buffer allocated by grub_malloc for holding
5532 the UTF16 string copied from catkey->name. And use that buffer as
5533 argument for grub_utf16_to_utf8 to convert to UTF8 strings.
5535 In addition, using a new copy of buffer rather than catkey->name itself
5536 for processing the endianess conversion, we can also get rid of the hunk
5537 restoring byte order of catkey->name to what it was previously.
5539 [ 59s] ../grub-core/fs/hfsplus.c: In function 'list_nodes':
5540 [ 59s] ../grub-core/fs/hfsplus.c:738:57: error: taking address of packed member of 'struct grub_hfsplus_catkey' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5541 [ 59s] 738 | *grub_utf16_to_utf8 ((grub_uint8_t *) filename, catkey->name,
5542 [ 59s] | ~~~~~~^~~~~~
5543 [ 59s] ../grub-core/fs/hfsplus.c: In function 'grub_hfsplus_label':
5544 [ 59s] ../grub-core/fs/hfsplus.c:1019:57: error: taking address of packed member of 'struct grub_hfsplus_catkey' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5545 [ 59s] 1019 | *grub_utf16_to_utf8 ((grub_uint8_t *) (*label), catkey->name,
5546 [ 59s] | ~~~~~~^~~~~~
5548 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5550 2019-04-23 Michael Chang <mchang@suse.com>
5552 hfs: Fix gcc9 error -Waddress-of-packed-member
5553 Simply adds the missing packed attribute to 'struct grub_hfs_extent'.
5555 [ 83s] ../grub-core/fs/hfs.c: In function 'grub_hfs_iterate_records':
5556 [ 83s] ../grub-core/fs/hfs.c:699:9: error: taking address of packed member of 'struct grub_hfs_sblock' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5557 [ 83s] 699 | ? (&data->sblock.catalog_recs)
5558 [ 83s] | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~
5559 [ 83s] ../grub-core/fs/hfs.c:700:9: error: taking address of packed member of 'struct grub_hfs_sblock' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5560 [ 83s] 700 | : (&data->sblock.extent_recs));
5561 [ 83s] | ~^~~~~~~~~~~~~~~~~~~~~~~~~~
5563 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5565 2019-04-23 Michael Chang <mchang@suse.com>
5567 jfs: Disable gcc9 -Waddress-of-packed-member
5568 Disable the -Wadress-of-packaed-member diagnostic for the
5569 grub_jfs_getent function since the result is found to be false postive.
5571 The leaf is read into memory as continous chunks in size of 32 bytes and
5572 the pointer to its base is aligned, which also guarentee its member
5573 leaf->namepart is aligned.
5575 [ 60s] ../grub-core/fs/jfs.c: In function 'grub_jfs_getent':
5576 [ 60s] ../grub-core/fs/jfs.c:557:44: error: taking address of packed member of 'struct grub_jfs_leaf_dirent' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5577 [ 60s] 557 | le_to_cpu16_copy (filename + strpos, leaf->namepart, len < diro->data->namecomponentlen ? len
5578 [ 60s] | ~~~~^~~~~~~~~~
5579 [ 60s] ../grub-core/fs/jfs.c:570:48: error: taking address of packed member of 'struct grub_jfs_leaf_next_dirent' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5580 [ 60s] 570 | le_to_cpu16_copy (filename + strpos, next_leaf->namepart, len < 15 ? len : 15);
5581 [ 60s] | ~~~~~~~~~^~~~~~~~~~
5582 [ 60s] cc1: all warnings being treated as errors
5584 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5586 2019-04-23 Michael Chang <mchang@suse.com>
5588 cpio: Disable gcc9 -Waddress-of-packed-member
5589 Disable the -Wadress-of-packaed-member diagnostic for the
5590 grub_cpio_find_file function since the result is found to be false
5591 postive. Any pointers to member of the 'struct head hd' is aligned even
5592 if the structure is packed without paddings.
5594 [ 59s] In file included from ../grub-core/fs/cpio.c:51:
5595 [ 59s] ../grub-core/fs/cpio_common.c: In function 'grub_cpio_find_file':
5596 [ 59s] ../grub-core/fs/cpio_common.c:58:31: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5597 [ 59s] 58 | data->size = read_number (hd.filesize, ARRAY_SIZE (hd.filesize));
5598 [ 59s] | ~~^~~~~~~~~
5599 [ 59s] ../grub-core/fs/cpio_common.c:60:29: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5600 [ 59s] 60 | *mtime = read_number (hd.mtime, ARRAY_SIZE (hd.mtime));
5602 [ 59s] ../grub-core/fs/cpio_common.c:61:28: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5603 [ 59s] 61 | modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode));
5605 [ 59s] ../grub-core/fs/cpio_common.c:62:29: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5606 [ 59s] 62 | namesize = read_number (hd.namesize, ARRAY_SIZE (hd.namesize));
5607 [ 59s] | ~~^~~~~~~~~
5608 [ 59s] In file included from ../grub-core/fs/cpio_be.c:51:
5609 [ 59s] ../grub-core/fs/cpio_common.c: In function 'grub_cpio_find_file':
5610 [ 59s] ../grub-core/fs/cpio_common.c:58:31: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5611 [ 59s] 58 | data->size = read_number (hd.filesize, ARRAY_SIZE (hd.filesize));
5612 [ 59s] | ~~^~~~~~~~~
5613 [ 59s] ../grub-core/fs/cpio_common.c:60:29: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5614 [ 59s] 60 | *mtime = read_number (hd.mtime, ARRAY_SIZE (hd.mtime));
5616 [ 59s] ../grub-core/fs/cpio_common.c:61:28: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5617 [ 59s] 61 | modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode));
5619 [ 59s] ../grub-core/fs/cpio_common.c:62:29: error: taking address of packed member of 'struct head' may result in an unaligned pointer value [-Werror=address-of-packed-member]
5620 [ 59s] 62 | namesize = read_number (hd.namesize, ARRAY_SIZE (hd.namesize));
5621 [ 59s] | ~~^~~~~~~~~
5623 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5625 2019-04-23 Heinrich Schuchardt <xypron.glpk@gmx.de>
5627 efi: Avoid NULL dereference if FilePath is NULL
5628 The UEFI specification allows LoadImage() to be called with a memory
5629 location only and without a device path. In this case FilePath will not be
5630 set in the EFI_LOADED_IMAGE_PROTOCOL.
5632 So in function grub_efi_get_filename() the device path argument may be
5633 NULL. As we cannot determine the device path in this case just return NULL
5636 Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
5637 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5639 2019-04-23 Daniel Kiper <daniel.kiper@oracle.com>
5641 x86/msr: Fix build with older GCC versions
5642 Some older GCC versions produce following error when x86 MSR modules are build:
5644 In file included from commands/i386/rdmsr.c:29:0:
5645 ../include/grub/i386/rdmsr.h:27:29: error: no previous prototype for ‘grub_msr_read’ [-Werror=missing-prototypes]
5646 extern inline grub_uint64_t grub_msr_read (grub_uint32_t msr_id)
5648 cc1: all warnings being treated as errors
5650 This happens due to lack of support for a such usage of extern keyword
5651 in older GCCs. Additionally, this usage is not consistent with the rest
5652 of codebase. So, replace it with static keyword.
5654 Additionally, fix incorrect coding style.
5656 Reported-by: Eric Snowberg <eric.snowberg@oracle.com>
5657 Reported-by: adrian15 <adrian15sgd@gmail.com>
5658 Reviewed-by: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
5659 Reviewed-by: Eric Snowberg <eric.snowberg@oracle.com>
5660 Tested-by: adrian15 <adrian15sgd@gmail.com>
5662 2019-04-09 Vladimir Serbinenko <phcoder@gmail.com>
5666 2019-04-09 Vladimir Serbinenko <phcoder@gmail.com>
5668 Change fs functions to add fs_ prefix
5669 This avoid conflict with gnulib
5671 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5673 2019-04-08 Vladimir Serbinenko <phcoder@google.com>
5675 A workaround for clang problem assembling startup_raw.S
5676 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5678 2019-04-04 Eric Snowberg <eric.snowberg@oracle.com>
5680 ieee1275: NULL pointer dereference in grub_ieee1275_encode_devname()
5681 Function grub_strndup() may return NULL, this is called from
5682 function grub_ieee1275_get_devname() which is then called from
5683 function grub_ieee1275_encode_devname() to set device. The device
5684 variable could then be used with a NULL pointer.
5686 Reviewed-by: Colin Watson <cjwatson@ubuntu.com>
5687 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5689 2019-04-02 Daniel Kiper <daniel.kiper@oracle.com>
5691 docs/grub-dev: Change comments rules
5692 Current comments forms are annoying, so, some of them are disallowed
5693 starting from now. New rules are more flexible and mostly aligned
5694 with, e.g., Linux kernel comments rules.
5696 Reviewed-by: Vladimir Serbinenko <phcoder@google.com>
5698 2019-04-02 Andrew Jeddeloh <andrew.jeddeloh@coreos.com>
5700 loader/i386/linux: Calculate the setup_header length
5701 Previously the setup_header length was just assumed to be the size of the
5702 linux_kernel_params struct. The linux x86 32-bit boot protocol says that the
5703 end of the linux_i386_kernel_header is at 0x202 + the byte value at 0x201 in
5704 the linux_i386_kernel_header. So, calculate the size of the header using the
5705 end of the linux_i386_kernel_header, rather than assume it is the size of the
5706 linux_kernel_params struct.
5708 Additionally, add some required members to the linux_kernel_params
5709 struct and align the content of linux_i386_kernel_header struct with
5710 it. New members naming was taken directly from Linux kernel source.
5712 linux_kernel_params and linux_i386_kernel_header structs require more
5713 cleanup. However, this is not urgent, so, let's do this after release.
5716 Reviewed-by: Vladimir Serbinenko <phcoder@google.com>
5717 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
5719 2019-04-02 Eric Snowberg <eric.snowberg@oracle.com>
5721 efidisk: NULL pointer dereference in grub_efidisk_get_device_name()
5722 Function grub_efi_find_last_device_path() may return NULL when called
5723 from grub_efidisk_get_device_name().
5725 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5727 2019-04-02 Eric Snowberg <eric.snowberg@oracle.com>
5729 efidisk: NULL pointer dereference in is_child()
5730 Function grub_efi_find_last_device() path may return NULL when called
5733 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5735 2019-04-02 Eric Snowberg <eric.snowberg@oracle.com>
5737 efidisk: Write to NULL pointer ldp
5738 Function grub_efi_find_last_device_path() may return constant NULL when
5739 called from find_parent_device().
5741 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5743 2019-04-02 Vladimir Serbinenko <phcoder@google.com>
5745 clang: Pair -Qn with -Qunused-arguments.
5746 When assembling module wirh clang -Qn ends up on command line but later ignored
5747 To avoid it breaking the compile, add -Qunused-arguments.
5749 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5751 2019-03-28 John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
5753 ieee1275: Fix path reference in comment of sparc64 boot loader code
5754 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5756 2019-03-28 John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
5758 ieee1275: Include a.out header in assembly of sparc64 boot loader
5759 Recent versions of binutils dropped support for the a.out and COFF
5760 formats on sparc64 targets. Since the boot loader on sparc64 is
5761 supposed to be an a.out binary and the a.out header entries are
5762 rather simple to calculate in our case, we just write the header
5763 ourselves instead of relying on external tools to do that.
5765 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5767 2019-03-26 Vladimir Serbinenko <phcoder@gmail.com>
5769 Propagate GNU_PRINTF from gnulib vfprintf
5770 gnulib now replaces vfprintf and hence its format becomes GNU_PRINTF format
5772 This also fixes matching definitions to always use GNU format
5774 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5776 2019-03-26 Vladimir Serbinenko <phcoder@gmail.com>
5778 efi/tpm.c: Add missing casts
5779 Without those casts we get a warning about implicit conversion of pointer
5782 2019-03-26 Vladimir Serbinenko <phcoder@gmail.com>
5784 POTFILES: Don't include gnulib in grub.pot
5785 They're translated as a separate project, so we
5786 don't want to submit them again.
5788 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5790 2019-03-26 Vladimir Serbinenko <phcoder@google.com>
5792 configure.ac: Use nostdlib when checking for nostdinc
5793 With clang nostdinc behaviour is influenced by nostdlib. Since we
5794 always add nostdlib, add it in test as well
5796 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5798 2019-03-25 Vladimir Serbinenko <phcoder@gmail.com>
5800 efi/tpm.h: Fix hash_log_extend_event definition.
5801 I didn't check the spec but pointer to address doesn't make much sense
5802 and doesn't match the code.
5804 Rename grub_disk members
5805 Otherwise it horribly clashes with gnulib when it's
5806 replacing open/write/read/close
5808 grub-mkimagexx: Fix RISCV error message
5809 Outputting a raw pointer doesn't match the format and is
5810 also useless. Output offset instead.
5812 kern/emu/misc.c: Don't include config-util.h when running as GRUB_BUILD
5814 Support R_PPC_PLTREL24
5815 It's emitted by clang 7. It's the same as R_PPC_REL24.
5817 2019-03-20 Daniel Kiper <daniel.kiper@oracle.com>
5819 sparc: Enable __clzsi2() and __clzdi2()
5820 This patch is similiar to commit e795b9011 (RISC-V: Add libgcc helpers
5821 for clz) but for SPARC target.
5823 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
5825 2019-03-20 Daniel Kiper <daniel.kiper@oracle.com>
5827 mips: Enable __clzsi2()
5828 This patch is similiar to commit e795b9011 (RISC-V: Add libgcc helpers
5829 for clz) but for MIPS target.
5831 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
5833 2019-03-20 Daniel Kiper <daniel.kiper@oracle.com>
5835 verifiers: MIPS fallout cleanup
5836 MIPS fallout cleanup after commit 4d4a8c96e (verifiers: Add possibility
5837 to verify kernel and modules command lines).
5839 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
5841 2019-03-20 Daniel Kiper <daniel.kiper@oracle.com>
5843 verifiers: PowerPC fallout cleanup
5844 PowerPC fallout cleanup after commit 4d4a8c96e (verifiers: Add possibility
5845 to verify kernel and modules command lines) and ca0a4f689 (verifiers: File
5846 type for fine-grained signature-verification controlling).
5848 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
5850 2019-03-20 Daniel Kiper <daniel.kiper@oracle.com>
5852 verifiers: IA-64 fallout cleanup
5853 IA-64 fallout cleanup after commit 4d4a8c96e (verifiers: Add possibility
5854 to verify kernel and modules command lines).
5856 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
5858 2019-03-20 Colin Watson <cjwatson@ubuntu.com>
5860 posix_wrap: Flesh out posix_wrap/limits.h a little more
5861 In addition to what was already there, Gnulib's <intprops.h> needs SCHAR_MIN,
5862 SCHAR_MAX, SHRT_MIN, INT_MIN, LONG_MIN, and LONG_MAX. Fixes build on CentOS 7.
5864 Reported-by: "Chen, Farrah" <farrah.chen@intel.com>
5865 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5867 2019-03-19 Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
5869 xen: Look for Xen notes in section headers too
5870 Mirror behaviour of ELF loader in libxc: first look for Xen notes in
5871 PT_NOTE segment, then in SHT_NOTE section and only then fallback to
5872 a section with __xen_guest name. This fixes loading PV kernels that
5873 Xen note have outside of PT_NOTE. While this may be result of a buggy
5874 linker script, loading such kernel directly works fine, so make it work
5875 with GRUB too. Specifically, this applies to binaries built from Unikraft.
5877 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5879 2019-03-19 Colin Watson <cjwatson@ubuntu.com>
5881 getroot: Save/restore CWD more reliably on Unix
5882 Various GRUB utilities fail if the current directory doesn't exist,
5883 because grub_find_device() chdirs to a different directory and then
5884 fails when trying to chdir back. Gnulib's save-cwd module uses fchdir()
5885 instead when it can, avoiding this category of problem.
5887 Fixes Debian bug #918700.
5889 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5891 2019-03-12 Andrei Borzenkov <arvidjaar@gmail.com>
5893 net/dhcp: Add explicit net_dhcp command
5894 Mostly for cosmetic reasons, we add a "net_dhcp" command, which is (at the
5895 moment) identical to the existing "net_bootp" command. Both actually trigger
5896 a DHCP handshake now, and both should be able to deal with pure BOOTP servers.
5897 We could think about dropping the DHCP options from the initial DISCOVER packet
5898 when the user issues the net_bootp command, but it's unclear whether this is
5899 really useful, as both protocols should be able to coexist.
5901 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5903 2019-03-12 Andrei Borzenkov <arvidjaar@gmail.com>
5905 net/dhcp: Actually send out DHCPv4 DISCOVER and REQUEST messages
5906 Even though we were parsing some DHCP options sent by the server, so far
5907 we are only using the BOOTP 2-way handshake, even when talking to a DHCP
5910 Change this by actually sending out DHCP DISCOVER packets instead of the
5911 generic (mostly empty) BOOTP BOOTREQUEST packets.
5913 A pure BOOTP server would ignore the extra DHCP options in the DISCOVER
5914 packet and would just reply with a BOOTREPLY packet, which we also
5917 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5919 2019-03-12 Andrei Borzenkov <arvidjaar@gmail.com>
5921 net/dhcp: Allow receiving DHCP OFFER and ACK packets
5922 In respone to a BOOTREQUEST packet a BOOTP server would answer with a BOOTREPLY
5923 packet, which ends the conversation for good. DHCP uses a 4-way handshake,
5924 where the initial server respone is an OFFER, which has to be answered with
5925 REQUEST by the client again, only to be completed by an ACKNOWLEDGE packet
5928 Teach the grub_net_process_dhcp() function to deal with OFFER packets,
5929 and treat ACK packets the same es BOOTREPLY packets.
5931 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5933 2019-03-12 Andrei Borzenkov <arvidjaar@gmail.com>
5935 net/dhcp: Use DHCP options for name and bootfile
5936 The BOOTP RFC describes the boot file name and the server name as being part
5937 of the integral BOOTP data structure, with some limits on the size of them.
5938 DHCP extends this by allowing them to be separate DHCP options, which is more
5941 Teach the code dealing with those fields to check for those DHCP options first
5942 and use this information, if provided. We fall back to using the BOOTP
5943 information if those options are not used.
5945 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5947 2019-03-12 Andrei Borzenkov <arvidjaar@gmail.com>
5949 net/dhcp: Introduce per-interface timeout
5950 Currently we have a global timeout for all network cards in the BOOTP/DHCP
5953 Make this timeout a per-interface one, so better accommodate the upcoming
5954 4-way DHCP handshake and to also cover the lease time limit a DHCP offer
5957 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5959 2019-03-12 Andrei Borzenkov <arvidjaar@gmail.com>
5961 net/dhcp: Make grub_net_process_dhcp() take an interface
5962 Change the interface of the function dealing with incoming BOOTP packets
5963 to take an interface instead of a card, to allow more fine per-interface
5964 state (timeout, handshake state) later on.
5966 Use the opportunity to clean up the code a bit.
5968 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5970 2019-03-12 Andrei Borzenkov <arvidjaar@gmail.com>
5972 net/dhcp: Refactor DHCP packet transmission into separate function
5973 In contrast to BOOTP, DHCP uses a 4-way handshake, so requires to send
5976 Refactor the generation and sending of the BOOTREQUEST packet into
5977 a separate function, so that future code can more easily reuse this.
5979 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5981 2019-03-12 Andrei Borzenkov <arvidjaar@gmail.com>
5983 net/dhcp: Allow overloading legacy bootfile and name field
5984 DHCP specifies a special dummy option OVERLOAD, to allow DHCP options to
5985 spill over into the (legacy) BOOTFILE and SNAME fields.
5987 Parse and handle this option properly.
5989 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5991 2019-03-12 Andrei Borzenkov <arvidjaar@gmail.com>
5993 net/dhcp: Replace parse_dhcp_vendor() with find_dhcp_option()
5994 For proper DHCP support we will need to parse DHCP options from a packet
5995 more often and at various places.
5997 Refactor the option parsing into a new function, which will scan a packet to
5998 find *a particular* option field. Use that new function in places where we
5999 were dealing with DHCP options before.
6001 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6003 2019-03-12 Andrei Borzenkov <arvidjaar@gmail.com>
6005 net/dhcp: Remove dead code
6006 The comment is right, the "giaddr" fields holds the IP address of the BOOTP
6007 relay, not a general purpose router address. Just remove the commented code,
6008 archeologists can find it in the git history.
6010 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6012 2019-03-12 Jesús Diéguez Fernández <jesusdf@gmail.com>
6014 msr: Add new MSR modules (rdmsr/wrmsr)
6015 In order to be able to read from and write to model-specific registers,
6016 two new modules are added. They are i386 specific, as the cpuid module.
6018 rdmsr module registers the command rdmsr that allows reading from a MSR.
6019 wrmsr module registers the command wrmsr that allows writing to a MSR.
6021 wrmsr module is disabled if UEFI secure boot is enabled.
6023 Please note that on SMP systems, interacting with a MSR that has a scope
6024 per hardware thread, implies that the value only applies to the
6025 particular cpu/core/thread that ran the command.
6027 Also, if you specify a reserved or unimplemented MSR address, it will
6028 cause a general protection exception (which is not currently being
6029 handled) and the system will reboot.
6031 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6033 2019-03-12 Jesús Diéguez Fernández <jesusdf@gmail.com>
6035 asm: Replace "__asm__ __volatile__" with "asm volatile"
6036 In order to maintain the coding style consistency, it was requested to
6037 replace the methods that use "__asm__ __volatile__" with "asm volatile".
6039 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6041 2019-03-12 Eric Snowberg <eric.snowberg@oracle.com>
6043 sparc64: Add bios boot partition support
6044 Add BIOS Boot Partition support for sparc64 platforms. This will work a
6045 little different than x86. With GPT, both the OBP "load" and "boot" commands
6046 are partition aware and neither command can see the partition table. Therefore
6047 the entire boot-loader is stored within the BIOS Boot Partition and nothing
6048 is stored within the bootstrap code area of MBR.
6050 To use it, the end user will issue the boot command with the path pointing to
6051 the BIOS Boot Partition.
6053 For example with the disk below:
6055 Model: Unknown (unknown)
6056 Disk /dev/nvme1n1: 1600GB
6057 Sector size (logical/physical): 512B/512B
6058 Partition Table: gpt
6060 Number Start End Size File system Name Flags
6061 1 1049kB 1075MB 1074MB ext3
6062 2 1075MB 1076MB 1049kB bios_grub
6063 3 1076MB 1600GB 1599GB lvm
6065 To boot grub2 from OBP, you would use:
6067 boot /pci@302/pci@1/pci@0/pci@13/nvme@0/disk@1:b
6069 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6071 2019-03-12 Eric Snowberg <eric.snowberg@oracle.com>
6073 ieee1275: obdisk driver
6074 Add a new disk driver called obdisk for IEEE1275 platforms. Currently
6075 the only platform using this disk driver is SPARC, however other IEEE1275
6076 platforms could start using it if they so choose. While the functionality
6077 within the current IEEE1275 ofdisk driver may be suitable for PPC and x86, it
6078 presented too many problems on SPARC hardware.
6080 Within the old ofdisk, there is not a way to determine the true canonical
6081 name for the disk. Within Open Boot, the same disk can have multiple names
6082 but all reference the same disk. For example the same disk can be referenced
6083 by its SAS WWN, using this form:
6085 /pci@302/pci@2/pci@0/pci@17/LSI,sas@0/disk@w5000cca02f037d6d,0
6087 It can also be referenced by its PHY identifier using this form:
6089 /pci@302/pci@2/pci@0/pci@17/LSI,sas@0/disk@p0
6091 It can also be referenced by its Target identifier using this form:
6093 /pci@302/pci@2/pci@0/pci@17/LSI,sas@0/disk@0
6095 Also, when the LUN=0, it is legal to omit the ,0 from the device name. So with
6096 the disk above, before taking into account the device aliases, there are 6 ways
6097 to reference the same disk.
6099 Then it is possible to have 0 .. n device aliases all representing the same disk.
6100 Within this new driver the true canonical name is determined using the the
6101 IEEE1275 encode-unit and decode-unit commands when address_cells == 4. This
6102 will determine the true single canonical name for the device so multiple ihandles
6103 are not opened for the same device. This is what frequently happens with the old
6104 ofdisk driver. With some devices when they are opened multiple times it causes
6105 the entire system to hang.
6107 Another problem solved with this driver is devices that do not have a device
6108 alias can be booted and used within GRUB. Within the old ofdisk, this was not
6109 possible, unless it was the original boot device. All devices behind a SAS
6110 or SCSI parent can be found. Within the old ofdisk, finding these disks
6111 relied on there being an alias defined. The alias requirement is not
6112 necessary with this new driver. It can also find devices behind a parent
6113 after they have been hot-plugged. This is something that is not possible
6114 with the old ofdisk driver.
6116 The old ofdisk driver also incorrectly assumes that the device pointing to by a
6117 device alias is in its true canonical form. This assumption is never made with
6120 Another issue solved with this driver is that it properly caches the ihandle
6121 for all open devices. The old ofdisk tries to do this by caching the last
6122 opened ihandle. However this does not work properly because the layer above
6123 does not use a consistent device name for the same disk when calling into the
6124 driver. This is because the upper layer uses the bootpath value returned within
6125 /chosen, other times it uses the device alias, and other times it uses the
6126 value within grub.cfg. It does not have a way to figure out that these devices
6127 are the same disk. This is not a problem with this new driver.
6129 Due to the way GRUB repeatedly opens and closes the same disk. Caching the
6130 ihandle is important on SPARC. Without caching, some SAS devices can take
6131 15 - 20 minutes to get to the GRUB menu. This ihandle caching is not possible
6132 without correctly having the canonical disk name.
6134 When available, this driver also tries to use the deblocker #blocks and
6135 a way of determining the disk size.
6137 Finally and probably most importantly, this new driver is also capable of
6138 seeing all partitions on a GPT disk. With the old driver, the GPT
6139 partition table can not be read and only the first partition on the disk
6142 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6144 2019-03-12 Paul Menzel <pmenzel@molgen.mpg.de>
6146 Makefile: Allow to set file systems modules for default_payload.elf
6147 By default all file system modules are added to the GRUB coreboot
6148 payload `default_payload.elf`. This makes the image quite big,
6149 especially as often not all modules are needed.
6151 Introduce the variable `FS_PAYLOAD_MODULES`, which can be used to
6152 explicitly set file systems modules to be added.
6154 $ make default_payload.elf
6155 test -f default_payload.elf && rm default_payload.elf || true
6156 pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o default_payload.elf --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu affs afs bfs btrfs cbfs cpio cpio_be exfat ext2 f2fs fat hfs hfsplus iso9660 jfs minix minix2 minix2_be minix3 minix3_be minix_be newc nilfs2 ntfs odc procfs reiserfs romfs sfs squash4 tar udf ufs1 ufs1_be ufs2 xfs zfs password_pbkdf2 ' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=./coreboot.cfg
6157 $ ls -l default_payload.elf
6158 -rw-rw---- 1 joey joey 1199568 Mar 6 13:58 default_payload.elf
6160 $ make default_payload.elf FS_PAYLOAD_MODULES="" # ext2 already in `--modules`
6161 test -f default_payload.elf && rm default_payload.elf || true
6162 pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o default_payload.elf --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu password_pbkdf2 ' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=./coreboot.cfg
6163 $ ls -l default_payload.elf
6164 -rw-rw---- 1 joey joey 832976 Mar 7 12:13 default_payload.elf
6166 So, the resulting payload size is around 370 kB smaller. (Adding it to
6167 the CBFS, it will be compressed, so the effective size difference will
6170 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6172 2019-03-07 Vladimir Serbinenko <phcoder@gmail.com>
6174 windows/platform.c: Fix compilation errors
6176 2019-03-05 Colin Watson <cjwatson@ubuntu.com>
6178 gnulib: Upgrade Gnulib and switch to bootstrap tool
6179 Upgrade Gnulib files to 20190105.
6181 It's much easier to maintain GRUB's use of portability support files
6182 from Gnulib when the process is automatic and driven by a single
6183 configuration file, rather than by maintainers occasionally running
6184 gnulib-tool and committing the result. Removing these
6185 automatically-copied files from revision control also removes the
6186 temptation to hack the output in ways that are difficult for future
6187 maintainers to follow. Gnulib includes a "bootstrap" program which is
6190 The canonical way to bootstrap GRUB from revision control is now
6191 "./bootstrap", but "./autogen.sh" is still useful if you just want to
6192 generate the GRUB-specific parts of the build system.
6194 GRUB now requires Autoconf >= 2.63 and Automake >= 1.11, in line with
6197 Gnulib source code is now placed in grub-core/lib/gnulib/ (which should
6198 not be edited directly), and GRUB's patches are in
6199 grub-core/lib/gnulib-patches/. I've added a few notes to the developer
6200 manual on how to maintain this.
6202 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6204 2019-03-05 Colin Watson <cjwatson@ubuntu.com>
6206 syslinux: Fix syslinux_test in out-of-tree builds
6207 syslinux_parse simplifies some filenames by removing things like ".."
6208 segments, but the tests assumed that @abs_top_srcdir@ would be
6209 untouched, which is not true in the case of out-of-tree builds where
6210 @abs_top_srcdir@ may contain ".." segments.
6212 Performing the substitution requires some awkwardness in Makefile.am due
6213 to details of how config.status works.
6215 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6217 2019-03-05 Colin Watson <cjwatson@ubuntu.com>
6219 util: Detect more I/O errors
6220 Many of GRUB's utilities don't check anywhere near all the possible
6221 write errors. For example, if grub-install runs out of space when
6222 copying a file, it won't notice. There were missing checks for the
6223 return values of write, fflush, fsync, and close (or the equivalents on
6224 other OSes), all of which must be checked.
6226 I tried to be consistent with the existing logging practices of the
6227 various hostdisk implementations, but they weren't entirely consistent
6228 to start with so I used my judgement. The result at least looks
6229 reasonable on GNU/Linux when I provoke a write error:
6231 Installing for x86_64-efi platform.
6232 grub-install: error: cannot copy `/usr/lib/grub/x86_64-efi-signed/grubx64.efi.signed' to `/boot/efi/EFI/debian/grubx64.efi': No space left on device.
6234 There are more missing checks in other utilities, but this should fix
6235 the most critical ones.
6237 Fixes Debian bug #922741.
6239 Reviewed-by: Steve McIntyre <93sam@debian.org>
6240 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6242 2019-03-05 James Clarke <jrtc27@jrtc27.com>
6244 osdep/freebsd: Fix partition calculation for EBR entries
6245 For EBR partitions, "start" is the relative starting sector of the EBR
6246 header itself, whereas "offset" is the relative starting byte of the
6247 partition's contents, excluding the EBR header and any padding. Thus we
6248 must use "offset", and divide by the sector size to convert to sectors.
6250 Fixes Debian bug #923253.
6252 Reviewed-by: Colin Watson <cjwatson@ubuntu.com>
6253 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6255 2019-02-26 Steve McIntyre <93sam@debian.org>
6257 grub-install: Check for arm-efi as a default target
6258 Much like on x86, we can work out if the system is running on top of EFI
6259 firmware. If so, return "arm-efi". If not, fall back to "arm-uboot" as
6262 Split out the code to (maybe) load the efivar module and check for
6263 /sys/firmware/efi into a common helper routine is_efi_system().
6265 Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
6266 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6268 2019-02-26 Daniel Kiper <daniel.kiper@oracle.com>
6270 Revert "grub-install: Check for arm-efi as a default target"
6271 This reverts commit 082fd84d525f8d6602f892160b77c0a948308a78.
6273 Incorrect version of the patch was pushed into the git repo.
6275 Reported-by: Leif Lindholm <leif.lindholm@linaro.org>
6277 2019-02-25 Alexander Graf <agraf@suse.de>
6279 travis: Add Travis CI config file
6280 There is a really convenient service for open source project from Travis
6281 CI: They allow for free CI testing using their infrastructure.
6283 GRUB has had issues with broken builds for various targets for a long time
6284 already. The main reason is a lack of CI to just do smoke tests on whether
6285 all targets still at least compile.
6287 This patch adds a Travis config file which builds (almost) all currently
6290 On top of that, this Travis config also runs a small execution test on the
6293 All of this config file can easily be extended further on. It probably
6294 makes sense to do something similar to the u-boot test infrastructure
6295 that communicates with the payload properly. Going forward, we also will
6296 want to do more QEMU runtime checks for other targets.
6298 Currently, with this config alone, I already see about half of the available
6299 targets as broken. So it's definitely desperately needed :).
6301 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6303 2019-02-25 Steve McIntyre <93sam@debian.org>
6305 grub-install: Check for arm-efi as a default target
6306 Much like on x86, we can work out if the system is running on top
6307 of EFI firmware. If so, return "arm-efi". If not, fall back to
6308 "arm-uboot" as previously.
6310 Heavily inspired by the existing code for x86.
6312 Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
6313 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6315 2019-02-25 Leif Lindholm <leif.lindholm@linaro.org>
6317 arm64/efi: Fix grub_efi_get_ram_base()
6318 grub_efi_get_ram_base() looks for the lowest available RAM address by
6319 traversing the memory map, comparing lowest address found so far.
6320 Due to a brain glitch, that "so far" was initialized to GRUB_UINT_MAX -
6321 completely preventing boot on systems without RAM below 4GB.
6323 Change the initial value to GRUB_EFI_MAX_USABLE_ADDRESS, as originally
6326 Reported-by: Steve McIntyre <93sam@debian.org>
6327 Tested-by: Steve McIntyre <93sam@debian.org>
6328 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6330 2019-02-25 Paul Menzel <pmenzel@molgen.mpg.de>
6332 normal/menu: Do not treat error values as key presses
6333 Some terminals, like `grub-core/term/at_keyboard.c`, return `-1` in case
6334 they are not ready yet.
6336 if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS)))
6339 Currently, that is treated as a key press, and the menu time-out is
6340 cancelled/cleared. This is unwanted, as the boot is stopped and the user
6341 manually has to select a menu entry. Therefore, adapt the condition to
6342 require the key value also to be greater than 0.
6344 `GRUB_TERM_NO_KEY` is defined as 0, so the condition could be collapsed
6345 to greater or equal than (≥) 0, but the compiler will probably do that
6346 for us anyway, so keep the cases separate for clarity.
6348 This is tested with coreboot, the GRUB default payload, and the
6349 configuration file `grub.cfg` below.
6354 $ ./configure --with-platform=coreboot
6356 $ make default_payload.elf
6361 serial --unit 0 --speed 115200
6367 $ build/cbfstool build/coreboot.rom add-payload \
6368 -f /dev/shm/grub/default_payload.elf -n fallback/payload -c lzma
6369 $ build/cbfstool build/coreboot.rom add -f grub.cfg -n etc/grub.cfg -t raw
6370 $ qemu-system-x86_64 --version
6371 QEMU emulator version 3.1.0 (Debian 1:3.1+dfsg-2+b1)
6372 Copyright (c) 2003-2018 Fabrice Bellard and the QEMU Project developers
6373 $ qemu-system-x86_64 -M pc -bios build/coreboot.rom -serial stdio -nic none
6375 Currently, the time-out is cancelled/cleared. With the commit, it is not.
6376 With a small GRUB payload, this the problem is also reproducible on the
6379 Link: http://lists.gnu.org/archive/html/grub-devel/2019-01/msg00037.html
6381 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6383 2019-02-25 Alexander Graf <agraf@suse.de>
6385 fdt: Treat device tree file type like ACPI
6386 We now have signature check logic in grub which allows us to treat
6387 files differently depending on their file type.
6389 Treat a loaded device tree like an overlayed ACPI table.
6390 Both describe hardware, so I suppose their threat level is the same.
6392 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6393 Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6395 2019-02-25 Alexander Graf <agraf@suse.de>
6397 RISC-V: Add to build system
6398 This patch adds support for RISC-V to the grub build system. With this
6399 patch, I can successfully build grub on RISC-V as a UEFI application.
6401 Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6402 Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
6403 Tested-by: Bin Meng <bmeng.cn@gmail.com>
6404 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6406 2019-02-25 Alexander Graf <agraf@suse.de>
6408 RISC-V: Add libgcc helpers for clz
6409 Gcc may decide it wants to call helper functions to execute clz. Provide
6410 them in our own copy of libgcc.
6412 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6414 2019-02-25 Alexander Graf <agraf@suse.de>
6416 RISC-V: Add auxiliary files
6417 To support a new architecture we need to provide a few helper functions
6418 for memory, cache, timer, etc support.
6420 This patch adds the remainders of those. Some bits are still disabled,
6421 as I couldn't guarantee that we're always running on models / in modes
6422 where the respective hardware is available.
6424 Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6425 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6427 2019-02-25 Alexander Graf <agraf@suse.de>
6429 RISC-V: Add awareness for RISC-V reloations
6430 This patch adds awareness of RISC-V relocations throughout the grub tools
6431 as well as dynamic linkage and elf->PE relocation conversion support.
6433 Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6434 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6436 2019-02-25 Alexander Graf <agraf@suse.de>
6438 RISC-V: Add Linux load logic
6439 We currently only support to run grub on RISC-V as UEFI payload. Ideally,
6440 we also only want to support running Linux underneath as UEFI payload.
6442 Prepare that with some Linux boot stub code. Once the arm64 target is
6443 generalized, we can hook into that one and gain boot functionality.
6445 Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6446 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6448 2019-02-25 Alexander Graf <agraf@suse.de>
6450 RISC-V: Add early startup code
6451 On entry, we need to save the system table pointer as well as our image
6452 handle. Add an early startup file that saves them and then brings us
6453 into our main function.
6455 Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6456 Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
6457 Tested-by: Bin Meng <bmeng.cn@gmail.com>
6458 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6460 2019-02-25 Alexander Graf <agraf@suse.de>
6462 RISC-V: Add setjmp implementation
6463 This patch adds a 32/64 capable setjmp implementation for RISC-V.
6465 Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6466 Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
6467 Tested-by: Bin Meng <bmeng.cn@gmail.com>
6468 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6470 2019-02-25 Alexander Graf <agraf@suse.de>
6472 elf.h: Add RISC-V definitions
6473 The RISC-V ABI document outlines ELF header structure and relocation
6474 information. Pull the respective magic numbers into our elf header
6475 so we can make use of them.
6477 Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6478 Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
6479 Tested-by: Bin Meng <bmeng.cn@gmail.com>
6480 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6482 2019-02-25 Alexander Graf <agraf@suse.de>
6484 PE: Add RISC-V definitions
6485 The PE format defines magic numbers as well as relocation identifiers for
6486 RISC-V. Add them to our include file, so we can make use of them.
6488 Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
6489 Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6490 Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
6491 Tested-by: Bin Meng <bmeng.cn@gmail.com>
6492 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6494 2019-02-25 Alexander Graf <agraf@suse.de>
6496 efi: Rename armxx to arch
6497 Some architectures want to boot Linux as plain UEFI binary. Today that
6498 really only encompasses ARM and AArch64, but going forward more
6499 architectures may adopt that model.
6501 So rename our internal API accordingly.
6503 Acked-by: Leif Lindholm <leif.lindholm@linaro.org>
6504 Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6505 Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
6506 Tested-by: Bin Meng <bmeng.cn@gmail.com>
6507 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6509 2019-02-06 Alexander Graf <agraf@suse.de>
6511 mkimage: Clarify file alignment in efi case
6512 There are a few spots in the PE generation code for EFI binaries that uses
6513 the section alignment rather than file alignment, even though the alignment
6514 is really only file bound.
6516 Replace those cases with the file alignment constant instead.
6518 Reported-by: Daniel Kiper <dkiper@net-space.pl>
6519 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6520 Tested-by: Julien ROBIN <julien.robin28@free.fr>
6522 2019-02-06 Alexander Graf <agraf@suse.de>
6524 mkimage: Align efi sections on 4k boundary
6525 There is UEFI firmware popping up in the wild now that implements stricter
6526 permission checks using NX and write protect page table entry bits.
6528 This means that firmware now may fail to load binaries if its individual
6529 sections are not page aligned, as otherwise it can not ensure permission
6532 So let's bump all efi section alignments up to 4k (EFI page size). That way
6533 we will stay compatible going forward.
6535 Unfortunately our internals can't deal very well with a mismatch of alignment
6536 between the virtual and file offsets, so we have to also pad our target
6539 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6540 Tested-by: Julien ROBIN <julien.robin28@free.fr>
6542 2019-02-06 Alexander Graf <agraf@suse.de>
6544 mkimage: Use EFI32_HEADER_SIZE define in arm-efi case
6545 The efi-arm case was defining its own header size calculation, even though it's
6546 100% identical to the common EFI32_HEADER_SIZE definition.
6548 So let's clean it up to use the common define.
6550 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6551 Tested-by: Julien ROBIN <julien.robin28@free.fr>
6553 2019-02-06 Guillaume GARDET <guillaume.gardet@arm.com>
6555 arm: Move initrd upper to leave more space for kernel
6556 This patch allows to have bigger kernels. If the kernel grows, then it will
6557 overwrite the initrd when it is extracted.
6559 Acked-by: Alexander Graf <agraf@suse.de>
6560 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6562 2019-01-23 Leif Lindholm <leif.lindholm@linaro.org>
6564 linux, efi, arm*, fdt: Break FDT extra allocation space out into a #define
6565 A certain amount of dynamic space is required for the handover from
6566 GRUB/Linux-EFI-stub. This entails things like initrd addresses,
6567 address-cells entries and associated strings.
6569 But move this into a proper centralised #define rather than live-code
6572 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6574 2019-01-22 Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
6576 uboot: Add the missing disk write operation support
6577 uboot_disk_write() is currently lacking the write support
6578 to storage devices because, historically, those devices did not
6579 implement block_write() in U-Boot.
6581 The solution has been tested using a patched U-Boot loading
6582 and booting GRUB in a QEMU vexpress-a9 environment.
6583 The disk write operations were triggered with GRUB's save_env
6586 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6588 2019-01-21 Max Tottenham <mtottenh@akamai.com>
6590 tpm: Fix bug in GRUB2 TPM module
6591 The value of tpm_handle changes between successive calls to grub_tpm_handle_find(),
6592 as instead of simply copying the stored pointer we end up taking the address of
6593 said pointer when using the cached value of grub_tpm_handle.
6595 This causes grub_efi_open_protocol() to return a nullptr in grub_tpm2_execute()
6596 and grub_tpm2_log_event(). Said nullptr goes unchecked and
6597 efi_call_5(tpm->hash_log_extend_event,...) ends up jumping to 0x0, Qemu crashes
6598 once video ROM is reached at 0xb0000.
6600 This patch seems to do the trick of fixing that bug, but we should also ensure
6601 that all calls to grub_efi_open_protocol() are checked so that we don't start
6602 executing low memory.
6604 Reviewed-by: Matthew Garrett <mjg59@google.com>
6605 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6607 2019-01-14 Colin Watson <cjwatson@ubuntu.com>
6609 pgp: Fix emu build and tests after pgp module renaming
6610 Commit b07feb8746c3bb845e3f0d33d37c0bded704d14d (verifiers: Rename
6611 verify module to pgp module) renamed the "verify" module to "pgp", but
6612 the GRUB_MOD_INIT and GRUB_MOD_FINI macros were left as "verify", which
6613 broke the emu target build; and file_filter_test still referred to the
6614 now non-existent "verify" module. Fix both of these.
6616 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6618 2019-01-14 Peter Große <pegro@friiks.de>
6620 grub-mkconfig/20_linux_xen: Support multiple early initrd images
6621 Add support for multiple, shared, early initrd images. These early
6622 images will be loaded in the order declared, and all will be loaded
6623 before the initrd image.
6625 While many classes of data can be provided by early images, the
6626 immediate use case would be for distributions to provide CPU
6627 microcode to mitigate the Meltdown and Spectre vulnerabilities.
6629 Xen has also support to load microcode updates provided as additional
6630 modules by the bootloader.
6632 There are two environment variables provided for declaring the early
6635 * GRUB_EARLY_INITRD_LINUX_STOCK is for the distribution declare
6636 images that are provided by the distribution or installed packages.
6637 If undeclared, this will default to a set of common microcode image
6640 * GRUB_EARLY_INITRD_LINUX_CUSTOM is for user created images. User
6641 images will be loaded after the stock images.
6643 These separate configurations allow the distribution and user to
6644 declare different image sets without clobbering each other.
6646 This also makes a minor update to ensure that UUID partition labels
6647 stay disabled when no initrd image is found, even if early images are
6650 This is basically a copy of a698240d "grub-mkconfig/10_linux: Support
6651 multiple early initrd images" by Matthew S. Turnbull.
6653 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6655 2019-01-14 Heinrich Schuchardt <xypron.glpk@gmx.de>
6657 grub-core/loader/efi/fdt.c: Do not copy random memory
6658 We should not try to copy any memory area which is outside of the original
6659 fdt. If this extra memory is controlled by a hypervisor this might end
6662 Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
6663 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6665 2018-12-12 Matthew Garrett <matthewgarrett@google.com>
6667 verifiers: Add TPM documentation
6668 Describe the behaviour of GRUB when the TPM module is in use.
6670 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6672 2018-12-12 Matthew Garrett <mjg59@google.com>
6674 verifiers: Core TPM support
6675 Add support for performing basic TPM measurements. Right now this only
6676 supports extending PCRs statically and only on UEFI. In future we might
6677 want to have some sort of mechanism for choosing which events get logged
6678 to which PCRs, but this seems like a good default policy and we can wait
6679 to see whether anyone has a use case before adding more complexity.
6681 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6683 2018-12-12 Matthew Garrett <mjg59@google.com>
6685 verifiers: Verify commands executed by grub
6686 Pass all commands executed by GRUB to the verifiers layer. Most verifiers will
6687 ignore this, but some (such as the TPM verifier) want to be able to measure and
6688 log each command executed in order to ensure that the boot state is as expected.
6690 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6692 2018-12-12 Juergen Gross <jgross@suse.com>
6694 xen_pvh: Add support to configure
6695 Support platform i386/xen_pvh in configure.
6697 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6698 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6700 2018-12-12 Juergen Gross <jgross@suse.com>
6702 xen_pvh: Support grub-install for xen_pvh
6703 Add xen_pvh support to grub-install.
6705 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6706 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6708 2018-12-12 Juergen Gross <jgross@suse.com>
6710 xen_pvh: Support building a standalone image
6711 Support mkimage for xen_pvh.
6713 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6714 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6716 2018-12-12 Juergen Gross <jgross@suse.com>
6718 xen: Use elfnote defines instead of plain numbers
6719 In order to avoid using plain integers for the ELF notes use the
6720 available Xen include instead.
6722 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6723 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6725 2018-12-12 Hans van Kranenburg <hans@knorrie.org>
6727 grub-module-verifier: Ignore all_video for xen_pvh
6728 This solves the build failing with "Error: no symbol table and no
6732 - 6371e9c10433578bb236a8284ddb9ce9e201eb59
6733 - https://savannah.gnu.org/bugs/?49012
6735 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6736 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6738 2018-12-12 Juergen Gross <jgross@suse.com>
6740 xen_pvh: Add build runes for grub-core
6741 Add the modifications to the build system needed to build a xen_pvh
6744 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6745 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6747 2018-12-12 Juergen Gross <jgross@suse.com>
6749 xen: Init memory regions for PVH
6750 Add all usable memory regions to grub memory management and add the
6751 needed mmap iterate code, which will be used by grub core (e.g.
6752 grub-core/lib/relocator.c or grub-core/mmap/mmap.c).
6754 As we are running in 32-bit mode don't add memory above 4GB.
6756 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6757 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6759 2018-12-12 Juergen Gross <jgross@suse.com>
6761 xen: Setup Xen specific data for PVH
6762 Initialize the needed Xen specific data. This is:
6764 - the Xen start of day page containing the console and Xenstore ring
6765 page PFN and event channel
6767 - the shared info page
6769 Write back the possibly modified memory map to the hypervisor in case
6770 the guest is reading it from there again.
6772 Set the RSDP address for the guest from the start_info page passed
6775 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6776 Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
6777 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6779 2018-12-12 Juergen Gross <jgross@suse.com>
6781 xen: Get memory map from hypervisor for PVH
6782 Retrieve the memory map from the hypervisor and normalize it to contain
6783 no overlapping entries and to be sorted by address.
6785 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6786 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6788 2018-12-12 Juergen Gross <jgross@suse.com>
6790 xen: Setup hypercall page for PVH
6791 Add the needed code to setup the hypercall page for calling into the
6794 Import the XEN_HVM_DEBUGCONS_IOPORT define from Xen unstable into
6795 include/xen/arch-x86/xen.h
6797 Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
6798 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6799 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6801 2018-12-12 Juergen Gross <jgross@suse.com>
6803 xen: Add PVH boot entry code
6804 Add the code for the Xen PVH mode boot entry.
6806 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6807 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6809 2018-12-12 Juergen Gross <jgross@suse.com>
6811 xen: Add basic hooks for PVH in current code
6812 Add the hooks to current code needed for Xen PVH. They will be filled
6813 with code later when the related functionality is being added.
6815 loader/i386/linux.c needs to include machine/kernel.h now as it needs
6816 to get GRUB_KERNEL_USE_RSDP_ADDR from there. This in turn requires to
6817 add an empty kernel.h header for some i386 platforms (efi, coreboot,
6818 ieee1275, xen) and for x86_64 efi.
6820 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6821 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6823 2018-12-12 Juergen Gross <jgross@suse.com>
6825 xen: Add PVH specific defines to offset.h
6826 include/grub/offsets.h needs some defines for Xen PVH mode.
6828 Add them. While at it line up the values in the surrounding lines to
6829 start at the same column.
6831 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6832 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6834 2018-12-12 Juergen Gross <jgross@suse.com>
6836 xen: Modify grub_xen_ptr2mfn() for Xen PVH
6837 grub_xen_ptr2mfn() returns the machine frame number for a given pointer
6838 value. For Xen-PVH guests this is just the PFN. Add the PVH specific
6841 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6842 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6844 2018-12-12 Juergen Gross <jgross@suse.com>
6846 xen: Rearrange xen/init.c to prepare it for Xen PVH mode
6847 Rearrange grub-core/kern/xen/init.c to prepare adding PVH mode support
6848 to it. This includes putting some code under #ifdef GRUB_MACHINE_XEN
6849 as it will not be used when running as PVH.
6851 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6852 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6854 2018-12-12 Juergen Gross <jgross@suse.com>
6856 xen: Add some dummy headers for PVH mode
6857 With Xen PVH mode adding a new machine type the machine related headers
6858 need to be present for the build to succeed. Most of the headers just
6859 need to include the related common i386 headers. Add those to the tree.
6861 Note that xen_pvh/int.h needs to include pc/int_types.h instead of
6862 pc/int.h in order to avoid the definition of grub_bios_interrupt().
6864 xen_pvh/memory.h needs to include coreboot/memory.h (like some other
6865 <machine>/memory.h do as well) as this contains just the needed stubs.
6867 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6868 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6870 2018-12-12 Juergen Gross <jgross@suse.com>
6872 xen: Prepare common code for Xen PVH support
6873 Some common code needs to be special cased for Xen PVH mode. This hits
6874 mostly Xen PV mode specific areas.
6876 Split include/grub/i386/pc/int_types.h off from
6877 include/grub/i386/pc/int.h to support including this file later from
6878 xen_pvh code without the grub_bios_interrupt definition.
6880 Move definition of struct grub_e820_mmap_entry from
6881 grub-core/mmap/i386/pc/mmap.c to include/grub/i386/memory.h in order
6882 to make it usable from xen_pvh code.
6884 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6885 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6887 2018-12-12 Juergen Gross <jgross@suse.com>
6889 xen: Carve out grant tab initialization into dedicated function
6890 Initialize the grant tab in a dedicated function. This will enable
6891 using it for PVH guests, too.
6893 Call the new function from grub_machine_init() as this will later
6894 be common between Xen PV and Xen PVH mode.
6896 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6897 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6899 2018-12-12 Juergen Gross <jgross@suse.com>
6901 loader/linux: Support passing RSDP address via boot params
6902 Xen PVH guests will have the RSDP at an arbitrary address. Support that
6903 by passing the RSDP address via the boot parameters to Linux.
6905 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6906 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6908 2018-12-12 Juergen Gross <jgross@suse.com>
6910 xen: Add some Xen headers
6911 In order to support grub2 in Xen PVH environment some additional Xen
6912 headers are needed as grub2 will be started in PVH mode requiring to
6913 use several HVM hypercalls and structures.
6915 Add the needed headers from Xen 4.10 being the first Xen version with
6916 full (not only experimental) PVH guest support.
6918 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6919 Tested-by: Hans van Kranenburg <hans@knorrie.org>
6921 2018-12-07 Daniel Kiper <daniel.kiper@oracle.com>
6923 verifiers: ARM Xen fallout cleanup
6924 ARM Xen fallout cleanup after commit ca0a4f689 (verifiers: File type for
6925 fine-grained signature-verification controlling).
6927 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
6929 2018-12-07 Daniel Kiper <daniel.kiper@oracle.com>
6931 verifiers: Xen fallout cleanup
6932 Xen fallout cleanup after commit ca0a4f689 (verifiers: File type for
6933 fine-grained signature-verification controlling).
6935 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
6937 2018-11-28 Eric Snowberg <eric.snowberg@oracle.com>
6939 ofnet: Fix build regression in grub_ieee1275_parse_bootpath()
6940 The grub_ieee1275_parse_bootpath() function (commit a661a32, ofnet: Initialize
6941 structs in bootpath parser) introduces a build regression on SPARC:
6943 cc1: warnings being treated as errors
6944 net/drivers/ieee1275/ofnet.c: In function 'grub_ieee1275_parse_bootpath':
6945 net/drivers/ieee1275/ofnet.c:156: error: missing initializer
6946 net/drivers/ieee1275/ofnet.c:156: error: (near initialization for 'client_addr.type')
6947 net/drivers/ieee1275/ofnet.c:156: error: missing initializer
6948 net/drivers/ieee1275/ofnet.c:156: error: (near initialization for 'gateway_addr.type')
6949 net/drivers/ieee1275/ofnet.c:156: error: missing initializer
6950 net/drivers/ieee1275/ofnet.c:156: error: (near initialization for 'subnet_mask.type')
6951 net/drivers/ieee1275/ofnet.c:157: error: missing initializer
6952 net/drivers/ieee1275/ofnet.c:157: error: (near initialization for 'hw_addr.type')
6953 make[3]: *** [net/drivers/ieee1275/ofnet_module-ofnet.o] Error 1
6955 Initialize the entire structure.
6957 More info can be found here:
6958 http://lists.gnu.org/archive/html/grub-devel/2018-03/msg00034.html
6960 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6962 2018-11-26 Nick Terrell <terrelln@fb.com>
6964 btrfs: Add zstd support to grub btrfs
6965 - Adds zstd support to the btrfs module.
6966 - Adds a test case for btrfs zstd support.
6967 - Changes top_srcdir to srcdir in the btrfs module's lzo include
6968 following comments from Daniel Kiper about the zstd include.
6970 Tested on Ubuntu-18.04 with a btrfs /boot partition with and without zstd
6971 compression. A test case was also added to the test suite that fails before
6972 the patch, and passes after.
6974 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
6976 2018-11-26 Nick Terrell <terrelln@fb.com>
6978 zstd: Import upstream zstd-1.3.6
6979 - Import zstd-1.3.6 from upstream
6980 - Add zstd's module.c file
6981 - Add the zstd module to Makefile.core.def
6983 Import zstd-1.3.6 from upstream [1]. Only the files need for decompression
6984 are imported. I used the latest zstd release, which includes patches [2] to
6985 build cleanly in GRUB.
6987 I included the script used to import zstd-1.3.6 below at the bottom of the
6990 Upstream zstd commit hash: 4fa456d7f12f8b27bd3b2f5dfd4f46898cb31c24
6991 Upstream zstd commit name: Merge pull request #1354 from facebook/dev
6993 Zstd requires some posix headers, which it gets from posix_wrap.
6994 This can be checked by inspecting the .Po files generated by automake,
6995 which contain the header dependencies. After building run the command
6996 `cat grub-core/lib/zstd/.deps-core/*.Po` to see the dependencies [3].
6997 The only OS dependencies are:
6999 - stddef.h, which is already a dependency in posix_wrap, and used for size_t
7001 - stdarg.h, which comes from the grub/misc.h header, and we don't use in zstd.
7003 All the types like uint64_t are typedefed to grub_uint64_t under the hood.
7004 The only exception is size_t, which comes from stddef.h. This is already the
7005 case for lzo and xz. I don't think there are any cross-compilation concerns,
7006 because cross-compilers provide their own system headers (and it would already
7009 [1] https://github.com/facebook/zstd/releases/tag/v1.3.6
7010 [2] https://github.com/facebook/zstd/pull/1344
7011 [3] https://gist.github.com/terrelln/7a16b92f5a1b3aecf980f944b4a966c4
7015 curl -L -O https://github.com/facebook/zstd/releases/download/v1.3.6/zstd-1.3.6.tar.gz
7016 curl -L -O https://github.com/facebook/zstd/releases/download/v1.3.6/zstd-1.3.6.tar.gz.sha256
7017 sha256sum --check zstd-1.3.6.tar.gz.sha256
7018 tar xzf zstd-1.3.6.tar.gz
7020 SRC_LIB="zstd-1.3.6/lib"
7021 DST_LIB="grub-core/lib/zstd"
7024 cp $SRC_LIB/zstd.h $DST_LIB/
7025 cp $SRC_LIB/common/*.[hc] $DST_LIB/
7026 cp $SRC_LIB/decompress/*.[hc] $DST_LIB/
7027 rm $DST_LIB/{pool.[hc],threading.[hc]}
7032 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7034 2018-11-21 Michael Chang <mchang@suse.com>
7036 verifiers: fix double close on pgp's sig file descriptor
7037 An error emerged as when I was testing the verifiers branch, so instead
7038 of putting it in pgp prefix, the verifiers is used to reflect what the
7041 While running verify_detached, grub aborts with error.
7043 verify_detached /@/.snapshots/1/snapshot/boot/grub/grub.cfg
7044 /@/.snapshots/1/snapshot/boot/grub/grub.cfg.sig
7046 alloc magic is broken at 0x7beea660: 0
7047 Aborted. Press any key to exit.
7049 The error is caused by sig file descriptor been closed twice, first time
7050 in grub_verify_signature() to which it is passed as parameter. Second in
7051 grub_cmd_verify_signature() or in whichever opens the sig file
7052 descriptor. The second close is not consider as bug to me either, as in
7053 common rule of what opens a file has to close it to avoid file
7056 After all the design of grub_verify_signature() makes it difficult to keep
7057 a good trace on opened file descriptor from it's caller. Let's refine
7058 the application interface to accept file path rather than descriptor, in
7059 this way the caller doesn't have to care about closing the descriptor by
7060 delegating it to grub_verify_signature() with full tracing to opened
7061 file descriptor by itself.
7063 Also making it clear that sig descriptor is not referenced in error
7064 returning path of grub_verify_signature_init(), so it can be closed
7065 directly by it's caller. This also makes delegating it to
7066 grub_pubkey_close() infeasible to help in relieving file descriptor
7067 leakage as it has to depend on uncertainty of ctxt fields in error
7070 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7072 2018-11-21 Lee Jones <lee.jones@linaro.org>
7074 generic/blocklist: Fix implicit declaration of function grub_file_filter_disable_compression()
7075 grub_file_filter_disable_compression() no longer exists.
7077 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7079 2018-11-21 Lee Jones <lee.jones@linaro.org>
7081 arm64/xen: Fix too few arguments to function grub_create_loader_cmdline()
7082 Without this fix, building xen_boot.c omits:
7084 loader/arm64/xen_boot.c: In function ‘xen_boot_binary_load’:
7085 loader/arm64/xen_boot.c:370:7: error: too few arguments to function ‘grub_create_loader_cmdline’
7086 grub_create_loader_cmdline (argc - 1, argv + 1, binary->cmdline,
7087 ^~~~~~~~~~~~~~~~~~~~~~~~~~
7088 In file included from loader/arm64/xen_boot.c:36:0:
7089 ../include/grub/lib/cmdline.h:29:12: note: declared here
7090 grub_err_t grub_create_loader_cmdline (int argc, char *argv[], char *buf,
7092 Reviewed-by: Julien Grall <julien.grall@arm.com>
7093 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7095 2018-11-16 Leif Lindholm <leif.lindholm@linaro.org>
7097 arm-uboot, ia64, sparc64: Fix up grub_file_open() calls
7098 The verifiers framework changed the grub_file_open() interface, breaking all
7099 non-x86 linux loaders. Add file types to the grub_file_open() calls to make
7102 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7104 2018-11-16 Leif Lindholm <leif.lindholm@linaro.org>
7106 arm64/efi: Fix breakage caused by verifiers
7107 - add variable "err" (used but not defined),
7108 - add GRUB_FILE_TYPE_LINUX_KERNEL to grub_file_open() call.
7110 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7112 2018-11-16 Leif Lindholm <leif.lindholm@linaro.org>
7114 grub-core/loader/efi/fdt.c: Fixup grub_file_open() call
7115 The verifiers framework changed the API of grub_file_open(), but did not
7116 fix up all users. Add the file type GRUB_FILE_TYPE_DEVICE_TREE_IMAGE
7117 to the "devicetree" command handler call.
7119 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7121 2018-11-16 Leif Lindholm <leif.lindholm@linaro.org>
7123 include/grub/file.h: Add device tree file type
7124 The API change of grub_file_open() for adding verifiers did not include
7125 a type for device tree blobs. Add GRUB_FILE_TYPE_DEVICE_TREE_IMAGE to
7126 the grub_file_type enum.
7128 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7130 2018-11-16 Leif Lindholm <leif.lindholm@linaro.org>
7132 include/grub/verify.h: Add include guard
7133 verify.h was added without include guards. This means compiling anything
7134 including both include/grub/verify.h and include/grub/lib/cmdline.h fails
7135 (at least grub-core/loader/arm64/linux.c.
7137 Add the necessary include guard.
7139 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7141 2018-11-16 Matthew Daley <mattd@bugfuzz.com>
7143 mkimage: Pad DTBs to target-specific pointer size
7144 Device tree (DTB) lengths are being padded to a multiple of 4 bytes
7145 rather than the target-specific pointer size. This causes objects
7146 following OBJ_TYPE_DTB objects to be incorrectly parsed during GRUB
7149 Fix by using ALIGN_ADDR(), not ALIGN_UP().
7151 Signed-by-off: Matthew Daley <mattd@bugfuzz.com>
7152 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7154 2018-11-09 Colin Watson <cjwatson@ubuntu.com>
7156 Cope with / being on a ZFS root dataset
7157 If / is on the root dataset in a ZFS pool, then ${bootfs} will be set to
7158 "/" (whereas if it is on a non-root dataset, there will be no trailing
7159 slash). Passing "root=ZFS=${rpool}/" will fail to boot, but
7160 "root=ZFS=${rpool}" works fine, so strip the trailing slash.
7162 Fixes: https://savannah.gnu.org/bugs/?52746
7164 Tested-by: Fejes József <jozsef.fejes@gmail.com>
7165 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7167 2018-11-09 Paul Menzel <pmenzel@molgen.mpg.de>
7169 unix/platform: Initialize variable to fix grub-install on UEFI system
7170 On a UEFI system, were no boot entry *grub* is present, currently,
7171 `grub-install` fails with an error.
7176 BootOrder: 0001,0006,0003,0004,0005
7177 Boot0001 Diskette Drive
7178 Boot0003* USB Storage Device
7179 Boot0004* CD/DVD/CD-RW Drive
7180 Boot0005 Onboard NIC
7181 Boot0006* WDC WD2500AAKX-75U6AA0
7182 $ sudo grub-install /dev/sda
7183 Installing for x86_64-efi platform.
7184 grub-install: error: efibootmgr failed to register the boot entry: Unknown error 22020.
7186 The error code is always different, and the error message (incorrectly)
7187 points to efibootmgr.
7189 But, the error is in GRUB’s function
7190 `grub_install_remove_efi_entries_by_distributor()`, where the variable
7191 `rc` for the return value, is uninitialized and never set, when no boot
7192 entry for the distributor is found.
7194 The content of that uninitialized variable is then returned as the error
7197 Set the variable to 0, so that success is returned, when no entry needs
7200 Tested on Dell OptiPlex 7010 with firmware A28.
7202 $ sudo ./grub-install /dev/sda
7203 Installing for x86_64-efi platform.
7204 Installation finished. No error reported.
7206 [1]: https://github.com/rhboot/efibootmgr/issues/100
7208 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7210 2018-11-09 Daniel Kiper <daniel.kiper@oracle.com>
7212 efi: Add EFI shim lock verifier
7213 This module provides shim lock verification for various kernels
7214 if UEFI secure boot is enabled on a machine.
7216 It is recommended to put this module into GRUB2 standalone image
7217 (avoid putting iorw and memrw modules into it; they are disallowed
7218 if UEFI secure boot is enabled). However, it is also possible to use
7219 it as a normal module. Though such configurations are more fragile
7220 and less secure due to various limitations.
7222 If the module is loaded and UEFI secure boot is enabled then:
7223 - module itself cannot be unloaded (persistent module),
7224 - the iorw and memrw modules cannot be loaded,
7225 - if the iorw and memrw modules are loaded then
7226 machine boot is disabled,
7227 - GRUB2 defers modules and ACPI tables verification to
7230 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
7232 2018-11-09 Daniel Kiper <daniel.kiper@oracle.com>
7234 dl: Add support for persistent modules
7235 This type of modules cannot be unloaded. This is useful if a given
7236 functionality, e.g. UEFI secure boot shim signature verification, should
7237 not be disabled if it was enabled at some point in time. Somebody may
7238 say that we can use standalone GRUB2 here. That is true. However, the
7239 code is not so big nor complicated hence it make sense to support
7240 modularized configs too.
7242 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
7244 2018-11-09 Vladimir Serbinenko <phcoder@gmail.com>
7246 verifiers: Add the documentation
7247 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
7249 2018-11-09 Daniel Kiper <daniel.kiper@oracle.com>
7251 verifiers: Rename verify module to pgp module
7252 Just for clarity. No functional change.
7254 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
7256 2018-11-09 Daniel Kiper <daniel.kiper@oracle.com>
7258 verifiers: Add possibility to defer verification to other verifiers
7259 This way if a verifier requires verification of a given file it can defer task
7260 to another verifier (another authority) if it is not able to do it itself. E.g.
7261 shim_lock verifier, posted as a subsequent patch, is able to verify only PE
7262 files. This means that it is not able to verify any of GRUB2 modules which have
7263 to be trusted on UEFI systems with secure boot enabled. So, it can defer
7264 verification to other verifier, e.g. PGP one.
7266 I silently assume that other verifiers are trusted and will do good job for us.
7267 Or at least they will not do any harm.
7269 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
7271 2018-11-09 Vladimir Serbinenko <phcoder@gmail.com>
7273 verifiers: Add possibility to verify kernel and modules command lines
7274 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
7276 2018-11-09 Vladimir Serbinenko <phcoder@gmail.com>
7278 verifiers: Framework core
7279 Verifiers framework provides core file verification functionality which
7280 can be used by various security mechanisms, e.g., UEFI secure boot, TPM,
7281 PGP signature verification, etc.
7283 The patch contains PGP code changes and probably they should be extracted
7284 to separate patch for the sake of clarity.
7286 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
7288 2018-11-09 Vladimir Serbinenko <phcoder@gmail.com>
7290 verifiers: File type for fine-grained signature-verification controlling
7291 Let's provide file type info to the I/O layer. This way verifiers
7292 framework and its users will be able to differentiate files and verify
7295 This is preparatory patch.
7297 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
7299 2018-11-09 Daniel Kiper <daniel.kiper@oracle.com>
7301 bufio: Use grub_size_t instead of plain int for size
7302 Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
7304 2018-10-31 Goffredo Baroncelli <kreijack@inwind.it>
7306 btrfs: Add RAID 6 recovery for a btrfs filesystem
7307 Add the RAID 6 recovery, in order to use a RAID 6 filesystem even if some
7308 disks (up to two) are missing. This code use the md RAID 6 code already
7311 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7313 2018-10-31 Goffredo Baroncelli <kreijack@inwind.it>
7315 btrfs: Make more generic the code for RAID 6 rebuilding
7316 The original code which handles the recovery of a RAID 6 disks array
7317 assumes that all reads are multiple of 1 << GRUB_DISK_SECTOR_BITS and it
7318 assumes that all the I/O is done via the struct grub_diskfilter_segment.
7319 This is not true for the btrfs code. In order to reuse the native
7320 grub_raid6_recover() code, it is modified to not call
7321 grub_diskfilter_read_node() directly, but to call an handler passed
7324 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7326 2018-10-31 Goffredo Baroncelli <kreijack@inwind.it>
7328 btrfs: Add support for recovery for a RAID 5 btrfs profiles
7329 Add support for recovery for a RAID 5 btrfs profile. In addition
7330 it is added some code as preparatory work for RAID 6 recovery code.
7332 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7334 2018-10-31 Goffredo Baroncelli <kreijack@inwind.it>
7336 btrfs: Refactor the code that read from disk
7337 Move the code in charge to read the data from disk into a separate
7338 function. This helps to separate the error handling logic (which
7339 depends on the different raid profiles) from the read from disk
7340 logic. Refactoring this code increases the general readability too.
7342 This is a preparatory patch, to help the adding of the RAID 5/6 recovery code.
7344 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7346 2018-10-31 Goffredo Baroncelli <kreijack@inwind.it>
7348 btrfs: Move logging code in grub_btrfs_read_logical()
7349 A portion of the logging code is moved outside of internal for(;;). The part
7350 that is left inside is the one which depends on the internal for(;;) index.
7352 This is a preparatory patch. The next one will refactor the code inside
7353 the for(;;) into an another function.
7355 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7357 2018-10-31 Goffredo Baroncelli <kreijack@inwind.it>
7359 btrfs: Avoid a rescan for a device which was already not found
7360 Currently read from missing device triggers rescan. However, it is never
7361 recorded that the device is missing. So, each read of a missing device
7362 triggers rescan again and again. This behavior causes a lot of unneeded
7363 rescans leading to huge slowdowns.
7365 This patch fixes above mentioned issue. Information about missing devices
7366 is stored in the data->devices_attached[] array as NULL value in dev
7367 member. Rescan is triggered only if no information is found for a given
7368 device. This means that only first time read triggers rescan.
7370 The patch drops premature return. This way data->devices_attached[] is
7371 filled even when a given device is missing.
7373 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7375 2018-10-31 Goffredo Baroncelli <kreijack@inwind.it>
7377 btrfs: Move the error logging from find_device() to its caller
7378 The caller knows better if this error is fatal or not, i.e. another disk is
7381 This is a preparatory patch.
7383 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7385 2018-10-31 Goffredo Baroncelli <kreijack@inwind.it>
7387 btrfs: Add helper to check the btrfs header
7388 This helper is used in a few places to help the debugging. As
7389 conservative approach the error is only logged.
7390 This does not impact the error handling.
7392 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7394 2018-10-31 Goffredo Baroncelli <kreijack@inwind.it>
7396 btrfs: Add support for reading a filesystem with a RAID 5 or RAID 6 profile
7397 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7399 2018-09-27 Michael Chang <mchang@suse.com>
7401 msdos: Fix overflow in converting partition start and length into 512B blocks
7402 When booting from NVME SSD with 4k sector size, it fails with the message.
7404 error: attempt to read or write outside of partition.
7406 This patch fixes the problem by fixing overflow in converting partition start
7407 and length into 512B blocks.
7409 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7411 2018-09-27 Mihai Moldovan <ionic@ionic.de>
7413 osdep/linux: Convert partition start to disk sector length
7414 When reading data off a disk, sector values are based on the disk sector
7417 Within grub_util_fd_open_device(), the start of the partition was taken
7418 directly from grub's partition information structure, which uses the
7419 internal sector length (currently 512b), but never transformed to the
7420 disk's sector length.
7422 Subsequent calculations were all wrong for devices that have a diverging
7423 sector length and the functions eventually skipped to the wrong stream
7424 location, reading invalid data.
7426 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7428 2018-09-27 Adam Williamson <awilliam@redhat.com>
7430 python: Use AM_PATH_PYTHON to determine interpreter for gentpl.py
7431 gentpl.py is python2/3-agnostic, but there's no way to cause it
7432 to be run with any interpreter other than 'python', it's just
7433 hard-coded into Makefile.common that way. Adjust that to use
7434 AM_PATH_PYTHON (provided by automake) to find an interpreter
7435 and run gentpl.py with that instead. This makes grub buildable
7436 when `python` does not exist (but rather `python3` or `python2`
7437 or `python2.7`, etc.) Minimum version is set to 2.6 as this is
7438 the first version with `__future__.print_function` available.
7440 Note, AM_PATH_PYTHON respects the PYTHON environment variable
7441 and will treat its value as the *only* candidate for a valid
7442 interpreter if it is set - when PYTHON is set, AM_PATH_PYTHON
7443 will not try to find any alternative interpreter, it will only
7444 check whether the interpreter set as the value of PYTHON meets
7445 the requirements and use it if so or fail if not. This means
7446 that when using grub's `autogen.sh`, as it too uses the value
7447 of the PYTHON environment variable (and if it is not set, just
7448 sets it to 'python') you cannot rely on AM_PATH_PYTHON
7449 interpreter discovery. If your desired Python interpreter is
7450 not just 'python', you must set the PYTHON environment variable,
7451 e.g. 'PYTHON=/usr/local/bin/python3 ./autogen.sh'. The specified
7452 interpreter will then be used both by autogen.sh itself and by
7453 the autotools-driven build scripts.
7455 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7457 2018-09-27 Colin Watson <cjwatson@ubuntu.com>
7459 build: Use pkg-config to find FreeType
7460 pkg-config is apparently preferred over freetype-config these days (see
7461 the BUGS section of freetype-config(1)). pkg-config support was added
7462 to FreeType in version 2.1.5, which was released in 2003, so it should
7463 comfortably be available everywhere by now.
7465 We no longer need to explicitly substitute FREETYPE_CFLAGS and
7466 FREETYPE_LIBS, since PKG_CHECK_MODULES does that automatically.
7468 Fixes Debian bug #887721.
7470 Reported-by: Hugh McMaster <hugh.mcmaster@outlook.com>
7471 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7473 2018-09-27 Colin Watson <cjwatson@ubuntu.com>
7475 build: Capitalise *freetype_* variables
7476 Using FREETYPE_CFLAGS and FREETYPE_LIBS is more in line with the naming
7477 scheme used by pkg-config macros.
7479 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7481 2018-09-13 Julian Andres Klode <julian.klode@canonical.com>
7483 ofnet: Initialize structs in bootpath parser
7484 Code later on checks if variables inside the struct are
7485 0 to see if they have been set, like if there were addresses
7488 The variables were not initialized however, so the check
7489 might succeed with uninitialized data, and a new interface
7490 with random addresses and the same name is added. This causes
7491 $net_default_mac to point to the random one, so, for example,
7492 using that variable to load per-mac config files fails.
7494 Bug-Ubuntu: https://bugs.launchpad.net/bugs/1785859
7496 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7498 2018-09-13 dann frazier <dann.frazier@canonical.com>
7500 grub-reboot: Warn when "for the next boot only" promise cannot be kept
7501 The "for the next boot only" property of grub-reboot is dependent upon
7502 GRUB being able to clear the next_entry variable in the environment
7503 block. However, GRUB cannot write to devices using the diskfilter
7504 and lvm abstractions.
7506 Ref: https://lists.gnu.org/archive/html/grub-devel/2009-12/msg00276.html
7507 Ref: https://bugs.launchpad.net/bugs/788298
7509 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7511 2018-09-13 Cao jin <caoj.fnst@cn.fujitsu.com>
7513 relocator16: Comments update
7514 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7516 2018-09-13 Paul Menzel <pmenzel@molgen.mpg.de>
7518 ahci: Increase time-out from 10 s to 32 s
7519 This is a cryptographically signed message in MIME format.
7521 Date: Thu, 9 Aug 2018 07:27:35 +0200
7523 Currently, the GRUB payload for coreboot does not detect the Western
7524 Digital hard disk WDC WD20EARS-60M AB51 connected to the ASRock E350M1,
7525 as that takes over ten seconds to spin up.
7528 disk/ahci.c:533: port 0, err: 0
7529 disk/ahci.c:539: port 0, err: 0
7530 disk/ahci.c:543: port 0, err: 0
7531 disk/ahci.c:549: port 0, offset: 120, tfd:80, CMD: 6016
7532 disk/ahci.c:552: port 0, err: 0
7533 disk/ahci.c:563: port 0, offset: 120, tfd:80, CMD: 6016
7534 disk/ahci.c:566: port: 0, err: 0
7535 disk/ahci.c:593: port 0 is busy
7536 disk/ahci.c:621: cleaning up failed devs
7539 GRUB detects the drive, when either unloading the module *ahci*, and
7540 then loading it again, or when doing a warm reset.
7542 As the ten second time-out is too short, increase it to 32 seconds,
7543 used by SeaBIOS. which detects the drive successfully.
7545 The AHCI driver in libpayload uses 30 seconds, and that time-out was
7546 added in commit 354066e1 (libpayload: ahci: Increase timeout for
7547 signature reading) with the description below.
7549 > We can't read the drives signature before it's ready, i.e. spun up.
7550 > So set the timeout to the standard 30s. Also put a notice on the
7551 > console, so the user knows why the signature reading failed.
7553 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7555 2018-09-13 Cao jin <caoj.fnst@cn.fujitsu.com>
7557 linux16: Code cleanup
7558 1. move relocator related code more close to each other
7559 2. use variable "len" since it has correct assignment, and keep coding
7560 style with upper code
7562 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7564 2018-09-13 Colin Watson <cjwatson@ubuntu.com>
7566 tests: Fix qemu options for UHCI test
7567 qemu 2.12 removed the -usbdevice option. Use a more modern spelling
7568 instead, in line with other USB-related tests.
7570 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7572 2018-09-13 Colin Watson <cjwatson@ubuntu.com>
7574 tests: Disable sercon in SeaBIOS
7575 SeaBIOS 1.11.0 added support for VGA emulation over a serial port, which
7576 interferes with grub-shell. Turn it off.
7578 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7580 2018-09-12 Peter Jones <pjones@redhat.com>
7582 grub-module-verifier: Report the filename or modname in errors
7583 Make it so that when grub-module-verifier complains of an issue, it tells you
7584 which module the issue was with.
7586 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7588 2018-09-12 Peter Jones <pjones@redhat.com>
7590 configure: Fix an 8 year old typo
7591 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7593 2018-09-12 Leif Lindholm <leif.lindholm@linaro.org>
7595 loader/multiboot_mbi2: Use central copy of grub_efi_find_mmap_size()
7596 Delete local copy of function to determine required buffer size for the
7597 UEFI memory map, use helper in kern/efi/mm.c.
7599 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7601 2018-09-12 Leif Lindholm <leif.lindholm@linaro.org>
7603 loader/ia64/linux: Use central copy of grub_efi_find_mmap_size()
7604 Delete local copy of function to determine required buffer size for the
7605 UEFI memory map, use helper in kern/efi/mm.c.
7607 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7609 2018-09-12 Leif Lindholm <leif.lindholm@linaro.org>
7611 loader/i386/linux: Use central copy of grub_efi_find_mmap_size()
7612 Delete local copy of function to determine required buffer size for the
7613 UEFI memory map, use helper in kern/efi/mm.c.
7615 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7617 2018-07-25 Leif Lindholm <leif.lindholm@linaro.org>
7619 i386: Don't include lib/i386/reset.c in EFI builds
7620 Commit 0ba90a7f0178 ("efi: Move grub_reboot() into kernel") broke
7621 the build on i386-efi - genmoddep.awk bails out with message
7622 grub_reboot in reboot is duplicated in kernel
7623 This is because both lib/i386/reset.c and kern/efi/efi.c now provide
7626 Rather than explicitly list each i386 platform variant in
7627 Makefile.core.def, include the contents of lib/i386/reset.c only when
7628 GRUB_MACHINE_EFI is not set.
7630 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7632 2018-07-25 Leif Lindholm <leif.lindholm@linaro.org>
7634 efi: Restrict arm/arm64 linux loader initrd placement
7635 The 32-bit arm Linux kernel is built as a zImage, which self-decompresses
7636 down to near start of RAM. In order for an initrd/initramfs to be
7637 accessible, it needs to be placed within the first ~768MB of RAM.
7638 The initrd loader built into the kernel EFI stub restricts this down to
7639 512MB for simplicity - so enable the same restriction in grub.
7641 For arm64, the requirement is within a 1GB aligned 32GB window also
7642 covering the (runtime) kernel image. Since the EFI stub loader itself
7643 will attempt to relocate to near start of RAM, force initrd to be loaded
7644 completely within the first 32GB of RAM.
7646 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7648 2018-07-25 Leif Lindholm <leif.lindholm@linaro.org>
7650 arm: Delete unused efi support from loader/arm
7651 The 32-bit arm efi port now shares the 64-bit linux loader, so delete
7652 the now unused bits from the 32-bit linux loader.
7654 This in turn leaves the grub-core/kern/arm/efi/misc.c unused, so
7657 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7659 2018-07-25 Leif Lindholm <leif.lindholm@linaro.org>
7661 arm/efi: Switch to arm64 linux loader
7662 The arm64 and arm linux kernel EFI-stub support presents pretty much
7663 identical interfaces, so the same linux loader source can be used for
7666 Switch 32-bit ARM UEFI platforms over to the existing EFI-stub aware
7667 loader initially developed for arm64.
7669 This *WILL* stop non-efistub Linux kernels from booting on arm-efi.
7671 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7673 2018-07-25 Leif Lindholm <leif.lindholm@linaro.org>
7675 arm64/linux/loader: Rename functions and macros and move to common headers
7676 In preparation for using the linux loader for 32-bit and 64-bit platforms,
7677 rename grub_arm64*/GRUB_ARM64* to grub_armxx*/GRUB_ARMXX*.
7679 Move prototypes for now-common functions to efi/efi.h.
7681 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7683 2018-07-25 Leif Lindholm <leif.lindholm@linaro.org>
7685 efi: Add grub_efi_get_ram_base() function for arm64
7686 Since ARM platforms do not have a common memory map, add a helper
7687 function that finds the lowest address region with the EFI_MEMORY_WB
7688 attribute set in the UEFI memory map.
7690 Required for the arm64 efi linux loader to restrict the initrd
7691 location to where it will be accessible by the kernel at runtime.
7693 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7695 2018-07-25 Leif Lindholm <leif.lindholm@linaro.org>
7697 efi: Add central copy of grub_efi_find_mmap_size
7698 There are several implementations of this function in the tree.
7699 Add a central version in grub-core/efi/mm.c.
7701 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7703 2018-07-25 Arindam Nath <arindam.nath@amd.com>
7705 i386/linux: Add support for ext_lfb_base
7706 The EFI Graphics Output Protocol can return a 64-bit
7707 linear frame buffer address in some firmware/BIOS
7708 implementations. We currently only store the lower
7709 32-bits in the lfb_base. This will eventually be
7710 passed to Linux kernel and the efifb driver will
7711 incorrectly interpret the framebuffer address as
7714 The Linux kernel has already added support to handle
7715 64-bit linear framebuffer address in the efifb driver
7716 since quite some time now.
7718 This patch adds the support for 64-bit linear frame
7719 buffer address in GRUB to address the above mentioned
7722 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7724 2018-07-11 Leif Lindholm <leif.lindholm@linaro.org>
7726 commands/file: Use definitions from arm64/linux.h
7727 Clean up code for matching IS_ARM64 slightly by making use of struct
7728 linux_arm64_kernel_header and GRUB_LINUX_ARM64_MAGIC_SIGNATURE.
7730 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7732 2018-07-11 Leif Lindholm <leif.lindholm@linaro.org>
7734 commands/file: Use definitions from arm/linux.h
7735 Clean up code for matching IS_ARM slightly by making use of struct
7736 linux_arm_kernel_header and GRUB_LINUX_ARM_MAGIC_SIGNATURE.
7738 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7740 2018-07-11 Hans de Goede <hdegoede@redhat.com>
7742 efi/console: Fix the "enter" key not working on x86 tablets
7743 Most 8" or 7" x86 Windows 10 tablets come with volume up/down buttons and
7744 a power-button. In their UEFI these are almost always mapped to arrow
7747 Pressing the volume buttons (sometimes by accident) will stop the
7748 menu countdown, but the power-button / "enter" key was not being recognized
7749 as enter, so the user would be stuck at the grub menu.
7751 The problem is that these tablets send scan_code 13 or 0x0d for the
7752 power-button, which officialy maps to the F3 key. They also set
7753 unicode_char to 0x0d.
7755 This commit recognizes the special case of both scan_code and unicode_char
7756 being set to 0x0d and treats this as an enter key press.
7758 This fixes things getting stuck at the grub-menu and allows the user
7759 to choice a grub-menu entry using the buttons on the tablet.
7761 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7763 2018-07-11 Cao jin <caoj.fnst@cn.fujitsu.com>
7765 grub-setup: Debug message cleanup
7766 Variable "root" is initialized after root device probing and is null in
7767 current place, so, drop it.
7769 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7771 2018-07-02 Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
7773 multiboot_elfxx.c: Fix compilation by fixing undeclared variable
7774 Without that fix we have:
7775 In file included from ../../include/grub/command.h:25:0,
7776 from ../../grub-core/loader/multiboot.c:30:
7777 ../../grub-core/loader/multiboot_elfxx.c: In function 'grub_multiboot_load_elf64':
7778 ../../grub-core/loader/multiboot_elfxx.c:130:28: error: 'relocatable' undeclared (first use in this function)
7779 "load_base_addr=0x%x\n", relocatable,
7781 This happens due to mistake in the commit 14ec665
7782 (mbi: Use per segment a separate relocator chunk).
7786 2018-06-23 Leif Lindholm <leif.lindholm@linaro.org>
7788 efi/fdt: Set address/size cells to 2 for empty tree
7789 When booting an arm* system on UEFI with an empty device tree (currently
7790 only when hardware description comes from ACPI), we don't currently set
7791 default to 1 cell (32 bits).
7793 Set both of these properties, to 2 cells (64 bits), to resolve issues
7794 with kexec on some platforms.
7796 This change corresponds with linux kernel commit ae8a442dfdc4
7797 ("efi/libstub/arm*: Set default address and size cells values for an empty dtb")
7798 and ensures booting through grub does not behave differently from booting
7799 the stub loader directly.
7801 See also https://patchwork.kernel.org/patch/9561201/
7803 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7805 2018-06-23 Leif Lindholm <leif.lindholm@linaro.org>
7807 fdt: Move prop_entry_size to fdt.h
7808 To be able to resuse the prop_entry_size macro, move it to
7809 <grub/fdt.h> and rename it grub_fdt_prop_entry_size.
7811 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7813 2018-06-23 Will Thompson <wjt@endlessm.com>
7815 grub-fs-tester: Fix losetup race
7816 If something else on the system is using loopback devices, then the
7817 device that's free at the call to `losetup -f` may not be free in the
7818 following call to try to use it. Instead, find and use the first free
7819 loopback device in a single call to losetup.
7821 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7823 2018-06-23 Alexander Boettcher <alexander.boettcher@genode-labs.com>
7825 mbi: Use per segment a separate relocator chunk
7826 Instead of setting up a all comprising relocator chunk for all segments,
7827 use per segment a separate relocator chunk.
7829 Currently, if the ELF is non-relocatable, a single relocator chunk will
7830 comprise memory (between the segments) which gets overridden by the relst()
7831 invocation of the movers code in grub_relocator16/32/64_boot().
7833 The overridden memory may contain reserved ranges like VGA memory or ACPI
7834 tables, which may lead to crashes or at least to strange boot behaviour.
7836 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7838 2018-06-05 Daniel Kiper <daniel.kiper@oracle.com>
7840 templates: Add missing "]"
7841 Commit 51be337 (templates: Update grub script template files)
7842 lacked one "]", so, add it.
7844 Reported-by: Philip <philm@manjaro.org>
7846 2018-05-29 Daniel Kiper <daniel.kiper@oracle.com>
7848 xfs: Accept filesystem with sparse inodes
7849 The sparse inode metadata format became a mkfs.xfs default in
7850 xfsprogs-4.16.0, and such filesystems are now rejected by grub as
7851 containing an incompatible feature.
7853 In essence, this feature allows xfs to allocate inodes into fragmented
7854 freespace. (Without this feature, if xfs could not allocate contiguous
7855 space for 64 new inodes, inode creation would fail.)
7857 In practice, the disk format change is restricted to the inode btree,
7858 which as far as I can tell is not used by grub. If all you're doing
7859 today is parsing a directory, reading an inode number, and converting
7860 that inode number to a disk location, then ignoring this feature
7861 should be fine, so I've added it to XFS_SB_FEAT_INCOMPAT_SUPPORTED
7863 I did some brief testing of this patch by hacking up the regression
7864 tests to completely fragment freespace on the test xfs filesystem, and
7865 then write a large-ish number of inodes to consume any existing
7866 contiguous 64-inode chunk. This way any files the grub tests add and
7867 traverse would be in such a fragmented inode allocation. Tests passed,
7868 but I'm not sure how to cleanly integrate that into the test harness.
7870 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7871 Tested-by: Chris Murphy <lists@colorremedies.com>
7873 2018-05-29 Oleg Solovyov <mcpain@altlinux.org>
7875 grub-probe: Don't skip /dev/mapper/dm-* devices
7876 This patch ensures that grub-probe will find the root device placed in
7877 /dev/mapper/dm-[0-9]+-.* e.g. device named /dev/mapper/dm-0-luks will be
7878 found and grub.cfg will be updated properly, enabling the system to boot.
7880 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7882 2018-05-08 Michael Chang <mchang@suse.com>
7884 bufio: Round up block size to power of 2
7885 Rounding up the bufio->block_size to meet power of 2 to facilitate next_buf
7886 calculation in grub_bufio_read().
7888 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7890 2018-04-23 Nicholas Vinson <nvinson234@gmail.com>
7892 templates: Update grub script template files
7893 Update grub-mkconfig.in and 10_linux.in to support grub-probe's new
7894 partuuid target. Update grub.texi documentation. The following table
7895 shows how GRUB_DISABLE_LINUX_UUID, GRUB_DISABLE_LINUX_PARTUUID, and
7896 initramfs detection interact:
7898 Initramfs GRUB_DISABLE_LINUX_PARTUUID GRUB_DISABLE_LINUX_UUID Linux Root
7899 detected Set Set ID Method
7901 false false false part UUID
7902 false false true part UUID
7903 false true false dev name
7904 false true true dev name
7905 true false false fs UUID
7906 true false true part UUID
7907 true true false fs UUID
7908 true true true dev name
7910 Note: GRUB_DISABLE_LINUX_PARTUUID and GRUB_DISABLE_LINUX_UUID equate to
7911 'false' when unset or set to any value other than 'true'.
7912 GRUB_DISABLE_LINUX_PARTUUID defaults to 'true'.
7914 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7916 2018-04-23 Nicholas Vinson <nvinson234@gmail.com>
7918 grub-probe: Add PARTUUID detection support
7919 Add PARTUUID detection support grub-probe for MBR and GPT partition schemes.
7921 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7923 2018-04-23 Nicholas Vinson <nvinson234@gmail.com>
7925 disk: Update grub_gpt_partentry
7926 Rename grub_gpt_part_type to grub_gpt_part_guid and update grub_gpt_partentry
7927 to use this type for both the partition type GUID string and the partition GUID
7928 string entries. This change ensures that the two GUID fields are handled more
7929 consistently and helps to simplify the changes needed to add Linux partition
7932 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7934 2018-04-23 Nicholas Vinson <nvinson234@gmail.com>
7936 grub-probe: Centralize GUID prints
7937 Define print_gpt_guid(), so there is a central function for printing
7938 GUID strings. This change is a precursor for later patches which rely
7941 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7943 2018-04-23 Olaf Hering <olaf@aepfle.de>
7945 grub-install: Locale depends on nls
7946 With --disable-nls no locales exist.
7948 Avoid runtime error by moving code that copies locales into its own
7949 function. Return early in case nls was disabled. That way the compiler
7950 will throw away unreachable code, no need to put preprocessor
7951 conditionals everywhere to avoid warnings about unused code.
7953 Fix memleak by freeing srcf and dstf.
7954 Convert tabs to spaces in moved code.
7956 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7958 2018-04-23 Cao jin <caoj.fnst@cn.fujitsu.com>
7960 diskboot: Trivial correction on stale comments
7961 diskboot.img now is loaded at 0x8000 and is jumped to with 0:0x8000.
7963 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7965 2018-04-10 Jaegeuk Kim <jaegeuk@kernel.org>
7967 fs: Add F2FS support
7968 "F2FS (Flash-Friendly File System) is flash-friendly file system which was merged
7969 into Linux kernel v3.8 in 2013.
7971 The motive for F2FS was to build a file system that from the start, takes into
7972 account the characteristics of NAND flash memory-based storage devices (such as
7973 solid-state disks, eMMC, and SD cards).
7975 F2FS was designed on a basis of a log-structured file system approach, which
7976 remedies some known issues of the older log structured file systems, such as
7977 the snowball effect of wandering trees and high cleaning overhead. In addition,
7978 since a NAND-based storage device shows different characteristics according to
7979 its internal geometry or flash memory management scheme (such as the Flash
7980 Translation Layer or FTL), it supports various parameters not only for
7981 configuring on-disk layout, but also for selecting allocation and cleaning
7982 algorithm.", quote by https://en.wikipedia.org/wiki/F2FS.
7984 The source codes for F2FS are available from:
7986 http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs.git
7987 http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs-tools.git
7989 This patch has been integrated in OpenMandriva Lx 3.
7990 https://www.openmandriva.org/
7992 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7994 2018-04-04 Michael Chang <mchang@suse.com>
7996 Fix packed-not-aligned error on GCC 8
7997 When building with GCC 8, there are several errors regarding packed-not-aligned.
7999 ./include/grub/gpt_partition.h:79:1: error: alignment 1 of ‘struct grub_gpt_partentry’ is less than 8 [-Werror=packed-not-aligned]
8001 This patch fixes the build error by cleaning up the ambiguity of placing
8002 aligned structure in a packed one. In "struct grub_btrfs_time" and "struct
8003 grub_gpt_part_type", the aligned attribute seems to be superfluous, and also
8004 has to be packed, to ensure the structure is bit-to-bit mapped to the format
8005 laid on disk. I think we could blame to copy and paste error here for the
8006 mistake. In "struct efi_variable", we have to use grub_efi_packed_guid_t, as
8007 the name suggests. :)
8009 Tested-by: Michael Chang <mchang@suse.com>
8010 Tested-by: Paul Menzel <paulepanter@users.sourceforge.net>
8011 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8013 2018-04-04 mike.travis@hpe.com <mike.travis@hpe.com>
8015 efi/uga: Fix PCIe LER when GRUB2 accesses non-enabled MMIO data from VGA
8016 A GPU inserted into a PCIe I/O slot disappears during system startup.
8017 The problem centers around GRUB and a specific VGA init function in
8018 efi_uga.c. This causes an LER (Link Error Recorvery) because the MMIO
8019 memory has not been enabled before attempting access.
8021 The fix is to add the same coding used in other VGA drivers, specifically
8022 to add a check to insure that it is indeed a VGA controller. And then
8023 enable the MMIO address space with the specific bits.
8025 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8027 2018-03-26 Eric Snowberg <eric.snowberg@oracle.com>
8029 ieee1275: NULL pointer dereference in grub_machine_get_bootlocation()
8030 Read from NULL pointer canon in function grub_machine_get_bootlocation().
8031 Function grub_ieee1275_canonicalise_devname() may return NULL.
8033 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8035 2018-03-14 Eric Snowberg <eric.snowberg@oracle.com>
8037 ieee1275: split up grub_machine_get_bootlocation
8038 Split up some of the functionality in grub_machine_get_bootlocation into
8039 grub_ieee1275_get_boot_dev. This will allow for code reuse in a follow on
8042 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8044 2018-03-14 C. Masloch <pushbx@38.de>
8046 chainloader: patch in BPB's sectors_per_track and num_heads
8047 These fields must reflect the ROM-BIOS's geometry for CHS-based
8048 loaders to correctly load their next stage. Most loaders do not
8049 query the ROM-BIOS (Int13.08), relying on the BPB fields to hold
8050 the correct values already.
8052 Tested with lDebug booted in qemu via grub2's
8053 FreeDOS direct loading support, refer to
8054 https://bitbucket.org/ecm/ldosboot + https://bitbucket.org/ecm/ldebug
8055 (For this test, lDebug's iniload.asm must be assembled with
8056 -D_QUERY_GEOMETRY=0 to leave the BPB values provided by grub.)
8058 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8060 2018-03-14 Matthew S. Turnbull <sparky@bluefang-logic.com>
8062 grub-mkconfig/10_linux: Support multiple early initrd images
8063 Add support for multiple, shared, early initrd images. These early
8064 images will be loaded in the order declared, and all will be loaded
8065 before the initrd image.
8067 While many classes of data can be provided by early images, the
8068 immediate use case would be for distributions to provide CPU
8069 microcode to mitigate the Meltdown and Spectre vulnerabilities.
8071 There are two environment variables provided for declaring the early
8074 * GRUB_EARLY_INITRD_LINUX_STOCK is for the distribution declare
8075 images that are provided by the distribution or installed packages.
8076 If undeclared, this will default to a set of common microcode image
8079 * GRUB_EARLY_INITRD_LINUX_CUSTOM is for user created images. User
8080 images will be loaded after the stock images.
8082 These separate configurations allow the distribution and user to
8083 declare different image sets without clobbering each other.
8085 This also makes a minor update to ensure that UUID partition labels
8086 stay disabled when no initrd image is found, even if early images are
8089 This is a continuation of a previous patch published by Christian
8091 http://lists.gnu.org/archive/html/grub-devel/2016-02/msg00025.html
8093 Down stream Gentoo bug:
8094 https://bugs.gentoo.org/645088
8096 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8098 2018-03-07 Eric Snowberg <eric.snowberg@oracle.com>
8100 mkimage: fix build regression in grub_mkimage_load_image
8101 The grub_mkimage_load_image function (commit 7542af6, mkimage: refactor a bunch
8102 of section data into a struct.) introduces a build regression on SPARC:
8104 cc1: warnings being treated as errors
8105 In file included from util/grub-mkimage32.c:23:
8106 util/grub-mkimagexx.c: In function 'grub_mkimage_load_image32':
8107 util/grub-mkimagexx.c:1968: error: missing initializer
8108 util/grub-mkimagexx.c:1968: error: (near initialization for 'smd.sections')
8109 make[2]: *** [util/grub_mkimage-grub-mkimage32.o] Error 1
8111 Initialize the entire section_metadata structure.
8113 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8115 2018-03-05 dann frazier <dann.frazier@canonical.com>
8117 Revert "Keep the native terminal active when enabling gfxterm"
8118 This can cause an issue where GRUB is trying to display both a text and
8119 graphical menu on the display at the same time, resulting in a flickering
8120 effect when e.g. scrolling quickly through a menu (LP: #1752767).
8122 Revert for now while we look for a better solution for the original issue.
8124 This reverts commit 52ef7b23f528ce844716661d586497a177e80d5b.
8126 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8128 2018-03-05 Eric Snowberg <eric.snowberg@oracle.com>
8130 sparc64: #blocks64 disk node method
8131 Return the 64bit number of blocks of storage associated with the device or
8132 instance. Where a "block" is a unit of storage consisting of the number of
8133 bytes returned by the package's "block-size" method. If the size cannot be
8134 determined, or if the number of blocks exceeds the range return -1.
8136 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8138 2018-03-05 Eric Snowberg <eric.snowberg@oracle.com>
8140 sparc64: #blocks disk node method
8141 Return the number of blocks of storage associated with the device or
8142 instance. Where a "block" is a unit of storage consisting of the number
8143 of bytes returned by the package's "block-size" method. If the size cannot
8144 be determined, the #blocks method returns the maximum unsigned integer
8145 (which, because of Open Firmware's assumption of two's complement arithmetic,
8146 is equivalent to the signed number -1). If the number of blocks exceeds
8147 the range of an unsigned number, return 0 to alert the caller to try
8148 the #blocks64 command.
8150 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8152 2018-03-05 Eric Snowberg <eric.snowberg@oracle.com>
8154 ieee1275: block-size deblocker support method
8155 IEEE Std 1275-1994 Standard for Boot (Initialization Configuration)
8156 Firmware: Core Requirements and Practices
8158 3.8.3 deblocker support package
8160 Any package that uses the "deblocker" support package must define
8161 the following method, which the deblocker uses as a low-level
8162 interface to the device
8164 block-size ( -- block-len ) Return "granularity" for accesses to this
8167 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8169 2018-03-05 Daniel Kiper <daniel.kiper@oracle.com>
8171 ieee1275: no-data-command bus specific method
8172 IEEE 1275-1994 Standard for Boot (Initialization Configuration)
8173 Firmware: Core Requirements and Practices
8175 E.3.2.2 Bus-specific methods for bus nodes
8177 A package implementing the scsi-2 device type shall implement the
8178 following bus-specific method:
8180 no-data-command ( cmd-addr -- error? )
8181 Executes a simple SCSI command, automatically retrying under
8182 certain conditions. cmd-addr is the address of a 6-byte command buffer
8183 containing an SCSI command that does not have a data transfer phase.
8184 Executes the command, retrying indefinitely with the same retry criteria
8187 error? is nonzero if an error occurred, zero otherwise.
8188 NOTE no-data-command is a convenience function. It provides
8189 no capabilities that are not present in retry-command, but for
8190 those commands that meet its restrictions, it is easier to use.
8192 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8194 2018-03-05 Eric Snowberg <eric.snowberg@oracle.com>
8196 ieee1275: set-address bus specific method
8197 IEEE 1275-1994 Standard for Boot (Initialization Configuration)
8198 Firmware: Core Requirements and Practices
8199 E.3.2.2 Bus-specific methods for bus nodes
8201 A package implementing the scsi-2 device type shall implement the
8202 following bus-specific method:
8204 set-address ( unit# target# -- )
8205 Sets the SCSI target number (0x0..0xf) and unit number (0..7) to which
8206 subsequent commands apply.
8208 This function is for devices with #address-cells == 2
8210 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8212 2018-03-05 Eric Snowberg <eric.snowberg@oracle.com>
8214 ieee1275: encode-unit command for 4 addr cell devs
8215 Convert physical address to text unit-string.
8217 Convert phys.lo ... phys-high, the numerical representation, to unit-string,
8218 the text string representation of a physical address within the address
8219 space defined by this device node. The number of cells in the list
8220 phys.lo ... phys.hi is determined by the value of the #address-cells property
8223 This function is for devices with #address-cells == 4
8225 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8227 2018-03-05 Eric Snowberg <eric.snowberg@oracle.com>
8229 ieee1275: decode-unit command for 4 addr cell devs
8230 decode-unit ( addr len -- phys.lo ... phys.hi )
8232 Convert text unit-string to physical address.
8234 Convert unit-string, the text string representation, to phys.lo ... phys.hi,
8235 the numerical representation of a physical address within the address space
8236 defined by this device node. The number of cells in the list
8237 phys.lo ... phys.hi is determined by the value of the #address-cells
8238 property of this node.
8240 This function is for devices with #address-cells == 4
8242 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8244 2018-03-05 Eric Snowberg <eric.snowberg@oracle.com>
8246 sparc64: Limit nvme of_path_of_nvme to just SPARC
8247 Limit NVMe of_path_of_nvme to just SPARC hardware for now. It has been
8248 found that non-Open Firmware hardware platforms can some how access
8251 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8253 2018-03-05 John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
8255 ieee1275: Fix crash in of_path_of_nvme when of_path is empty
8256 The of_path_of_nvme function (commit 2391d57, ieee1275: add nvme
8257 support within ofpath) introduced a functional regression:
8259 On systems which are not based on Open Firmware but have at
8260 least one NVME device, find_obppath will return NULL and thus
8261 trying to append the disk name to of_path will result in a
8264 The proper behavior of of_path_of_nvme is, however, to just
8265 return NULL in such cases, like other users of find_obppath,
8266 such as of_path_of_scsi.
8268 Reviewed-by: Eric Snowberg <eric.snowberg@oracle.com>
8269 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8271 2018-03-05 Peter Jones <pjones@redhat.com>
8273 .mod files: Strip annobin annotations and .eh_frame, and their relocations
8274 This way debuginfo built from the .module will still include this
8275 information, but the final result won't have the data we don't actually
8276 need in the modules, either on-disk, loaded at runtime, or in prebuilt
8279 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8281 2018-03-05 Peter Jones <pjones@redhat.com>
8283 mkimage: avoid copying relocations for sections that won't be copied.
8284 Some versions of gcc include a plugin called "annobin", and in some
8285 build systems this is enabled by default. This plugin creates special
8286 ELF note sections to track which ABI-breaking features are used by a
8287 binary, as well as a series of relocations to annotate where.
8289 If grub is compiled with this feature, then when grub-mkimage translates
8290 the binary to another file format which does not strongly associate
8291 relocation data with sections (i.e. when platform is *-efi), these
8292 relocations appear to be against the .text section rather than the
8293 original note section. When the binary is loaded by the PE runtime
8294 loader, hilarity ensues.
8296 This issue is not necessarily limited to the annobin, but could arise
8297 any time there are relocations in sections that are not represented in
8298 grub-mkimage's output.
8300 This patch seeks to avoid this issue by only including relocations that
8301 refer to sections which will be included in the final binary.
8303 As an aside, this should also obviate the need to avoid -funwind-tables,
8304 -fasynchronous-unwind-tables, and any sections similar to .eh_frame in
8305 the future. I've tested it on x86-64-efi with the following gcc command
8306 line options (as recorded by -grecord-gcc-flags), but I still need to
8307 test the result on some other platforms that have been problematic in
8308 the past (especially ARM Aarch64) before I feel comfortable making
8309 changes to the configure.ac bits:
8311 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
8313 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8315 2018-03-05 Peter Jones <pjones@redhat.com>
8317 mkimage: refactor a bunch of section data into a struct.
8318 This basically moves a bunch of the section information we pass around a
8319 lot into a struct, and passes a pointer to a single one of those
8322 This shouldn't change the binary file output or the "grub-mkimage -v"
8325 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8327 2018-03-05 Peter Jones <pjones@redhat.com>
8329 mkimage: make locate_sections() set up vaddresses as well.
8330 This puts both kinds of address initialization at the same place, and also lets
8331 us iterate through the section list one time fewer.
8333 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8335 2018-03-05 Peter Jones <pjones@redhat.com>
8337 mkimage: rename a couple of things to be less confusing later.
8338 This renames some things:
8340 - the "strtab" and "strtab_section" in relocate_symbols are changed to "symtab"
8341 instead, so as to be less confusing when "strtab" is moved to a struct in a
8344 - The places where we pass section_vaddresses to functions are changed to also
8345 be called section_vaddresses"inside those functions, so I get less confused
8346 when I put addresses and vaddresses in a struct in a later patch.
8348 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8350 2018-03-05 Peter Jones <pjones@redhat.com>
8352 mkimage: make it easier to run syntax checkers on grub-mkimagexx.c
8353 This makes it so you can treat grub-mkimagexx.c as a file you can build
8354 directly, so syntax checkers like vim's "syntastic" plugin, which uses
8355 "gcc -x c -fsyntax-only" to build it, will work.
8357 One still has to do whatever setup is required to make it pick the right
8358 include dirs, which -W options we use, etc., but this makes it so you
8359 can do the checking on the file you're editing, rather than on a
8362 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8364 2018-03-05 Peter Jones <pjones@redhat.com>
8366 aout.h: Fix missing include.
8367 grub_aout_load() has a grub_file_t parameter, and depending on what order
8368 includes land in, it's sometimes not defined. This patch explicitly adds
8369 file.h to aout.h so that it will always be defined.
8371 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8373 2018-02-26 Joakim Bech <joakim.bech@linaro.org>
8375 ieee1275: fix build regression in of_path_of_nvme
8376 The of_path_of_nvme function (commit 2391d57, ieee1275: add nvme
8377 support within ofpath) introduced a build regression:
8378 grub-core/osdep/linux/ofpath.c:365:21: error: comparison between pointer
8379 and zero character constant [-Werror=pointer-compare]
8380 if ((digit_string != '\0') && (*part_end == 'p'))
8382 Update digit_string to compare against the char instead of the pointer.
8384 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8386 2018-02-23 Leif Lindholm <leif.lindholm@linaro.org>
8388 arm: make linux.h safe to include for non-native builds
8389 <grub/machine/loader.h> (for machine arm/efi) and
8390 <grub/machine/kernel.h> (for machine arm/coreboot) will not always
8391 resolve (and will likely not be valid to) if pulled in when building
8392 non-native commands, such as host tools or the "file" command.
8393 So explicitly include them with their expanded pathnames.
8395 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8397 2018-02-23 Leif Lindholm <leif.lindholm@linaro.org>
8399 arm: switch linux loader to linux_arm_kernel_header struct
8400 Use kernel header struct and magic definition to align (and coexist) with
8403 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8405 2018-02-23 Leif Lindholm <leif.lindholm@linaro.org>
8407 arm64: align linux kernel magic macro naming with i386
8408 Change GRUB_ARM64_LINUX_MAGIC to GRUB_LINUX_ARM64_MAGIC_SIGNATURE.
8410 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8412 2018-02-23 Leif Lindholm <leif.lindholm@linaro.org>
8414 arm64: align linux kernel header struct naming with i386
8415 Rename struct grub_arm64_linux_kernel_header -> linux_arm64_kernel_header.
8417 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8419 2018-02-23 Leif Lindholm <leif.lindholm@linaro.org>
8421 i386: make struct linux_kernel_header architecture specific
8422 struct linux_kernel_header -> struct linux_i386_kernel_header
8424 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8426 2018-02-23 Leif Lindholm <leif.lindholm@linaro.org>
8428 make GRUB_LINUX_MAGIC_SIGNATURE architecture-specific
8429 Rename GRUB_LINUX_MAGIC_SIGNATURE GRUB_LINUX_I386_MAGIC_SIGNATURE,
8430 to be usable in code that supports more than one image type.
8432 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8434 2018-02-23 Leif Lindholm <leif.lindholm@linaro.org>
8436 Make arch-specific linux.h include guards architecture unique
8437 Replace uses of GRUB_LINUX_MACHINE_HEADER and GRUB_LINUX_CPU_HEADER
8438 with GRUB_<arch>_LINUX_HEADER include guards to prevent issues when
8439 including more than one of them.
8441 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8443 2018-02-23 Leif Lindholm <leif.lindholm@linaro.org>
8445 arm64/efi: move EFI_PAGE definitions to efi/memory.h
8446 The EFI page definitions and macros are generic and should not be confined
8447 to arm64 headers - so move to efi/memory.h.
8448 Also add EFI_PAGE_SIZE macro.
8450 Update loader sources to reflect new header location.
8452 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8454 2018-02-23 Colin Watson <cjwatson@ubuntu.com>
8456 libgcrypt: Import replacement CRC operations
8457 The CRC implementation imported from libgcrypt 1.5.3 is arguably
8458 non-free, due to being encumbered by the restrictive Internet Society
8459 licence on RFCs (see e.g. https://wiki.debian.org/NonFreeIETFDocuments).
8460 Fortunately, libgcrypt has since replaced it with a version that is both
8461 reportedly better-optimised and doesn't suffer from this encumbrance.
8463 The ideal solution would be to update to a new version of libgcrypt, and
8464 I spent some time trying to do that. However, util/import_gcry.py
8465 requires complex modifications to cope with the new version, and I
8466 stalled part-way through; furthermore, GRUB's libgcrypt tree already
8467 contains some backports of upstream changes. Rather than allowing the
8468 perfect to be the enemy of the good, I think it's best to backport this
8469 single change to at least sort out the licensing situation. Doing so
8470 won't make things any harder for a future wholesale upgrade.
8472 This commit is mostly a straightforward backport of
8473 https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=commitdiff;h=06e122baa3321483a47bbf82fd2a4540becfa0c9,
8474 but I also imported bufhelp.h from libgcrypt 1.7.0 (newer versions
8475 required further changes elsewhere).
8477 I've tested that "hashsum -h crc32" still produces correct output for a
8478 variety of files on both i386-pc and x86_64-emu targets.
8480 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8482 2018-02-23 Eric Snowberg <eric.snowberg@oracle.com>
8484 ieee1275: add nvme support within ofpath
8485 Add NVMe support within ofpath.
8487 The Open Firmware text representation for a NVMe device contains the
8488 Namespace ID. An invalid namespace ID is one whose value is zero or whose
8489 value is greater than the value reported by the Number of Namespaces (NN)
8490 field in the Identify Controller data structure. At the moment only a
8491 single Namespace is supported, therefore the value is currently hard coded
8494 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8496 2018-02-23 Daniel Kiper <daniel.kiper@oracle.com>
8498 chainloader: Fix wrong break condition (must be AND not, OR)
8499 The definition of bpb's num_total_sectors_16 and num_total_sectors_32
8500 is that either the 16-bit field is non-zero and is used (in which case
8501 eg mkfs.fat sets the 32-bit field to zero), or it is zero and the
8502 32-bit field is used. Therefore, a BPB is invalid only if *both*
8503 fields are zero; having one field as zero and the other as non-zero is
8504 the case to be expected. (Indeed, according to Microsoft's specification
8505 one of the fields *must* be zero, and the other non-zero.)
8507 This affects all users of grub_chainloader_patch_bpb which are in
8508 chainloader.c, freedos.c, and ntldr.c
8510 Some descriptions of the semantics of these two fields:
8512 https://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html
8514 The old 2-byte fields "total number of sectors" and "number of
8515 sectors per FAT" are now zero; this information is now found in
8516 the new 4-byte fields.
8518 (Here given in the FAT32 EBPB section but the total sectors 16/32 bit
8519 fields semantic is true of FAT12 and FAT16 too.)
8521 https://wiki.osdev.org/FAT#BPB_.28BIOS_Parameter_Block.29
8523 19 | 2 | The total sectors in the logical volume. If this value is 0,
8524 it means there are more than 65535 sectors in the volume, and the actual
8525 count is stored in "Large Sectors (bytes 32-35).
8527 32 | 4 | Large amount of sector on media. This field is set if there
8528 are more than 65535 sectors in the volume.
8530 (Doesn't specify what the "large" field is set to when unused, but as
8531 mentioned mkfs.fat sets it to zero then.)
8533 https://technet.microsoft.com/en-us/library/cc976796.aspx
8535 0x13 | WORD | 0x0000 |
8536 Small Sectors . The number of sectors on the volume represented in 16
8537 bits (< 65,536). For volumes larger than 65,536 sectors, this field
8538 has a value of zero and the Large Sectors field is used instead.
8540 0x20 | DWORD | 0x01F03E00 |
8541 Large Sectors . If the value of the Small Sectors field is zero, this
8542 field contains the total number of sectors in the FAT16 volume. If the
8543 value of the Small Sectors field is not zero, the value of this field
8546 https://staff.washington.edu/dittrich/misc/fatgen103.pdf page 10
8548 BPB_TotSec16 | 19 | 2 |
8549 This field is the old 16-bit total count of sectors on the volume.
8550 This count includes the count of all sectors in all four regions of the
8551 volume. This field can be 0; if it is 0, then BPB_TotSec32 must be
8552 non-zero. For FAT32 volumes, this field must be 0. For FAT12 and
8553 FAT16 volumes, this field contains the sector count, and
8554 BPB_TotSec32 is 0 if the total sector count “fits” (is less than
8557 BPB_TotSec32 | 32 | 4 |
8558 This field is the new 32-bit total count of sectors on the volume.
8559 This count includes the count of all sectors in all four regions of the
8560 volume. This field can be 0; if it is 0, then BPB_TotSec16 must be
8561 non-zero. For FAT32 volumes, this field must be non-zero. For
8562 FAT12/FAT16 volumes, this field contains the sector count if
8563 BPB_TotSec16 is 0 (count is greater than or equal to 0x10000).
8565 (This specifies that an unused BPB_TotSec32 field is set to zero.)
8567 By the way fix offsets in include/grub/fat.h.
8569 Tested with lDebug booted in qemu via grub2's
8570 FreeDOS direct loading support, refer to
8571 https://bitbucket.org/ecm/ldosboot + https://bitbucket.org/ecm/ldebug
8573 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8575 2018-02-23 H.J. Lu <hjl.tools@gmail.com>
8577 x86-64: Treat R_X86_64_PLT32 as R_X86_64_PC32
8578 Starting from binutils commit bd7ab16b4537788ad53521c45469a1bdae84ad4a:
8580 https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=bd7ab16b4537788ad53521c45469a1bdae84ad4a
8582 x86-64 assembler generates R_X86_64_PLT32, instead of R_X86_64_PC32, for
8583 32-bit PC-relative branches. Grub2 should treat R_X86_64_PLT32 as
8586 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8588 2018-02-14 Steve McIntyre <steve@einval.com>
8590 Make grub-install check for errors from efibootmgr
8591 Code is currently ignoring errors from efibootmgr, giving users
8592 clearly bogus output like:
8594 Setting up grub-efi-amd64 (2.02~beta3-4) ...
8595 Installing for x86_64-efi platform.
8596 Could not delete variable: No space left on device
8597 Could not prepare Boot variable: No space left on device
8598 Installation finished. No error reported.
8600 and then potentially unbootable systems. If efibootmgr fails, grub-install
8601 should know that and report it!
8603 We've been using similar patch in Debian now for some time, with no ill effects.
8605 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8607 2018-02-14 Eric Snowberg <eric.snowberg@oracle.com>
8609 sparc64: fix OF path names for sun4v systems
8610 Fix the Open Firmware (OF) path property for sun4v SPARC systems.
8611 These platforms do not have a /sas/ within their path. Over time
8612 different OF addressing schemes have been supported. There
8613 is no generic addressing scheme that works across every HBA.
8615 It looks that this functionality will not work if you try to cross-install
8616 SPARC GRUB2 binary using e.g. x86 grub-install. By default it should work.
8617 However, we will also have other issues here, like lack of access to OF
8618 firmware/paths, which make such configs unusable anyway. So, let's leave
8619 this patch as is for time being. If somebody cares then he/she should fix
8620 the issue(s) at some point.
8622 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8624 2018-02-14 Eric Snowberg <eric.snowberg@oracle.com>
8626 sparc64: Add blocklist GPT support for SPARC
8627 Add block-list GPT support for SPARC. The OBP "load" and "boot" methods
8628 are partition aware and neither command can see the partition table. Also
8629 neither command can address the entire physical disk. When the install
8630 happens, grub generates the block-list entries based on the beginning of the
8631 physical disk, not the beginning of the partition. This patch fixes the
8632 block-list entries so they match what OBP expects during boot for a GPT disk.
8634 T5 and above now supports GPT as well as VTOC.
8636 This patch has been tested on T5-2 and newer SPARC systems.
8638 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8640 2018-01-29 Stefan Fritsch <fritsch@genua.de>
8642 ahci: Improve error handling
8643 Check the error bits in the interrupt status register. According to the
8644 AHCI 1.2 spec, "Interrupt sources that are disabled (‘0’) are still
8645 reflected in the status registers.", so this should work even though
8648 This fixes the following problem on a Fujitsu E744 laptop:
8650 Sometimes there is a very long delay (up to several minutes) when
8651 booting from hard disk. It seems accessing the DVD drive (which has no
8652 disk inserted) sometimes fails with some errors, which leads to each
8653 access being stalled until the 20s timeout triggers. This seems to
8654 happen when grub is trying to read filesystem/partition data.
8656 The problem is that the command_issue bit that is checked in the loop is
8657 only reset if the "HBA receives a FIS which clears the BSY, DRQ, and ERR
8658 bits for the command", but the ERR bit is never cleared. Therefore
8659 command_issue is never reset and grub waits for the timeout.
8661 The relevant bit in our case is the Task File Error Status (TFES), which
8662 is equivalent to the ERR bit 0 in tfd. But this patch also checks
8663 the other error bits except for the "Interface non-fatal error status"
8666 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8668 2018-01-29 dann frazier <dann.frazier@canonical.com>
8670 Keep the native terminal active when enabling gfxterm
8671 grub-mkconfig will set GRUB_TERMINAL_OUTPUT to "gfxterm" unless the user
8672 has overridden it. On EFI systems, this will stop output from going to the
8673 default "console" terminal. When the EFI fw console is configured to output to
8674 both serial and video, this will cause GRUB to only display on video - while
8675 continuing to accept input from both video and serial.
8677 Instead of switching from "console" to "gfxterm", let's output to both.
8679 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8681 2017-12-06 Julien Grall <julien.grall@linaro.org>
8683 arm64/xen: Add missing #address-cells and #size-cells properties
8684 The properties #address-cells and #size-cells are used to know the
8685 number of cells for ranges provided by "regs". If they don't exist, the
8686 value are resp. 2 and 1.
8688 Currently, when multiboot nodes are created it is assumed that #address-cells
8689 and #size-cells are exactly 2. However, they are never set by GRUB and
8690 will result to later failure when the device-tree is generated by GRUB
8691 or contain different values.
8693 To prevent this failure, create the both properties in the chosen nodes.
8695 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8697 2017-12-06 Jordan Glover <Golden_Miller83@protonmail.ch>
8699 grub-mkconfig: Fix detecting .sig files as system images
8700 grub-mkconfig detects detached RSA signatures for kernel images used for
8701 signature checking as valid images and adds them to grub.cfg as separate
8702 menu entries. This patch adds .sig extension to common blacklist.
8704 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8706 2017-12-06 Eric Snowberg <eric.snowberg@oracle.com>
8708 ieee1275: Fix segfault in grub-ofpathname
8709 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8711 2017-11-28 Eric Snowberg <eric.snowberg@oracle.com>
8713 grub-install: Fix memory leak
8714 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8716 2017-11-24 Eric Snowberg <eric.snowberg@oracle.com>
8718 ls: prevent double open
8719 Prevent a double open. This can cause problems with some ieee1275
8720 devices, causing the system to hang. The double open can occur
8723 grub_ls_list_files (char *dirname, int longlist, int all, int human)
8724 dev = grub_device_open (device_name);
8725 dev remains open while:
8726 grub_normal_print_device_info (device_name);
8727 dev = grub_device_open (name);
8729 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8731 2017-10-06 David E. Box <david.e.box@linux.intel.com>
8733 tsc: Change default tsc calibration method to pmtimer on EFI systems
8734 On efi systems, make pmtimer based tsc calibration the default over the
8735 pit. This prevents Grub from hanging on Intel SoC systems that power gate
8738 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8740 2017-09-07 Alexander Graf <agraf@suse.de>
8742 efi: Free malloc regions on exit
8743 When we exit grub, we don't free all the memory that we allocated earlier
8744 for our heap region. This can cause problems with setups where you try
8745 to descend the boot order using "exit" entries, such as PXE -> HD boot
8748 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8750 2017-09-07 Alexander Graf <agraf@suse.de>
8752 efi: Move grub_reboot() into kernel
8753 The reboot function calls machine_fini() and then reboots the system.
8754 Currently it lives in lib/ which means it gets compiled into the
8755 reboot module which lives on the heap.
8757 In a following patch, I want to free the heap on machine_fini()
8758 though, so we would free the memory that the code is running in. That
8759 obviously breaks with smarter UEFI implementations.
8761 So this patch moves it into the core. That way we ensure that all
8762 code running after machine_fini() in the UEFI case is running from
8763 memory that got allocated (and gets deallocated) by the UEFI core.
8765 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8767 2017-09-07 Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
8769 Use grub-file to figure out whether multiboot2 should be used for Xen.gz
8770 The multiboot2 is much more preferable than multiboot. Especiall
8771 if booting under EFI where multiboot does not have the functionality
8772 to pass ImageHandler.
8774 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8776 2017-09-07 Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
8778 Fix util/grub.d/20_linux_xen.in: Add xen_boot command support for aarch64
8779 Commit d33045ce7ffcb7c1e4a60c14d5ca64b36e3c5abe introduced
8780 the support for this, but it does not work under x86 (as it stops
8781 20_linux_xen from running).
8783 The 20_linux_xen is run under a shell and any exits from within it:
8785 (For example on x86):
8786 + /usr/bin/grub2-file --is-arm64-efi /boot/xen-4.9.0.gz
8787 [root@tst063 grub]# echo $?
8790 will result in 20_linux_xen exiting without continuing
8791 and also causing grub2-mkconfig to stop processing.
8795 [root@tst063 grub]# ./grub-mkconfig | tail
8796 Generating grub configuration file ...
8797 Found linux image: /boot/vmlinuz-4.13.0-0.rc5.git1.1.fc27.x86_64
8798 Found initrd image: /boot/initramfs-4.13.0-0.rc5.git1.1.fc27.x86_64.img
8799 Found linux image: /boot/vmlinuz-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2
8800 Found initrd image: /boot/initramfs-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2.img
8801 echo 'Loading Linux 0-rescue-ec082ee24aea41b9b16aca52a6d10cc2 ...'
8802 linux /vmlinuz-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2 root=/dev/mapper/fedora_tst063-root ro single
8803 echo 'Loading initial ramdisk ...'
8804 initrd /initramfs-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2.img
8808 ### END /usr/local/etc/grub.d/10_linux ###
8810 ### BEGIN /usr/local/etc/grub.d/20_linux_xen ###
8816 This patch wraps the invocation of grub-file to be a in subshell
8817 and to process the return value in a conditional. That fixes
8820 RH-BZ 1486002: grub2-mkconfig does not work if xen.gz is installed.
8822 CC: Fu Wei <fu.wei@linaro.org>
8823 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
8825 2017-09-07 Vladimir Serbinenko <phcoder@gmail.com>
8827 Fix compilation for x86_64-efi.
8829 2017-09-05 Vladimir Serbinenko <phcoder@gmail.com>
8831 Add a file missing in multiboot2 commit.
8833 2017-08-30 Vladimir Serbinenko <phcoder@google.com>
8835 gzio: fix unaligned access
8837 grub-fs-tester: Fix bashism
8839 2017-08-30 Vladimir Serbinenko <phcoder@gmail.com>
8841 Regenerate checksum.h with newer unifont.
8842 Old link is broken. New unifont is
8843 http://ftp.de.debian.org/debian/pool/main/u/unifont/xfonts-unifont_9.0.06-2_all.deb
8845 printf_unit_test: Disable Wformat-truncation on GCC >= 7
8846 We intentionally pass NULL as argument to format, hence disable the warning.
8848 qemu, coreboot, multiboot: Change linking address to 0x9000.
8849 It's common for distros to use a defective ld which links at 0x9000. Instead
8850 of fighting it, just move link target to 0x9000.
8852 2017-08-30 Stefan Fritsch <sf@sfritsch.de>
8854 Implement checksum verification for gunzip
8855 This implements the crc32 check for the gzip format. Support for zlib's
8856 adler checksum is not included, yet.
8858 2017-08-30 Vladimir Serbinenko <phcoder@gmail.com>
8860 xfs: Don't attempt to iterate over empty directory.
8861 Reported by: Tuomas Tynkkynen
8863 2017-08-30 Patrick Steinhardt <ps@pks.im>
8865 unix exec: avoid atexit handlers when child exits
8866 The `grub_util_exec_redirect_all` helper function can be used to
8867 spawn an executable and redirect its output to some files. After calling
8868 `fork()`, the parent will wait for the child to terminate with
8869 `waitpid()` while the child prepares its file descriptors, environment
8870 and finally calls `execvp()`. If something in the children's setup
8871 fails, it will stop by calling `exit(127)`.
8873 Calling `exit()` will cause any function registered via `atexit()` to be
8874 executed, which is usually the wrong thing to do in a child. And
8875 actually, one can easily observe faulty behaviour on musl-based systems
8876 without modprobe(8) installed: executing `grub-install --help` will call
8877 `grub_util_exec_redirect_all` with "modprobe", which obviously fails if
8878 modprobe(8) is not installed. Due to the child now exiting and invoking
8879 the `atexit()` handlers, it will clean up some data structures of the
8880 parent and cause it to be deadlocked in the `waitpid()` syscall.
8882 The issue can easily be fixed by calling `_exit(127)` instead, which is
8883 especially designed to be called when the atexit-handlers should not be
8886 2017-08-30 Vladimir Serbinenko <phcoder@gmail.com>
8888 arc: Do not create spurious variable grub_arc_memory_type_t.
8890 2017-08-14 Xuan Guo <nbdd0121>
8892 Set have_exec to y on cygwin so we have grub_mkrescue.
8894 2017-08-14 Vladimir Serbinenko <phcoder@gmail.com>
8902 yylex: Explicilty cast fprintf to void.
8903 It's needed to avoid warning on recent GCC.
8905 genmoddep: Check that no modules provide the same symbol.
8906 The semantics of 2 modules providing the same symbol are undefined. So
8907 ensure that it doesn't happen.
8909 Fix symbols appearing in several modules in linux*.
8910 If same symbol is provided by 2 modules its semantics are undefined.
8911 Avoid this by depending rather than double-including files.
8913 2017-08-14 Vladimir Serbinenko <phcoder@gmail.com>
8915 multiboot: disentangle multiboot and multiboot2.
8916 Previously we had multiboot and multiboot2 declaring the same symbols.
8917 This can potentially lead to aliasing and strange behaviours when e.g.
8918 module instead of module2 is used with multiboot2.
8922 2017-08-14 Vladimir Serbinenko <phcoder@gmail.com>
8924 hdparm: Depend on hexdump rather than having a second copy of hexdump.
8927 Reported by: Ori Avtalion <saltyhorse>
8929 2017-08-07 Pete Batard <pete@akeo.ie>
8931 io: add a GRUB_GZ prefix to gzio specific defines
8932 * This is done to avoid a conflict with a PACKED define in the EDK2
8934 core: use GRUB_TERM_ definitions when handling term characters
8935 * Also use hex value for GRUB_TERM_ESC as '\e' is not in the C standard and is not understood by some compilers
8937 2017-08-07 Leif Lindholm <leif.lindholm@linaro.org>
8939 efi: change heap allocation type to GRUB_EFI_LOADER_CODE
8940 With upcoming changes to EDK2, allocations of type EFI_LOADER_DATA may
8941 not return regions with execute ability. Since modules are loaded onto
8942 the heap, change the heap allocation type to GRUB_EFI_LOADER_CODE in
8943 order to permit execution on systems with this feature enabled.
8947 2017-08-07 Leif Lindholm <leif.lindholm@linaro.org>
8949 arm64 linux loader: improve type portability
8950 In preparation for turning this into a common loader for 32-bit and 64-bit
8951 platforms, ensure the code will compile cleanly for either.
8953 2017-08-07 Leif Lindholm <leif.lindholm@linaro.org>
8955 efi: Add GRUB_PE32_MAGIC definition
8956 Add a generic GRUB_PE32_MAGIC definition for the PE 'MZ' tag and delete
8957 the existing one in arm64/linux.h.
8959 Update arm64 Linux loader to use this new definition.
8961 2017-08-07 Leif Lindholm <leif.lindholm@linaro.org>
8963 efi: move fdt helper library
8964 There is nothing ARM64 (or even ARM) specific about the efi fdt helper
8965 library, which is used for locating or overriding a firmware-provided
8966 devicetree in a UEFI system - so move it to loader/efi for reuse.
8968 Move the fdtload.h include file to grub/efi and update path to
8969 efi/fdtload.h in source code referring to it.
8971 2017-08-07 Vladimir Serbinenko <phcoder@gmail.com>
8973 Remove grub_efi_allocate_pages.
8974 grub_efi_allocate_pages Essentially does 2 unrelated things:
8975 * Allocate at fixed address.
8976 * Allocate at any address.
8978 To switch between 2 different functions it uses address == 0 as magic
8979 value which is wrong as 0 is a perfectly valid fixed adress to allocate at.
8981 2017-08-07 Leif Lindholm <leif.lindholm@linaro.org>
8983 efi: refactor grub_efi_allocate_pages
8984 Expose a new function, grub_efi_allocate_pages_real(), making it possible
8985 to specify allocation type and memory type as supported by the UEFI
8986 AllocatePages boot service.
8988 Make grub_efi_allocate_pages() a consumer of the new function,
8989 maintaining its old functionality.
8991 Also delete some left-around #if 1/#else blocks in the affected
8994 2017-08-07 Vladimir Serbinenko <phcoder@gmail.com>
8996 Fail if xorriso failed.
8997 If xorriso failed most likely we didn't generate a meaningful image.
8999 mkrescue: Check xorriso presence before doing anything else.
9000 mkrescue can't do anything useful without xorriso, so abort early if it's
9003 2017-08-07 Pali Rohár <pali.rohar@gmail.com>
9005 * grub-core/fs/udf.c: Add support for UUID
9006 Use same algorithm as in libblkid from util-linux v2.30.
9008 1. Take first 16 bytes from UTF-8 encoded string of VolumeSetIdentifier
9009 2. If all bytes are hexadecimal digits, convert to lowercase and use as UUID
9010 3. If first 8 bytes are not all hexadecimal digits, convert those 8 bytes
9011 to their hexadecimal representation, resulting in 16 bytes for UUID
9012 4. Otherwise, compose UUID from two parts:
9013 1. part: converted first 8 bytes (which are hexadecimal digits) to lowercase
9014 2. part: encoded following 4 bytes to their hexadecimal representation (16 bytes)
9016 So UUID would always have 16 hexadecimal digits in lowercase variant.
9018 According to UDF specification, first 16 Unicode characters of
9019 VolumeSetIdentifier should be unique value and first 8 should be
9020 hexadecimal characters.
9022 In most cases all 16 characters are hexadecimal, but e.g. MS Windows
9023 format.exe set only first 8 as hexadecimal and remaining as fixed
9024 (non-unique) which violates specification.
9026 2017-08-07 Pali Rohár <pali.rohar@gmail.com>
9028 udf: Fix reading label, lvd.ident is dstring
9029 UDF dstring has stored length in the last byte of buffer. Therefore last
9030 byte is not part of recorded characters. And empty string in dstring is
9031 encoded as empty buffer, including first byte (compression id).
9033 2017-08-07 Pete Batard <pete@akeo.ie>
9035 zfs: remove size_t typedef and use grub_size_t instead
9036 * Prevents some toolchains from issuing a warning on size_t redef.
9038 2017-08-03 Rob Clark <rclark@redhat.com>
9040 Fix a segfault in lsefi
9041 when protocols_per_handle returns error, we can't use the pointers we
9042 passed to it, and that includes trusting num_protocols.
9044 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9046 2017-07-10 Vladimir Serbinenko <phcoder@gmail.com>
9048 fdt: silence clang warning.
9050 2017-07-09 Vladimir Serbinenko <phcoder@gmail.com>
9052 arm-efi: Fix compilation
9054 2017-07-09 AppChecker <appchecker>
9056 crypto: Fix use after free.
9057 Reported by: AppChecker
9058 Transformed to patch by: Satish Govindarajan
9060 2017-07-09 Vladimir Serbinenko <phcoder@gmail.com>
9062 ehci: Fix compilation on i386
9064 2017-07-09 phcoder <phcoder@sid.debian.laptop.phnet>
9066 cache: Fix compilation for ppc, sparc and arm64
9068 ehci: Fix compilation for amd64
9070 2017-06-29 Eric Biggers <ebiggers@google.com>
9072 Allow GRUB to mount ext2/3/4 filesystems that have the encryption feature.
9073 On such a filesystem, inodes may have EXT4_ENCRYPT_FLAG set.
9074 For a regular file, this means its contents are encrypted; for a
9075 directory, this means the filenames in its directory entries are
9076 encrypted; and for a symlink, this means its target is encrypted. Since
9077 GRUB cannot decrypt encrypted contents or filenames, just issue an error
9078 if it would need to do so. This is sufficient to allow unencrypted boot
9079 files to co-exist with encrypted files elsewhere on the filesystem.
9081 (Note that encrypted regular files and symlinks will not normally be
9082 encountered outside an encrypted directory; however, it's possible via
9083 hard links, so they still need to be handled.)
9085 Tested by booting from an ext4 /boot partition on which I had run
9086 'tune2fs -O encrypt'. I also verified that the expected error messages
9087 are printed when trying to access encrypted directories, files, and
9088 symlinks from the GRUB command line. Also ran 'sudo ./grub-fs-tester
9089 ext4_encrypt'; note that this requires e2fsprogs v1.43+ and Linux v4.1+.
9091 2017-05-29 Eric Snowberg <eric.snowberg@oracle.com>
9093 sparc64: Don't use devspec to determine the OBP path
9094 Don't use devspec to determine the OBP path on SPARC hardware. Within all
9095 versions of Linux on SPARC, the devspec returns one of three values:
9096 "none", "vnet-port", or "vdisk". Unlike on PPC, none of these values
9097 are useful in determining the OBP path.
9099 Before this patch grub-ofpathname always returned the wrong value
9100 for a virtual disk. For example:
9102 % grub-ofpathname /dev/vdiskc2
9105 After this patch it now returns the correct value:
9107 % grub-ofpathname /dev/vdiskc2
9108 /virtual-devices@100/channel-devices@200/disk@2:b
9112 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9114 2017-05-18 Fu Wei <fu.wei@linaro.org>
9116 arm64: Update the introduction of Xen boot commands in docs/grub.texi
9117 delete: xen_linux, xen_initrd, xen_xsm
9120 This update bases on
9121 commit 0edd750e50698854068358ea53528100a9192902
9122 Author: Vladimir Serbinenko <phcoder@gmail.com>
9123 Date: Fri Jan 22 10:18:47 2016 +0100
9125 xen_boot: Remove obsolete module type distinctions.
9127 Also bases on the module loading mechanism of Xen code:
9128 488c2a8 docs/arm64: clarify the documention for loading XSM support
9129 67831c4 docs/arm64: update the documentation for loading XSM support
9130 ca32012 xen/arm64: check XSM Magic from the second unknown module.
9132 Reviewed-by: Julien Grall <julien.grall@arm.com>
9133 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9135 2017-05-18 Fu Wei <fu.wei@linaro.org>
9137 util/grub.d/20_linux_xen.in: Add xen_boot command support for aarch64
9138 This patch adds the support of xen_boot command for aarch64:
9141 These two commands are only for aarch64, since it has its own protocol and
9142 commands to boot xen hypervisor and Dom0, but not multiboot.
9144 For other architectures, they are still using multiboot and module
9147 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9149 2017-05-18 Fu Wei <fu.wei@linaro.org>
9151 arm64: Add "--nounzip" option support in xen_module command
9152 This patch adds "--nounzip" option support in order to
9153 be compatible with the module command of multiboot on other architecture,
9154 by this way we can simplify grub-mkconfig support code.
9156 This patch also allow us to use zip compressed module(like Linux kernel
9159 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9161 2017-05-18 Julien Grall <julien.grall@linaro.org>
9163 arm64/xen_boot: Fix Xen boot using GRUB2 on AARCH64
9164 Xen is currently crashing because of malformed compatible property for
9165 the boot module. This is because the property string is not
9166 null-terminated as requested by the ePAR spec.
9168 Tested-by: Fu Wei <fu.wei@linaro.org>
9169 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9171 2017-05-18 Eric Snowberg <eric.snowberg@oracle.com>
9173 sparc64: Close cdboot ihandle
9174 The ihandle is left open with a cd-core image. This will cause a delay
9175 booting grub from a virtual cdrom in a LDOM. It will also cause problems
9176 as Linux boots, since it expects the ihandle to be closed during init.
9180 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9182 2017-05-09 Vladimir Serbinenko <phcoder@gmail.com>
9184 at_keyboard: Fix falco chromebook case.
9185 EC is slow, so we need few delays for it to toggle the bits correctly.
9187 Command to enable clock and keyboard were not sent.
9189 2017-05-09 Julius Werner <jwerner@chromium.org>
9191 coreboot: Changed cbmemc to support updated console format from coreboot.
9193 2017-05-09 Vladimir Serbinenko <phcoder@gmail.com>
9195 Missing parts of previous commit
9197 arm_coreboot: Add Chromebook keyboard driver.
9199 rk3288_spi: Add SPI driver
9201 fdtbus: Add ability to send/receive messages on parent busses.
9203 Fix bug on FDT nodes with compatible property
9205 2017-05-08 Vladimir Serbinenko <phcoder@gmail.com>
9207 arm_coreboot: Support EHCI.
9209 ehci: Split core code from PCI part.
9210 On ARM often EHCI is present without PCI and just declared in device
9211 tree. So splitcore from PCI part.
9213 arm_coreboot: Support DMA.
9214 This is needed to support USB and some other busses.
9216 arm_coreboot: Support loading linux images.
9218 arm_coreboot: Support grub-mkstandalone.
9220 arm_coreboot: Support keyboard for vexpress.
9222 at_keyboard: Split protocol from controller code.
9223 On vexpress controller is different but protocol is the same, so reuse the
9226 arm-coreboot: Export FDT routines.
9227 We need to use them from modules as well.
9229 arm-coreboot: Support for vexpress timer.
9231 Add support for device-tree-based drivers.
9233 arm-coreboot: Start new port.
9235 Rename uboot/datetime to dummy/datetime.
9236 It's just a stub and is not UBoot-specific.
9238 Rename uboot/halt.c to dummy/halt.c.
9239 It's not U-Boot specific and it's a stub.
9241 coreboot: Split parts that are platform-independent.
9242 We currently assume that coreboot is always i386, it's no longer the case,
9243 so split i386-coreboot parts from generic coreboot code.
9245 Refactor arm-uboot code to make it genereic.
9246 arm-coreboot startup code can be very similar to arm-uboot but current code has
9247 U-Boot specific references. So split U-Boot part from generic part.
9249 mkimage: Pass layout to mkimage_generate_elfXX rather than some fields.
9250 This allows easier extension of this function without having too long of
9253 2017-05-03 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
9255 Add Virtual LAN support.
9256 This patch adds support for virtual LAN (VLAN) tagging. VLAN tagging allows
9257 multiple VLANs in a bridged network to share the same physical network link
9258 but maintain isolation:
9260 http://en.wikipedia.org/wiki/IEEE_802.1Q
9262 * grub-core/net/ethernet.c: Add check, get, and set vlan tag id.
9263 * grub-core/net/drivers/ieee1275/ofnet.c: Get vlan tag id from bootargs.
9264 * grub-core/net/arp.c: Add check.
9265 * grub-core/net/ip.c: Likewise.
9266 * include/grub/net/arp.h: Add vlantag attribute.
9267 * include/grub/net/ip.h: Likewise.
9269 2017-05-03 Vladimir Serbinenko <phcoder@gmail.com>
9271 strtoull: Fix behaviour on chars between '9' and 'a'.
9272 Reported by: Aaron Miller <aaronmiller@fb.com>
9276 Fix shebang for termux.
9277 Termux doesn't have a /bin/sh. So we needto use $SHELL.
9278 Keep /bin/sh as much as possible.
9280 Add termux path to dict.
9282 po: Use @SHELL@ rather than /bin/sh.
9283 /bin/sh might not exist.
9285 Use $(SHELL) rather than /bin/sh.
9286 /bin/sh doesn't exist under termux.
9289 Android doesn't have 64-bit off_t, so use off64_t instead.
9291 Don't retrieve fstime when it's not useful.
9293 support busybox date.
9294 Busybox date doesn't understand weekdays in -d input,
9295 so strip them beforehand.
9297 fs-tester: make sh-compatible
9299 Remove bashisms from tests.
9300 Those tests don't actually need bash. Just use common shebang.
9302 Bump version to 2.03
9304 2017-04-25 Vladimir Serbinenko <phcoder@gmail.com>
9306 Increase version to 2.02.
9308 2017-04-12 Vladimir Serbinenko <phcoder@gmail.com>
9310 Fix remaining cases of gcc 7 fallthrough warning.
9311 They are all intended, so just add the relevant comment.
9313 2017-04-04 Andrei Borzenkov <arvidjaar@gmail.com>
9315 Add gnulib-fix-gcc7-fallthrough.diff
9316 As long as the code is not upstream, add it as explicit patch for the
9317 case of gnulib refresh.
9319 2017-04-04 Andrei Borzenkov <arvidjaar@gmail.com>
9321 i386, x86_64, ppc: fix switch fallthrough cases with GCC7
9322 In util/getroot and efidisk slightly modify exitsing comment to mostly
9323 retain it but still make GCC7 compliant with respect to fall through
9326 In grub-core/lib/xzembed/xz_dec_lzma2.c it adds same comments as
9329 In grub-core/tests/setjmp_tets.c declare functions as "noreturn" to
9330 suppress GCC7 warning.
9332 In grub-core/gnulib/regexec.c use new __attribute__, because existing
9333 annotation is not recognized by GCC7 parser (which requires that comment
9334 immediately precedes case statement).
9336 Otherwise add FALLTHROUGH comment.
9340 2017-04-04 Andrei Borzenkov <arvidjaar@gmail.com>
9342 btrfs: avoid "used uninitialized" error with GCC7
9343 sblock was local and so considered new variable on every loop
9348 2017-04-02 Andrei Borzenkov <arvidjaar@gmail.com>
9350 acpi: add missing efi_call wrapper to acpi command
9351 Fixed loading of ACPI tables on EFI (side effect was apparent memory
9352 corruption ranging from unpredictable behavior to system reset).
9354 Reported by Nando Eva <nando4eva@ymail.com>
9356 2017-03-15 Vladimir Serbinenko <phcoder@gmail.com>
9358 Increment version to GRUB 2.02~rc2.
9360 Use core2duo for bootcheck test on 64-bit EFI.
9361 Obviously pentium2 can't run efi64.
9363 2017-03-14 Andrei Borzenkov <arvidjaar@gmail.com>
9365 efi: skip iPXE block device.
9366 iPXE adds Simple File System Protocol to loaded image handle, as side
9367 effect it also adds Block IO protocol (according to comments, to work
9368 around some bugs in EDK2). GRUB assumes that every device with Block IO
9369 is disk and skips network initialization entirely. But iPXE Block IO
9370 implementation is just a stub which always fails for every operation
9371 so cannot be used. Attempt to detect and skip such devices.
9373 We are using media ID which iPXE sets to "iPXE" and block IO size in
9374 hope that no real device would announce 1B block ...
9378 2017-03-05 phcoder <phcoder@gmail.com>
9380 xen: Fix wrong register in relocator.
9381 This fixes chainloading of some GRUB variants.
9383 2017-02-27 Vladimir Serbinenko <phcoder@gmail.com>
9385 video_fb: Fix blue collor if using unoptimized blitter.
9386 when unmapping the color what matters is the mode of source, not target.
9388 legacy_initrd: Strip any additional arguments to initrd.
9390 2017-02-26 Andrei Borzenkov <arvidjaar@gmail.com>
9392 grub-fs-tester: improve squash4 tests
9393 1. Make sure files are not multiple of block size. This will ensure tail packing
9394 for squash4 and may also trigger more codes paths in other filesystems.
9396 2. Call mksquashfs with -always-use-fragments to force tail packing.
9398 2017-02-25 Andrei Borzenkov <arvidjaar@gmail.com>
9400 efi: strip off final NULL from File Path in grub_efi_get_filename
9401 UEFI 2.6 9.3.6.4 File Path Media Device Path says that Path Name is
9402 "A NULL-terminated Path string including directory and file names".
9404 Strip final NULL from Path Name in each File Path node when constructing
9405 full path. To be on safe side, strip all of them.
9407 Fixes failure chainloading grub from grub, when loaded grub truncates
9408 image path and does not find its grub.cfg.
9410 https://bugzilla.opensuse.org/show_bug.cgi?id=1026344
9412 This was triggered by commit ce95549cc54b5d6f494608a7c390dba3aab4fba7;
9413 before it we built Path Name without trailing NULL, and apparently all
9414 other bootloaders use single File Path node, thus not exposing this bug.
9416 2017-02-24 Andrei Borzenkov <arvidjaar@gmail.com>
9418 squash4: fix handling of fragments and sparse files
9419 1. Do not assume block list and fragment are mutually exclusive. Squash
9420 can pack file tail as fragment (unless -no-fragments is specified); so
9421 check read offset and read either from block list or from fragments as
9424 2. Support sparse files with zero blocks.
9426 3. Fix fragment read - frag.offset is absolute fragment position,
9427 not offset relative to ino.chunk.
9429 Reported and tested by Carlo Caione <carlo@endlessm.com>
9431 2017-02-22 Vladimir Serbinenko <phcoder@gmail.com>
9433 Whitelist sparc64-ieee1275 as having no video modules.
9434 ieee1275_fb is not built on sparc64 due to virtual address issues.
9436 2017-02-12 Andrei Borzenkov <arvidjaar@gmail.com>
9438 script: fix double free in lexer
9439 yylex_destroy() already frees scanner.
9441 Found by: Coverity scan.
9444 2017-02-07 Vladimir Serbinenko <phcoder@gmail.com>
9446 xen: Fix parsing of XZ kernel.
9447 In case of xz, the uncompressed size is appended to xz data which confuses
9448 our xz decompressor. Trim it.
9450 2017-02-07 Vladimir Serbinenko <phcoder@gmail.com>
9452 xen: Fix handling of GRUB chainloading.
9453 In case of GRUB we put remapper after domain pages and not at 0x0.
9454 In this case we use max_addr to put remapper. Unfortunately we increment
9455 max_addr as well in this case resulting in virt mapping mapping page
9456 at old max_addr and trying to boot using new max_addr.
9460 2017-02-04 Vladimir Serbinenko <phcoder@gmail.com>
9462 linguas: Don't skip ko.po.
9463 Translation project doesn't require copyright disclaimers. They're independant
9464 from us. They're responsible for their copyright story.
9466 2017-02-03 Vladimir Serbinenko <phcoder@gmail.com>
9468 Fix truncated checksum.h.
9470 Regenerate checksums.h
9471 Screenshots contain version, so we need new checksums.
9475 Fix mingw compilation.
9477 2017-02-03 Daniel Kahn Gillmor <dkg@fifthhorseman.net>
9479 documentation: Clarify documentation for special environment variable "default".
9480 The current documentation for the special environment variable
9481 "default" is confusing and unclear. This patch attempts to clean it
9484 In particular, the current documentation refers to the "number or
9485 title", but then in the example it gives, the menu entries and
9486 submenus all have numbers *in* their title; furthermore, there is no
9487 example given about how to choose the number, or any indication about
9488 whether counting is zero-indexed or 1-indexed.
9490 Having a cleaner example and presenting all variants (numeric, title,
9491 and id) should make it clearer to the user.
9493 2017-02-03 Vladimir Serbinenko <phcoder@gmail.com>
9495 Avoid causing kernel oops in nilfs2 test.
9496 1024-byte and 2048-byte blocks don't really work with some kernels, skip
9497 them as we don't want any oops'es.
9499 btrfs: Shorten label by one character.
9500 mkfs.btrfs imposes a slightly lower limit than would be possible in btrfs.
9502 2017-02-02 Vladimir Serbinenko <phcoder@gmail.com>
9504 grub-fs-tester: Fix mkudffs invocation.
9505 With current invocation order of arguments is wrong and path is hardcoded.
9507 grub-fs-tester: Fix fat test.
9508 mkfs.vfat ignores -S when invoked on a disk, including loopback device,
9509 so do an mkfs on underlying image.
9511 2017-02-02 Daniel Kiper <daniel.kiper@oracle.com>
9513 i386/relocator: Align stack in grub_relocator64_efi relocator
9514 Unified Extensible Firmware Interface Specification, Version 2.6,
9515 section 2.3.4, x64 Platforms, boot services, says among others:
9516 The stack must be 16-byte aligned. So, do it. Otherwise OS may
9517 boot only by chance as it happens right now.
9519 2017-02-02 Vladimir Serbinenko <phcoder@gmail.com>
9521 i386-ieee1275: Add missing bootcheck target.
9523 bootcheck-linux-i386: Use -cpu pentium2.
9524 Most modern kernels are compiled for i686, so use -cpu pentium2
9525 to avoid spurious failures.
9527 Use -fPIC with arm64 with clang.
9528 Currently it doesn't work either way but with -fPIC it should work once
9531 INSTALL: Fix mention of thumb-clang.
9533 Fix thumb compilation with clang.
9534 According to EABI only STT_FUNC has convention of lowest bit indicating
9535 execution mode. R_THM_{JUMP,CALL}* relocations are assumed to be pointing
9536 to thumb mode unless they use STT_FUNC.
9538 2017-02-01 Vladimir Serbinenko <phcoder@gmail.com>
9540 Add missing strtoull_test.c
9541 It was forgotten in my local directory.
9543 arm64: Add support for GOT and PCREL32 relocations.
9545 mkimage: Fix memory leak.
9547 arm/arm64: Fix improper use of start address.
9548 It was used instead of loading address of current section or of entire buffer.
9550 ia64: Fix iterator for relocation entries.
9551 Don't assume relocation entry size and use sh_entsize properly.
9553 arm: Fix trampoline generation.
9554 We used the wrong pointer in this case. It worked only by accident.
9556 Fix bootcheck-related files compilation.
9557 We need -static as otherwise linker will set interpreter field and ld.so
9558 is not available on our initrd's.
9559 Strip all sections we don't need on binary tests.
9561 2017-01-31 Vladimir Serbinenko <phcoder@gmail.com>
9563 Regenerate checksum.h.
9564 Screenshots checked.
9565 Using unifont from http://ftp.us.debian.org/debian/pool/main/u/unifont/xfonts-unifont_7.0.06-1_all.deb.
9567 grub-mkfont: Remove leftover debug statement.
9569 charset: Trim away RLM and LRM.
9570 They are not visible but would otherwise end up as [LRM] or [RLM] squares
9573 gfxterm: Fix clearing of cursor.
9574 If ascent is bigger than height - 2, then we draw over character box but then
9575 to clear cursor we only draw over character box. So trim ascent if necessarry.
9577 ia64: Add support for R_IA64_GPREL64I.
9578 Recent GCC generates those relocations, so we need to support them.
9580 2017-01-30 Vladimir Serbinenko <phcoder@gmail.com>
9582 grub-module-verifier: Add mips to all_video whitelist.
9583 On MIPS video is compiled-in. So all_video is empty. Whitelist it.
9585 Fix -nopie/-nopie check.
9586 We don't use lgcc_s but missing lgcc_s or another library cause test to fail.
9588 We need to use -Werror to avoid warning-generated case to be accepted.
9589 Clang uses -nopie rather than -no-pie. Check both and use whichever one works.
9590 Additionally android clang passes -pie to the linker even though it doesn't
9591 define __PIE__. So if compilation without no-pie logic fails add -nopie/-no-pie
9592 even if __PIE__ is not defined.
9594 grub-module-verifier: Ignore all_video emptiness on xen.
9595 It's intentional that it's empty when no video modules
9598 2017-01-28 Vladimir Serbinenko <phcoder@gmail.com>
9600 Support arm clang 3.8 amd later.
9601 clang 3.8 and later doesn't support -mllvm -use-arm-movt=0
9602 whereas older clang doesn't know -mno-movt. So use
9603 -mno-movt whenever possible and fallback to mllvm variant.
9605 2017-01-27 Carlo Caione <carlo@endlessm.com>
9607 exfat: Support files over 4GiB
9608 file size in grub_fat_data was 32-bit on exfat.
9610 2017-01-27 Vladimir Serbinenko <phcoder@gmail.com>
9612 Ensure that grub_reboot doesn't return on emu.
9613 Use grub_fatal if longjmp fails.
9615 grub_reboot is marked as noreturn so return would cause
9618 2017-01-27 Vladimir Serbinenko <phcoder@gmail.com>
9620 grub-shell: skip font copying when no font is available.
9622 Don't use -mlong-calls on arm.
9623 We don't really need it and it's flaky and creates
9624 bogus symbols with clang.
9626 configure: Disable movw/movt with clang.
9627 Those relocations are not compatible with PE and also
9628 not compatible with custom uboot relocator.
9631 grub-fs-tester: Delete directory once we're done.
9633 grub-fs-tester: Accomodate for slower systems.
9634 fstime can be more different with xz squashfs.
9635 Allow difference up to 3 seconds.
9636 This code is ugly now but rewriting it now is not on the
9639 grub-fs-tester: Accomodate for testing in proot containers.
9640 proot creates hidden files with .proot prefix and name
9641 derived from real file name. So decrease file name length
9642 and path depth. For some reason depth 85 also results in
9643 undeleteable directory, so use 84 instead of 85.
9645 2017-01-24 Andrei Borzenkov <arvidjaar@gmail.com>
9647 osdep/linux: handle autofs entries in /proc/self/mountinfo
9648 These entries have placeholder for device name and so are useless for our
9649 purpose. grub failed with something like
9651 grub-install: error: failed to get canonical path of `systemd-1'.
9653 When we see autofs entry, record it (to keep parent-child relationship) but
9654 continue to look for real mount. If it is found, we process it as usual. If
9655 only autofs entry exists, attempt to trigger mount by opening mount point
9656 and retry. Mount point itself is then kept open to avoid timeout.
9658 Recent systemd is by default using automount for /boot/efi so this should
9659 become more popular problem on EFI systems.
9663 2017-01-08 Andrei Borzenkov <arvidjaar@gmail.com>
9665 linux: fix "vga=XX deprecated" warning for text mode
9666 Arguments were in reverse order which resulted in
9668 text is deprecated. Use set gfxpayload=vga=0 before linux command instead.
9670 2016-12-22 Andrei Borzenkov <arvidjaar@gmail.com>
9672 configure: fix check for sys/sysmacros.h under glibc 2.25+
9673 glibc 2.25 still includes sys/sysmacros.h in sys/types.h but also emits
9674 deprecation warning. So test for sys/types.h succeeds in configure but later
9675 compilation fails because we use -Werror by default.
9677 While this is fixed in current autoconf GIT, we really cannot force everyone
9678 to use bleeding edge (that is not even released right now). So run test under
9679 -Werror as well to force proper detection.
9681 This should have no impact on autoconf 2.70+ as AC_HEADER_MAJOR in this version
9682 simply checks for header existence.
9684 Reported and tested by Khem Raj <raj.khem@gmail.com>
9686 2016-12-22 Michael Chang <mchang@suse.com>
9688 Fix fwpath in efi netboot
9689 The path returned by grub_efi_net_config has already been stripped for the
9690 directory part extracted from cached bootp packet. We should just return the
9691 result to avoild it be stripped again.
9693 It fixed the problem that grub.efi as NBP image always looking for grub.cfg and
9694 platform directory in upper folder rather than current one it gets loaded while
9695 $prefix is empty. The behavior is inconsistent with other architecture and how
9696 we would expect empty $prefix going to be in general.
9698 The only exception to the general rule of empty $prefix is that when loaded
9699 from platform directory itself, the platform part is stripped thus upper folder
9700 is used for looking up files. It meets the case for how grub-mknetdir lay out
9701 the files under tftp root directory, but also hide away this issue to be
9702 identified as it appears to be just works.
9704 Also fix possible memory leak by moving grub_efi_get_filename() call after
9705 grub_efi_net_config().
9707 2016-12-15 Andrei Borzenkov <arvidjaar@gmail.com>
9709 efi: properly terminate filepath with NULL in chainloader
9710 EFI File Path Media Device Path is defined as NULL terminated string;
9711 but chainloader built file paths without final NULL. This caused error
9712 with Secure Boot and Linux Foundation PreLoader on Acer with InsydeH20 BIOS.
9713 Apparently firmware failed verification with EFI_INVALID_PARAMETER which is
9714 considered fatal error by PreLoader.
9716 Reported and tested by Giovanni Santini <itachi.sama.amaterasu@gmail.com>
9718 2016-12-14 Magnus Granberg <zorry@gentoo.org>
9720 configure: add check for -no-pie if the compiler default to -fPIE
9721 When Grub is compile with gcc 6.1 that have --enable-defult-pie set.
9723 -ffreestanding -m32 -Wl,-melf_i386 -Wl,--build-id=none -nostdlib -Wl,-N -Wl,-r,-d -
9724 o trig.module trig_module-trigtables.o
9725 grep 'MARKER' gcry_whirlpool.marker.new > gcry_whirlpool.marker; rm -f
9726 gcry_whirlpool.marker.new
9727 /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: -r and -
9728 shared may not be used together
9729 collect2: error: ld returned 1 exit status
9730 Makefile:26993: recipe for target 'trig.module' failed
9732 Check that compiler supports -no-pie and add it to linker flags.
9734 2016-12-14 Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
9736 ofnet: implement the receive buffer
9737 get_card_packet() from ofnet.c allocates a netbuff based on the device's MTU:
9739 nb = grub_netbuff_alloc (dev->mtu + 64 + 2);
9741 In the case when the MTU is large, and the received packet is
9742 relatively small, this leads to allocation of significantly more memory,
9743 than it's required. An example could be transmission of TFTP packets
9744 with 0x400 blksize via a network card with 0x10000 MTU.
9746 This patch implements a per-card receive buffer in a way similar to efinet.c,
9747 and makes get_card_packet() allocate a netbuff of the received data size.
9749 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9751 2016-12-14 Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
9753 ofnet: move the allocation of the transmit buffer into a function
9754 In the current code search_net_devices() uses the "alloc-mem" command
9755 from the IEEE1275 User Interface for allocation of the transmit buffer
9756 for the case when GRUB_IEEE1275_FLAG_VIRT_TO_REAL_BROKEN is set.
9758 I don't have hardware where this flag is set to verify if this
9759 workaround is still needed. However, further changes to ofnet will
9760 require to execute this workaround one more time. Therefore, to
9761 avoid possible duplication of code I'm moving this piece of
9762 code into a function.
9764 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9766 2016-11-24 Alexander Graf <agraf@suse.de>
9768 efi: Move fdt helper into own file
9769 We only support FDT files with EFI on arm and arm64 systems, not
9770 on x86. So move the helper that finds a prepopulated FDT UUID
9771 into its own file and only build it for architectures where it
9774 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9776 2016-11-22 Andrei Borzenkov <arvidjaar@gmail.com>
9780 2016-11-22 Andrei Borzenkov <arvidjaar@gmail.com>
9782 bootp: export next server IP as environment variable
9783 Network boot autoconfiguration sets default server to next server IP
9784 (siaddr) from BOOTP/DHCP reply, but manual configuration using net_bootp
9785 exports only server name. Unfortunately semantic of server name is not
9786 clearly defined. BOOTP RFC 951 defines it only for client request, and
9787 DHCP RFC 1541 only mentions it, without any implied usage. It looks like
9788 this field is mostly empty in server replies.
9790 Export next server IP as net_<interface>_next_server variable. This allows
9791 grub configuration script to set $root/$prefix based on information obtained
9794 Reported and tested by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
9795 Cc: nikunj@linux.vnet.ibm.com
9797 v2: change variable name to net_<interface>_next_server as discussed on the list
9799 2016-11-22 Aaro Koskinen <aaro.koskinen@iki.fi>
9801 configure.ac: don't require build time grub-mkfont on powerpc-ieee1275
9802 Don't require build time grub-mkfont on powerpc-ieee1275.
9804 2016-11-14 Dirk Mueller <dmueller@suse.com>
9806 grub-mknetdir: Add support for ARM64 EFI
9808 2016-11-12 Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
9810 .gitignore: Add grub-core/build-grub-module-verifier
9812 2016-11-10 Alexander Graf <agraf@suse.de>
9814 arm efi: Use fdt from firmware when available
9815 If EFI is nice enough to pass us an FDT using configuration tables on 32bit
9816 ARM, we should really try and make use of it.
9818 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9820 2016-11-10 Alexander Graf <agraf@suse.de>
9822 arm64: Move firmware fdt search into global function
9823 Searching for a device tree that EFI passes to us via configuration tables
9824 is nothing architecture specific. Move it into generic code.
9826 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9828 2016-11-05 Corey Hickey <bugfood-ml@fatooh.org>
9830 fix detection of non-LUKS CRYPT
9831 grub_util_get_dm_abstraction() does a string comparison of insufficient
9832 length. When using a UUID such as "CRYPT-PLAIN-sda6_crypt", the function
9833 returns GRUB_DEV_ABSTRACTION_LUKS.
9835 This results in the error:
9836 ./grub-probe: error: disk `cryptouuid/sda6_crypt' not found.
9838 This appears to be a copy/paste error introduced in:
9839 a10e7a5a8918bea6e2632055129fa9b516fe965a
9841 The bug was (apparently) latent until revealed by:
9842 3bca85b4184f74995a7cc2791e432173fde26d34
9844 2016-10-27 Juergen Gross <jgross@suse.com>
9846 xen: add capability to load p2m list outside of kernel mapping
9847 Modern pvops linux kernels support a p2m list not covered by the
9848 kernel mapping. This capability is flagged by an elf-note specifying
9849 the virtual address the kernel is expecting the p2m list to be mapped
9852 In case the elf-note is set by the kernel don't place the p2m list
9853 into the kernel mapping, but map it to the given address. This will
9854 allow to support domains with larger memory, as the kernel mapping is
9855 limited to 2GB and a domain with huge memory in the TB range will have
9856 a p2m list larger than this.
9858 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9860 2016-10-27 Juergen Gross <jgross@suse.com>
9862 xen: modify page table construction
9863 Modify the page table construction to allow multiple virtual regions
9864 to be mapped. This is done as preparation for removing the p2m list
9865 from the initial kernel mapping in order to support huge pv domains.
9867 This allows a cleaner approach for mapping the relocator page by
9868 using this capability.
9870 The interface to the assembler level of the relocator has to be changed
9871 in order to be able to process multiple page table areas.
9873 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9875 2016-10-27 Juergen Gross <jgross@suse.com>
9877 xen: add capability to load initrd outside of initial mapping
9878 Modern pvops linux kernels support an initrd not covered by the initial
9879 mapping. This capability is flagged by an elf-note.
9881 In case the elf-note is set by the kernel don't place the initrd into
9882 the initial mapping. This will allow to load larger initrds and/or
9883 support domains with larger memory, as the initial mapping is limited
9884 to 2GB and it is containing the p2m list.
9886 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9888 2016-10-27 Juergen Gross <jgross@suse.com>
9890 xen: factor out allocation of page tables into separate function
9891 Do the allocation of page tables in a separate function. This will
9892 allow to do the allocation at different times of the boot preparations
9893 depending on the features the kernel is supporting.
9895 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9897 2016-10-27 Juergen Gross <jgross@suse.com>
9899 xen: factor out allocation of special pages into separate function
9900 Do the allocation of special pages (start info, console and xenbus
9901 ring buffers) in a separate function. This will allow to do the
9902 allocation at different times of the boot preparations depending on
9903 the features the kernel is supporting.
9905 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9907 2016-10-27 Juergen Gross <jgross@suse.com>
9909 xen: factor out p2m list allocation into separate function
9910 Do the p2m list allocation of the to be loaded kernel in a separate
9911 function. This will allow doing the p2m list allocation at different
9912 times of the boot preparations depending on the features the kernel
9915 While at this remove superfluous setting of first_p2m_pfn and
9916 nr_p2m_frames as those are needed only in case of the p2m list not
9917 being mapped by the initial kernel mapping.
9919 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9921 2016-10-27 Juergen Gross <jgross@suse.com>
9923 xen: synchronize xen header
9924 Get actual version of include/xen/xen.h from the Xen repository in
9925 order to be able to use constants defined there.
9927 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9929 2016-10-27 Juergen Gross <jgross@suse.com>
9931 xen: add elfnote.h to avoid using numbers instead of constants
9932 Various features and parameters of a pv-kernel are specified via
9933 elf notes in the kernel image. Those notes are part of the interface
9934 between the Xen hypervisor and the kernel.
9936 Instead of using num,bers in the code when interpreting the elf notes
9937 make use of the header supplied by Xen for that purpose.
9939 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9941 2016-10-27 Juergen Gross <jgross@suse.com>
9943 xen: reduce number of global variables in xen loader
9944 The loader for xen paravirtualized environment is using lots of global
9945 variables. Reduce the number by making them either local or by putting
9946 them into a single state structure.
9948 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9950 2016-10-27 Juergen Gross <jgross@suse.com>
9952 xen: avoid memleaks on error
9953 When loading a Xen pv-kernel avoid memory leaks in case of errors.
9955 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9957 2016-10-27 Juergen Gross <jgross@suse.com>
9959 xen: make xen loader callable multiple times
9960 The loader for xen paravirtualized environment isn't callable multiple
9961 times as it won't free any memory in case of failure.
9963 Call grub_relocator_unload() as other modules do it before allocating
9964 a new relocator or when unloading the module.
9966 Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9968 2016-10-27 Daniel Kiper <daniel.kiper@oracle.com>
9970 multiboot2: Add support for relocatable images
9971 Currently multiboot2 protocol loads image exactly at address specified in
9972 ELF or multiboot2 header. This solution works quite well on legacy BIOS
9973 platforms. It is possible because memory regions are placed at predictable
9974 addresses (though I was not able to find any spec which says that it is
9975 strong requirement, so, it looks that it is just a goodwill of hardware
9976 designers). However, EFI platforms are more volatile. Even if required
9977 memory regions live at specific addresses then they are sometimes simply
9978 not free (e.g. used by boot/runtime services on Dell PowerEdge R820 and
9979 OVMF). This means that you are not able to just set up final image
9980 destination on build time. You have to provide method to relocate image
9981 contents to real load address which is usually different than load address
9982 specified in ELF and multiboot2 headers.
9984 This patch provides all needed machinery to do self relocation in image code.
9985 First of all GRUB2 reads min_addr (min. load addr), max_addr (max. load addr),
9986 align (required image alignment), preference (it says which memory regions are
9987 preferred by image, e.g. none, low, high) from multiboot_header_tag_relocatable
9988 header tag contained in binary (at this stage load addresses from multiboot2
9989 and/or ELF headers are ignored). Later loader tries to fulfill request (not only
9990 that one) and if it succeeds then it informs image about real load address via
9991 multiboot_tag_load_base_addr tag. At this stage GRUB2 role is finished. Starting
9992 from now executable must cope with relocations itself using whole static and
9993 dynamic knowledge provided by boot loader.
9995 This patch does not provide functionality which could do relocations using
9996 ELF relocation data. However, I was asked by Konrad Rzeszutek Wilk and Vladimir
9997 'phcoder' Serbinenko to investigate that thing. It looks that relevant machinery
9998 could be added to existing code (including this patch) without huge effort.
9999 Additionally, ELF relocation could live in parallel with self relocation provided
10000 by this patch. However, during research I realized that first of all we should
10001 establish the details how ELF relocatable image should look like and how it should
10002 be build. At least to build proper test/example files.
10004 So, this patch just provides support for self relocatable images. If ELF file
10005 with relocs is loaded then GRUB2 complains loudly and ignores it. Support for
10006 such files will be added later.
10008 This patch was tested with Xen image which uses that functionality. However, this Xen
10009 feature is still under development and new patchset will be released in about 2-3 weeks.
10011 Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
10013 2016-10-27 Daniel Kiper <daniel.kiper@oracle.com>
10015 multiboot2: Do not pass memory maps to image if EFI boot services are enabled
10016 If image requested EFI boot services then skip multiboot2 memory maps.
10017 Main reason for not providing maps is because they will likely be
10018 invalid. We do a few allocations after filling them, e.g. for relocator
10019 needs. Usually we do not care as we would have finished boot services.
10020 If we keep boot services then it is easier/safer to not provide maps.
10021 However, if image needs memory maps and they are not provided by bootloader
10022 then it should get itself just before ExitBootServices() call.
10024 Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
10025 Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
10027 2016-10-27 Daniel Kiper <daniel.kiper@oracle.com>
10029 multiboot2: Add tags used to pass ImageHandle to loaded image
10030 Add tags used to pass ImageHandle to loaded image if requested.
10031 It is used by at least ExitBootServices() function.
10033 Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
10034 Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
10036 2016-10-27 Daniel Kiper <daniel.kiper@oracle.com>
10038 i386/relocator: Add grub_relocator64_efi relocator
10039 Add grub_relocator64_efi relocator. It will be used on EFI 64-bit platforms
10040 when multiboot2 compatible image requests MULTIBOOT_TAG_TYPE_EFI_BS. Relocator
10041 will set lower parts of %rax and %rbx accordingly to multiboot2 specification.
10042 On the other hand processor mode, just before jumping into loaded image, will
10043 be set accordingly to Unified Extensible Firmware Interface Specification,
10044 Version 2.4 Errata B, section 2.3.4, x64 Platforms, boot services. This way
10045 loaded image will be able to use EFI boot services without any issues.
10047 Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
10048 Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
10050 2016-10-18 Sakar Arora <Sakar.Arora@nxp.com>
10052 net/ip: Fix limit_time calculation in freeing old fragments
10053 limit_time underflows when current time is less than 90000ms.
10054 This causes packet fragments received during this time, i.e.,
10055 till 90000ms pass since timer init, to be rejected.
10057 Hence, set it to 0 if its less than 90000.
10059 2016-09-28 Andrei Borzenkov <arvidjaar@gmail.com>
10061 asm-tests/i386-pc: Check that movl is 5 bytes.
10062 LLVM 3.9 now emits short form of jump instructions, but it is still using
10063 32 bit addresses for some movl instructions. Fortunately it was caught early:
10065 clang ... boot/i386/pc/boot.S
10066 clang -cc1as: fatal error: error in backend: invalid .org offset '440' (at offset '441')
10068 Add additional check to catch it during configure run and force -no-integrated-as.
10073 https://lists.gnu.org/archive/html/grub-devel/2015-02/msg00099.html
10074 https://llvm.org/bugs/show_bug.cgi?id=22662
10076 2016-08-13 Pete Batard <pete@akeo.ie>
10078 Add missing va_end() to xasprintf() in grub-emu.
10080 2016-07-27 Andrei Borzenkov <arvidjaar@gmail.com>
10082 at_keyboard: fix numpad "0" and "." mapping
10083 Reported for set 1 by fgndevelop <fgndevelop@posteo.org>. Apparently
10084 set 2 was reversed too.
10086 2016-07-26 Andrei Borzenkov <arvidjaar@gmail.com>
10088 dns: fix buffer overflow for data->addresses in recv_hook
10089 We may get more than one response before exiting out of loop in
10090 grub_net_dns_lookup, but buffer was allocated for the first response only,
10091 so storing answers from subsequent replies wrote past allocated size.
10092 We never really use more than the very first address during lookup so there
10093 is little point in collecting all of them. Just quit early if we already have
10096 Code needs serious redesign to actually collect multiple answers
10097 and select the best fit according to requested type (IPv4 or IPv6).
10099 Reported and tested by Michael Chang <mchang@suse.com>
10101 2016-07-26 Andrei Borzenkov <arvidjaar@gmail.com>
10103 xfs: accept filesystem with meta_uuid
10104 XFS V5 stores UUID in metadata and compares them with superblock UUID.
10105 To allow changing of user-visible UUID it stores original value in new
10106 superblock field (meta_uuid) and sets incompatible flag to indicate that
10107 new field must be used to verify metadata. Our driver currently does not
10108 check metadata UUID so simply accept such filesystem.
10110 Reported-By: Marcos Mello <marcosfrm@outlook.com>
10111 Reviewd by Jan Kara <jack@suse.cz>
10113 2016-05-03 Andrei Borzenkov <arvidjaar@gmail.com>
10115 net: translate pxe prefix to tftp when checking for self-load
10116 Commit ba218c1 missed legacy pxe and pxe: prefixes which are
10117 translated to tftp, so comparison failed.
10119 2016-04-30 Andrei Borzenkov <arvidjaar@gmail.com>
10121 net: reset net->stall in grub_net_seek_real
10122 If we open new connection, we need to reset stall indication, otherwise
10123 nothing will ever be polled (low level code rely on this field being
10124 zero when establishing connection).
10126 2016-04-30 Stefan Fritsch <sf@sfritsch.de>
10128 http: reset EOF indication in http_seek
10129 Otherwise next read will stop polling too early due to stale EOF
10130 indicator, returning incomplete data to caller.
10132 2016-04-24 Mike Gilbert <floppym@gentoo.org>
10134 build: Use AC_HEADER_MAJOR to find device macros
10135 Depending on the OS/libc, device macros are defined in different
10136 headers. This change ensures we include the right one.
10140 sys/sysmacros.h - glibc (Linux)
10142 glibc currently pulls sys/sysmacros.h into sys/types.h, but this may
10143 change in a future release.
10145 https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html
10147 2016-04-09 Michael Chang <mchang@suse.com>
10149 http: fix superfluous null line in range request header
10150 At least the apache sever is very unhappy with that extra null line and will
10151 take more than ten seconds in responding to each range request, which slows
10152 down a lot the entire http file transfer process or even time out.
10154 2016-03-22 Andrei Borzenkov <arvidjaar@gmail.com>
10156 configure: set -fno-pie together with -fno-PIE
10157 OpenBSD 5.9 apparently defaults to -fpie. We use -fno-PIE when appropriate
10158 already, but that is not enough - it does not turn off -fpie.
10160 Actually check for -fPIE is not precise enough. __PIE__ is set for both
10161 -fpie and -fPIE but with different values. As far as I can tell, both
10162 options were introduced at the same time, so both should always be supported.
10164 This fixes compilation on OpenBSD 5.9 which otherwise created insanely big
10165 lzma_decompress.img.
10167 Reported, suggested and tested by: Jiri B <jirib@devio.us>
10169 2016-03-20 Andrei Borzenkov <arvidjaar@gmail.com>
10171 bootp: check that interface is not NULL in configure_by_dhcp_ack
10172 grub_net_add_addr may fail with OOM and we use returned interface
10173 later without any checks.
10175 2016-03-19 Andrei Borzenkov <arvidjaar@gmail.com>
10177 bootp: fix memory leak in grub_cmd_dhcpopt
10179 2016-03-15 Aaron Luft <aluft@lifesize.com>
10181 Remove the variable oldname which is attempting to free stack space.
10182 Historically this variable hold previous value of filename that
10183 had to be freed if allocated previously. Currently this branch
10184 is entered only if filename was not allocated previously so it
10185 became redundant. It did not cause real problems because grub_free
10186 was not called, but code is confusing and causes compilation error
10189 2016-03-13 Andrei Borzenkov <arvidjaar@gmail.com>
10191 Makefile.util.def: add $LIBINTL to grub-macbless flags
10192 Fixes compilation on OpenBSD 5.9.
10194 Reported by Jiri B <jirib@devio.us>
10196 2016-03-11 Robert Marshall <rmarshall@redhat.com>
10198 Failed config now returns exit code (#1252311)
10199 Grub would notify the user if the new config was invalid, however, it
10200 did not exit properly with exit code 1. Added the proper exit code.
10202 Resolves: rhbz#1252311
10204 2016-03-11 Michael Chang <mchang@suse.com>
10206 xen_file: Fix invalid payload size
10208 2016-03-10 Vladimir Serbinenko <phcoder@gmail.com>
10210 multiboot2: Remove useless GRUB_PACKED
10211 Reported by: Daniel Kiper
10213 2016-03-06 Andrei Borzenkov <arvidjaar@gmail.com>
10215 20_linux_xen: fix test for GRUB_DEVICE
10216 Same fix as in 082bc9f.
10218 2016-03-06 Mike Gilbert <floppym@gentoo.org>
10220 10_linux: Fix grouping of tests for GRUB_DEVICE
10221 Commit 7290bb562 causes GRUB_DISABLE_LINUX_UUID to be ignored due to
10222 mixing of || and && operators. Add some parens to help with that.
10224 2016-02-28 Andrei Borzenkov <arvidjaar@gmail.com>
10228 2016-02-28 Vladimir Serbinenko <phcoder@gmail.com>
10232 grub_arch_sync_dma_caches: Accept volatile address
10234 2016-02-27 Leif Lindholm <leif.lindholm@linaro.org>
10236 efidisk: Respect block_io_protocol buffer alignment
10237 Returned from the OpenProtocol operation, the grub_efi_block_io_media
10238 structure contains the io_align field, specifying the minimum alignment
10239 required for buffers used in any data transfers with the device.
10241 Make grub_efidisk_readwrite() allocate a temporary buffer, aligned to
10242 this boundary, if the buffer passed to it does not already meet the
10245 Also sanity check the io_align field in grub_efidisk_open() for
10246 power-of-two-ness and bail if invalid.
10248 2016-02-27 Vladimir Serbinenko <phcoder@gmail.com>
10250 usbtrans: Fix memory coherence and use-after-free.
10252 ehci: Fix memory coherence
10253 This is a no-op on x86 but necessarry on ARM and may be necessarry on MIPS.
10255 arm-uboot: Make self-relocatable to allow loading at any address
10257 Allow _start == 0 with relocatable images
10259 2016-02-27 Vladimir Serbinenko <phcoder@gmail.com>
10261 Provide __bss_start and _end symbols in grub-mkimage.
10262 For this ensure that all bss sections are merged.
10264 We need this to correctly prelink non-PE relocatable images.
10266 2016-02-27 Vladimir Serbinenko <phcoder@gmail.com>
10268 Encapsulate image layout into a separate structure.
10269 Currently we pass around a lot of pointer. Instead put all relevant data
10270 into one structure.
10272 mkimagexx: Split PE and generic part for relocations.
10273 As a preparation for U-Boot relocations, split emitting PE-relocations
10274 from parsing source ELF-relocations.
10276 mkimage.c: Split into separate files.
10277 util/grub-mkimagexx.c is included in a special way into mkimage.c.
10278 Interoperation between defines makes this very tricky. Instead
10279 just have a clean interface and compile util/grub-mkimage*.c separately
10282 bsd: Ensure that kernel is loaded before loading module.
10283 kernel_type may be set to the type of failed kernel. This patching-up is
10284 easier than to reflow kernel loading routines.
10286 cat: Don't switch terminal mode when there is nothing to highlight.
10287 This just pollutes serial console.
10289 Use console rather than serial_efi0 on arm64-efi in tests
10291 2016-02-27 Andrei Borzenkov <arvidjaar@gmail.com>
10293 efidisk: fix misplaced parenthesis in b00e4c2
10295 2016-02-26 Andrei Borzenkov <arvidjaar@gmail.com>
10297 efidisk: prevent errors from diskfilter scan of removable drives
10298 Map EFI_NO_MEDIA to GRUB_ERR_OUT_OF_RANGE that is ignored by diskfilter. This
10299 actually matches pretty close (we obviously attempt to read outside of media)
10300 and avoids adding more error codes.
10302 This affects only internally initiated scans. If read/write from removable is
10303 explicitly requested, we still return an error and text explanation is more
10304 clear for user than generic error.
10306 Reported and tested by Andreas Loew <Andreas.Loew@gmx.net>
10308 2016-02-26 Vladimir Serbinenko <phcoder@gmail.com>
10310 Regenerate checksums
10312 Makefile: Don't delete default_payload.elf if it doesn't exist.
10314 2016-02-25 Josef Bacik <jbacik@fb.com>
10316 net: fix ipv6 routing
10317 ipv6 routing in grub2 is broken, we cannot talk to anything outside our local
10318 network or anything that doesn't route in our global namespace. This patch
10319 fixes this by doing a couple of things
10321 1) Read the router information off of the router advertisement. If we have a
10322 router lifetime we need to take the source address and create a route from it.
10324 2) Changes the routing stuff slightly to allow you to specify a gateway _and_ an
10325 interface. Since the router advertisements come in on the link local address we
10326 need to associate it with the global address on the card. So when we are
10327 processing the router advertisement, either use the SLAAC interface we create
10328 and add the route to that interface, or loop through the global addresses we
10329 currently have on our interface and associate it with one of those addresses.
10330 We need to have a special case here for the default route so that it gets used,
10331 we do this by setting the masksize to 0 to mean it encompasses all networks.
10332 The routing code will automatically select the best route so if there is a
10333 closer match we will use that.
10335 With this patch I can now talk to ipv6 addresses outside of my local network.
10338 2016-02-24 Vladimir Serbinenko <phcoder@gmail.com>
10340 ieee1275: fix signed comparison
10342 2016-02-23 Andrei Borzenkov <arvidjaar@gmail.com>
10344 search: actually skip floppy with --no-floppy
10345 grub_device_iterate() ignores device when iterator returns 1, not 0.
10347 Reported by Carlos E. R. <robin.listas@telefonica.net>
10349 2016-02-23 Andrei Borzenkov <arvidjaar@gmail.com>
10351 multiboot2: zero reserved field in memory map
10352 Documentation says, bootloader should set reserved field to zero.
10354 Reported by Wink Saville <wink@saville.com>
10356 2016-02-22 Vladimir Serbinenko <phcoder@gmail.com>
10358 Improve EHCI logging
10359 Add dprintf's on common error paths and remove some entries which are too
10362 usb_keyboard: Remove useless include
10363 This prevents non-PCI machines from having USB.
10365 Refresh before abort
10366 This ensures that abort message is actually visible to the user.
10368 2016-02-22 Eric Snowberg <eric.snowberg@oracle.com>
10370 ieee1275: prevent buffer over-read
10371 Prevent buffer over-read in grub_machine_mmap_iterate. This was
10372 causing phys_base from being calculated properly. This then
10373 caused the wrong value to be placed in ramdisk_image within
10374 struct linux_hdrs. Which prevented the ramdisk from loading on
10377 Newer SPARC systems contain more than 8 available memory entries.
10379 For example on a T5-8 with 2TB of memory, the memory layout could
10383 reg 00000000 30000000 0000003f b0000000
10384 00000800 00000000 00000040 00000000
10385 00001000 00000000 00000040 00000000
10386 00001800 00000000 00000040 00000000
10387 00002000 00000000 00000040 00000000
10388 00002800 00000000 00000040 00000000
10389 00003000 00000000 00000040 00000000
10390 00003800 00000000 00000040 00000000
10391 available 00003800 00000000 0000003f ffcae000
10392 00003000 00000000 00000040 00000000
10393 00002800 00000000 00000040 00000000
10394 00002000 00000000 00000040 00000000
10395 00001800 00000000 00000040 00000000
10396 00001000 00000000 00000040 00000000
10397 00000800 00000000 00000040 00000000
10398 00000000 70000000 0000003f 70000000
10399 00000000 6eef8000 00000000 00002000
10400 00000000 30400000 00000000 3eaf6000
10403 2016-02-22 Thomas Huth <thuth@redhat.com>
10405 menu_entry: Disable cursor during update_screen()
10406 When running grub in a VGA console of a KVM pseries guest on PowerPC,
10407 you can see the cursor sweeping over the whole line when entering a
10408 character in editor mode. This is visible because grub always refreshes
10409 the whole line when entering a character in editor mode, and drawing
10410 characters is quite a slow operation with the firmware used for the
10411 powerpc pseries guests (SLOF).
10412 To avoid this ugliness, the cursor should be disabled when refreshing
10413 the screen contents during update_screen().
10415 2016-02-17 Vladimir Serbinenko <phcoder@gmail.com>
10417 default_payload.elf: Always rebuild and remove before build.
10418 It's difficult to know all dependencies. Since it's manual and cheap
10419 target anyway, simply always rebuild it.
10421 default_payload.elf: Include password_pbkdf2.
10422 Withoout this module we may end up in a system where no password is
10425 default_payload.elf: Add modules from $(EXTRA_PAYLOAD_MODULES).
10426 This allows coreboot building system to add extra modules depending
10429 mm: Avoid integer overflow.
10431 Remove -Wno-maybe-uninitialized as it may not be present.
10433 Fix warnings when compiling with -O3
10435 2016-02-14 Vladimir Serbinenko <phcoder@gmail.com>
10437 Add wbinvd around bios call.
10438 Via C3 has problems with cache coherency when transitioning between the modes,
10439 so flush it around bios calls.
10441 2016-02-12 Eric Snowberg <eric.snowberg@oracle.com>
10443 OBP available region contains grub. Start at grub_phys_end.
10444 This prevents a problem where grub was being overwritten since
10445 grub_phys_start does not start at a zero offset within the memory
10448 2016-02-12 Andreas Freimuth <andreas_freimuth@web.de>
10450 Add Thinkpad T410s button cmos address.
10452 2016-02-12 Vladimir Serbinenko <phcoder@gmail.com>
10454 TODO: Remove obsolete link
10456 2016-02-12 Toomas Soome <tsoome@me.com>
10458 lz4: Fix pointer overflow
10460 2016-02-12 Vladimir Serbinenko <phcoder@gmail.com>
10462 grub-shell: Update 32-bit OVMF binary name.
10464 2016-02-12 Daniel Kiper <daniel.kiper@oracle.com>
10466 relocator: Fix integer underflow.
10468 2016-02-12 Vladimir Serbinenko <phcoder@gmail.com>
10470 Change -v to -V for version of shell utils.
10472 xnu: Add new kernel path to autoconfig.
10474 arm64: Use cpu timer for timekeeping.
10476 powerpc: Trim header in tests.
10478 default_payload: Include syslinuxcfg, all filesystems and xnu.
10480 xnu: Supply random seed.
10481 Now we're able to load kernels up to El Capitan.
10485 yylex: use grub_fatal for exit.
10486 lexer calls yylex_fatal on fatal internal errors. yylex_fatal itself is
10487 declared as noreturn and calls exit. Returning from noreturn function has
10488 unpredictable consequences.
10490 printf: Fix and test %% behaviour in presence of subsequenbt args.
10492 Split pmtimer wait and tsc measurement from pmtimer tsc calibration.
10494 Make grub_cpu_is_tsc_supported generally available.
10496 Make grub_acpi_find_fadt accessible generically
10498 Make unaligned types public.
10499 This simplifies code which has to handle those types.
10501 Fix emu compilation error on arm.
10503 2016-02-11 Vladimir Serbinenko <phcoder@gmail.com>
10505 xnu: Include relocated EFI in heap size.
10507 xnu: supply ramsize to the kernel.
10508 Without this info recent kernels crash as they allocate no heap.
10510 2016-02-03 Andrei Borzenkov <arvidjaar@gmail.com>
10512 support modules without symbol table
10513 all_video module does not have any code or data and exists solely for
10514 .moddeps section to pull in dependencies. This makes all symbols unneeded.
10516 While in current binutils (last released version as of this commit is 2.26)
10517 ``strip --strip-unneeded'' unintentionally adds section symbols for each
10518 existing section, this behavior was considered a bug and changed in commit
10519 14f2c699ddca1e2f706342dffc59a6c7e23e844c to completely strip symbol table
10522 Older binutils (verified with 2.17) and some other toolchains (at least
10523 elftoolchain r3223M), both used in FreeBSD, remove symbol table in all_video
10526 Relax run-time check and do not return error for modules without symbol table.
10527 Add additional checks to module verifier to make sure such modules
10529 a) have non-empty .moddeps section. Without either externally visible symbols
10530 or .moddeps modules are completely useless and should not be built.
10532 b) do not have any relocations.
10536 v2: add run-time check for empty symbol table if relocations are present as
10537 suggested by Vladimir.
10539 2016-02-01 Andrei Borzenkov <arvidjaar@gmail.com>
10541 10_linux: avoid multi-device root= kernel argument
10542 If root filesystem is multidev btrfs, do not attempt to pass all devices as
10543 kernel root= argument. This results in splitting command line in GRUB due to
10544 embedded newline and even if we managed to quote it, kernel does not know how
10545 to interpret it anyway. Multidev btrfs requires user space device scanning,
10546 so passing single device would not work too.
10548 This still respects user settings GRUB_DISABLE_LINUX_UUID. Not sure what we
10549 should do in this case.
10553 2016-01-22 Vladimir Serbinenko <phcoder@gmail.com>
10555 Error out if mtools invocation fails.
10557 arm64: Add support for relocations needed for linaro gcc
10559 efiemu: Fix compilation failure
10563 2016-01-22 Robert Elliott <elliott@hpe.com>
10565 efiemu: Handle persistent RAM and unknown possible future additions.
10567 2016-01-22 Vladimir Serbinenko <phcoder@gmail.com>
10569 Document expr1 expr2 syntax for test command
10571 2016-01-22 Michael Chang <mchang@suse.com>
10573 Restore terminal settings on grub-emu exit.
10575 2016-01-22 Vladimir Serbinenko <phcoder@gmail.com>
10577 xen_boot: Remove obsolete module type distinctions.
10579 arm: Ignore qemu clock bug
10581 i386-ieee1275: Increase maximum heap size to accomodate highres graphi tests
10583 2016-01-20 Colin Watson <cjwatson@ubuntu.com>
10585 Remove pragmas related to -Wunreachable-code
10586 -Wunreachable-code has been a no-op since GCC 4.5; GRUB hasn't been
10587 compiled with it since 2012; and GCC 6 produces "error:
10588 '-Wunreachable-code' is not an option that controls warnings" for these.
10590 Fixes Debian bug #812047.
10592 2016-01-16 Colin Watson <cjwatson@ubuntu.com>
10594 loader/bsd: Fix signed/unsigned comparison
10596 ahci, ehci: Fix typos
10598 2016-01-16 Andrei Borzenkov <arvidjaar@gmail.com>
10600 grub-probe: fix memory leak
10601 Found by: Coverity scan.
10604 2016-01-16 Andrei Borzenkov <arvidjaar@gmail.com>
10606 tftp: fix memory leaks in open
10607 If protocol open fails, file is immediately freed, so data was leaked.
10609 Found by: Coverity scan.
10612 2016-01-16 Andrei Borzenkov <arvidjaar@gmail.com>
10614 tcp: fix memory leaks
10615 Found by: Coverity scan.
10618 net: fix memory leaks
10619 Found by: Coverity scan.
10622 legacycfg: fix memory leaks and add NULL check
10623 Memory leaks found by Coverity scan.
10626 2016-01-15 Andrei Borzenkov <arvidjaar@gmail.com>
10628 loader: Unintended sign extension
10629 CID: 96707, 96699, 96693, 96691, 96711, 96709, 96708, 96703, 96702,
10630 96700, 96698, 96696, 96695, 96692, 96710, 96705
10632 2016-01-12 Andrei Borzenkov <arvidjaar@gmail.com>
10634 script: fix memory leak
10635 Found by: Coverity scan.
10638 normal: fix memory leak
10639 Found by: Coverity scan.
10640 CID: 96641, 96670, 96667
10642 xnu: fix memory leak
10643 Found by: Coverity scan.
10646 truecrypt: fix memory leak
10647 Found by: Coverity scan.
10650 gfxmenu: fix memory leak
10651 Found by: Coverity scan.
10654 efiemu: fix memory leak
10655 Found by: Coverity scan.
10658 efidisk: fix memory leak
10659 Found by: Coverity scan.
10662 verify: fix memory leak
10663 Found by: Coverity scan.
10666 password_pbkdf2: fix memory leak
10667 Found by: Coverity scan.
10670 parttool: fix memory leak
10671 Found by: Coverity scan.
10674 2016-01-12 Andrei Borzenkov <arvidjaar@gmail.com>
10676 nativedisk: fix memory leak
10677 Based on Coverity scan.
10680 Extended to also cover other error return places.
10682 2016-01-12 Andrei Borzenkov <arvidjaar@gmail.com>
10684 acpi: fix memory leak
10685 Found by: Coverity scan.
10688 2016-01-10 Andrei Borzenkov <arvidjaar@gmail.com>
10690 grub-install: include ehci in list of native modules
10691 This matches behavior of "nativedisk" command.
10693 Reported and tested by Smith Henry <sh37092@gmail.com>
10695 2016-01-10 Andrei Borzenkov <arvidjaar@gmail.com>
10697 grub-mkimage: remove redundant NULL check
10698 Found by: Coverity scan.
10701 2016-01-10 Andrei Borzenkov <arvidjaar@gmail.com>
10703 net: remove dead and redundant code
10704 server cannot be NULL at this point (we return error earlier if it is).
10705 Also structure is zalloc'ed, so no need to explicitly initialize
10708 Found by: Coverity scan.
10711 2016-01-10 Andrei Borzenkov <arvidjaar@gmail.com>
10713 hostdisk: fix device detection
10714 Condition was apparently reversed so GRUB assumed all devices were
10715 files. This later made it skip BLKFLSBUF ioctl on Linux which caused
10716 various page cache coherency issues. Observed were
10718 - failure to validate blocklist install (read content did not match
10721 - failure to detect Linux MD on disk after online hot addition
10722 (GRUB got stale superblock)
10726 2016-01-09 Andrei Borzenkov <arvidjaar@gmail.com>
10728 setup: fix NULL pointer dereference
10729 Check return value of grub_guess_root_devices
10731 Found by: Coverity scan.
10734 2016-01-09 Andrei Borzenkov <arvidjaar@gmail.com>
10736 mkimage: fix unintended sign extension
10737 Found by: Coverity scan.
10740 2016-01-09 Andrei Borzenkov <arvidjaar@gmail.com>
10742 util/getroot: delete dead code
10743 is_part cannot be non-zero at this point.
10745 Found by: Coveruty scan.
10748 2016-01-09 Andrei Borzenkov <arvidjaar@gmail.com>
10750 loader/multiboot: fix unintended sign extension
10751 Found by: Coveruty scan.
10754 kern/elf: fix unintended sign extension
10755 Found by: Coverity scan.
10756 CID: 73729, 73735, 73758, 73760
10758 2016-01-09 Andrei Borzenkov <arvidjaar@gmail.com>
10760 xfs: fix possible inode corruption in directory scan
10761 grub_xfs_iterate_dir did not restore first character after inline
10762 name when match was found. Dependning on XFS format this character
10763 could be inode number and we could return to the same node later in
10764 find_file if processing cycled symlinks.
10768 2016-01-09 Andrei Borzenkov <arvidjaar@gmail.com>
10770 rescue_parser: restructure code to avoid Coverity false positive
10771 If line contains single word, line and argv[0] are aliases, so
10772 no NULL dereference is possible, but Coverity does not know it.
10773 Change code to avoid ambiguity and also remove redundant call to
10778 2016-01-09 Andrei Borzenkov <arvidjaar@gmail.com>
10780 grub-mklayout: check subscript bounds
10781 Found by: Coverity scan.
10784 grub-probe: fix memory leak
10785 Found by: Coverity scan.
10788 gfxmenu: fix memory leak
10789 Found by: Coverity scan.
10792 2016-01-09 Andrei Borzenkov <arvidjaar@gmail.com>
10794 util/setup: fix grub_util_path_list leak
10795 Add helper grub_util_free_path_list and use it where appropriate.
10797 Found by: Coverity scan.
10800 2016-01-09 Andrei Borzenkov <arvidjaar@gmail.com>
10802 setup: fix memory leak
10803 Found by: Coverity scan.
10806 efiemu: check return value of grub_efiemu_write_value
10807 Found by: Coverity scan.
10810 efiemu: change code to avoid Coverity false positive
10813 efiemu: fix unintended sign extension
10814 Found by: Coverity scan.
10817 hfs: fix memory leak
10818 Found by: Coverity scan.
10821 grub-module-verifier: fix unintended sign extension
10822 Found by: Coverity scan.
10823 CID: 156533, 156532
10825 2016-01-08 Vladimir Serbinenko <phcoder@gmail.com>
10827 Tests: Support arm-efi
10829 2016-01-07 Vladimir Serbinenko <phcoder@gmail.com>
10831 arm64/setjmp: Add missing move for arg1 == 0 case.
10833 grub-shell: Support arm64-efi
10835 2016-01-07 Mark Salter <msalter@redhat.com>
10837 arm-efi: Reduce timer event frequency by 10
10838 Timer event to keep grub msec counter was running at 1000HZ. This was too
10839 fast for UEFI timer driver and resulted in a 10x slowdown in grub time
10840 versus wallclock. Reduce the timer event frequency and increase tick
10841 increment accordingly to keep better time.
10843 2016-01-07 Vladimir Serbinenko <phcoder@gmail.com>
10845 x86_64-efi: Automatically add -bios OVMF.fd to qemu in tests.
10847 Allow GRUB_QEMU_OPTS to override machine.
10849 arm64: Disable tests that need native drivers.
10851 Disable NetBSD bootcheck on EFI until it supports ACPI on EFI.
10853 grub-shell: Use new cbfstool syntax.
10855 grub-shell: On i386-ieee1275 don't try to switch to console.
10856 console goes to serial as well, so this doesn't stop garbage from going
10857 to serial. But it creates garbage itself.
10859 hddboot_test: reenable on OVMF
10860 OVMF now supports booting from disks.
10862 iee1275/datetime: Fix off-by-1 error.
10864 2016-01-07 Vladimir Serbinenko <phcoder@gmail.com>
10866 Adjust bootcheck tests for multiboot/coreboot/qemu to match real support.
10867 coreboot has ACPI while 2 others don't. *BSD need ACPI and have trouble
10868 without it. Don't even attempt to boot *BSD on multiboot or qemu targets.
10870 On coreboot boot all *BSD except 32-bit NetBSD which apparently does some
10873 2016-01-05 Vladimir Serbinenko <phcoder@gmail.com>
10875 minixfs_test: Check if mkfs.minixfs supports -B option.
10877 Add memdisk support to grub-emu.
10878 Use it to add custom files, so that tests which need them work.
10880 Move file loading functions to grub-emu.
10881 So that we can use it in grub-emu as well as utils.
10883 Disable progress indicator in grub-shell.
10884 This disables progress indicator for tests. This in turn fixes test
10885 flakiness as they ended up timing-dependent.
10889 2016-01-02 Andrei Borzenkov <arvidjaar@gmail.com>
10891 acpihalt: add GRUB_ACPI_OPCODE_CREATE_DWORD_FIELD (0x8a)
10892 Fixes ACPI halt on ASUSTeK P8B75-V,
10893 Bios: American Megatrends v: 0414 date: 04/24/2012
10895 Reported-By: Goh Lip <g.lip@gmx.com>
10897 2016-01-02 Andrei Borzenkov <arvidjaar@gmail.com>
10899 acpihalt: fix GRUB_DSDT_TEST compilation
10901 2016-01-01 Andrei Borzenkov <arvidjaar@gmail.com>
10903 Add missing BUILD_EXEEXT
10905 2015-12-31 Vladimir Serbinenko <phcoder@gmail.com>
10907 configure.ac: Reorder efiemu check to after link format check.
10908 efiemu is supposed to be disabled when compiling through exe format.
10909 Unfortunately format was determined only after efiemu check. Reorder to fix the
10912 2015-12-31 Andrey Borzenkov <arvidjaar@gmail.com>
10914 remove temporary .bin files (kernel and modules)
10916 add dejavu built fonts to cleanfiles
10918 2015-12-31 Andrei Borzenkov <arvidjaar@gmail.com>
10920 Add grub-module-verifier files to EXTRA_DIST
10922 2015-12-31 Vladimir Serbinenko <phcoder@gmail.com>
10924 configure: Add -fno-unwind-tables if supported.
10925 Unwind tables are useless for us bt consume space if present. Ensure that they
10928 module-verifier: allow limited-range relocations on sparc64.
10929 clang as incomplete mcmodel=large support. As we don't currently need full
10930 mcmodel=large support for sparc64, relax those checks.
10932 Disable build-time module check on emu.
10933 On emu some checks can be laxer like check for relocation range. Additionally
10934 module loading in emu is rarely used. So skip this check rather than making
10935 it laxer for all platforms. In ideal we may want to have slightly different
10936 check for emu but for now this is good enough.
10938 configure: Fix grub_cv_cc_fno_unwind_tables check.
10939 Check tries -fno-dwarf2-cfi-asm but adds -fno-asynchronous-unwind-tables
10940 to TARGET_CFLAGS. Fix this.
10942 Add -mno-stack-arg-probe on mingw.
10943 This argument disables generation of calls to __chkstk_ms. Those calls are
10944 useless on GRUB as function is dummy. Yet they increase module size and
10945 use limited-range relocations which may not work under some memory layouts.
10946 We currently don't use such layouts on concerned platforms but lt's correct
10950 This section is generated by clang and is useful only for debugging.
10951 It contains exotic relocations, so strip them to avoid them interferring
10952 with module loading.
10954 module-verifier: Check range-limited relative relocations.
10955 Check that they point to the same module, so will end up in the same
10958 xen/relocator: Use local symbol to ensure that code is relocation-free.
10960 backtrace: Fix register call syntax
10962 Verify modules on build-time rather than failing in runtime.
10964 sparc64: Fix assembly to let compiler to fill in memory references.
10965 This fixes the use of not fully relocatable (they assume that variables are
10966 under 4G limit in virtual memory) references.
10968 2015-12-30 Andrey Borzenkov <arvidjaar@gmail.com>
10970 30_os-prober: derive --class from os-prober generated label
10971 Currently only Windows gets distinguished icons, everything else is displayed
10972 using the same generic one. Add additional --class based on os-prober returned
10973 label, which usually is expected to match primary distribution name.
10975 Also use it for Windows as well - chainloader prober may actually return
10976 different strings (Windows, MS-DOS, Windows9xME).
10978 2015-12-30 Vladimir Serbinenko <phcoder@gmail.com>
10980 backtrace: Remove assembly assumption that grub_backtrace_pointer is under 4G
10982 2015-12-30 Andrei Borzenkov <arvidjaar@gmail.com>
10984 menu: fix line count calculation for long lines
10985 It gave one extra screen line if length was exactly equal to screen
10988 Reported by Michael Chang.
10989 Also-By: Michael Chang <mchang@suse.com>
10991 2015-12-29 Vladimir Serbinenko <phcoder@gmail.com>
10993 grub-mkrescue: Delete temporary file
10994 Reported by: Thomas Schmitt
10996 grub-mount: Fix oath parsing.
10997 Brackets detection was copied from somewhere else and makes no sense in case
10998 of grub-mount and prevents user from accessing and files with ) in them.
11000 exfat: Fix stream extension flag parsing.
11002 2015-12-26 Andrei Borzenkov <arvidjaar@gmail.com>
11004 devmapper: check for valid device abstraction in get_grub_dev
11005 This was lost when code was refactored. Patch restores previous behavior.
11007 It is still not clear whether this is the right one. Due to the way we
11008 detect DM abstraction, partitions on DM are skipped, we fall through to
11009 generic detection which ends up in assuming parent device is BIOS disk.
11011 It is useful to install GRUB on VM disk from the host. But it also means
11012 that GRUB will mistakenly allow install on real system as well.
11014 For now let's fix regression; future behavior needs to be discussed.
11018 2015-12-19 Andrei Borzenkov <arvidjaar@gmail.com>
11020 windows: correct LBA in generated EFI HDD media paths
11021 GRUB keeps partition offset and size in units of 512B sectors. Media paths
11022 are defined in terms of LBA which are presumed to match HDD sector size.
11024 This is probably cosmetic (EFI requires that partition is searched by GUID)
11025 and still incorrect if GPT was created using different logical block size.
11026 But current code is obviously wrong and new has better chances to be correct.
11028 2015-12-17 Robert Elliott <elliott@hpe.com>
11030 lsefimmap: support persistent memory and other UEFI 2.5 features
11031 This should accompany
11032 76ce1de740 Translate UEFI persistent memory type
11034 1. Add a string for the EfiPersistentMemory type 14 that was
11037 2. Decode the memory attributes that were added in UEFI 2.5:
11038 * NV (non-volatile)
11039 * MORE_RELIABLE (higher reliable, e.g., mirrored memory in a system
11040 with partial memory mirroring)
11043 3. Use proper IEC binary units (KiB, MiB, etc.) for power-of-two
11044 values rather than misusing SI power-of-ten units (KB, MB, etc.)
11046 4. The lsmmap command only decodes memory ranges sizes up to GiB scale
11047 units. Persistent memory ranges will reach into the TiB scale.
11048 Since 64-bit size field supports TiB, PiB, and EiB, decode all of
11049 them for completeness.
11051 5. In the lsefimmap command, rewrite the print statements to
11053 * avoid a big nested if/else tree.
11055 For example: In the sixth entry below, the value of 309MB implies
11056 316416KB but is really reporting 316436KB.
11058 Widen the size column to 6 digits to accommodate typical cases.
11059 The worst case value would require 14 digits; if that happens,
11060 let the columns get out of sync.
11063 Type Physical start - end #Pages Size Attributes
11064 conv-mem 0000000000000000-0000000000092fff 00000093 588KB UC WC WT WB
11065 reserved 0000000000093000-0000000000093fff 00000001 4KB UC WC WT WB
11066 conv-mem 0000000000094000-000000000009ffff 0000000c 48KB UC WC WT WB
11067 conv-mem 0000000000100000-000000000fffffff 0000ff00 255MB UC WC WT WB
11068 BS-code 0000000010000000-0000000010048fff 00000049 292KB UC WC WT WB
11069 conv-mem 0000000010049000-000000002354dfff 00013505 309MB UC WC WT WB
11070 ldr-data 000000002354e000-000000003ecfffff 0001b7b2 439MB UC WC WT WB
11071 BS-data 000000003ed00000-000000003ed7ffff 00000080 512KB UC WC WT WB
11072 conv-mem 000000003ed80000-000000006af5ffff 0002c1e0 705MB UC WC WT WB
11073 reserved 000000006af60000-000000006b55ffff 00000600 6MB UC WC WT WB
11074 BS-data 000000006b560000-000000006b560fff 00000001 4KB UC WC WT WB
11075 RT-data 000000006b561000-000000006b5e1fff 00000081 516KB RT UC WC WT WB
11076 BS-data 000000006b5e2000-000000006ecfafff 00003719 55MB UC WC WT WB
11077 BS-code 000000006ecfb000-000000006ecfbfff 00000001 4KB UC WC WT WB
11078 conv-mem 000000006ecfc000-00000000711fafff 000024ff 36MB UC WC WT WB
11079 BS-data 00000000711fb000-000000007128dfff 00000093 588KB UC WC WT WB
11080 Unk 0d 0000000880000000-0000000e7fffffff 00600000 24GB UC WC WT WB NV
11081 reserved 0000001680000000-0000001c7fffffff 00600000 24GB UC WC WT WB NV
11084 Type Physical start - end #Pages Size Attributes
11085 conv-mem 0000000000000000-0000000000092fff 00000093 588KiB UC WC WT WB
11086 reserved 0000000000093000-0000000000093fff 00000001 4KiB UC WC WT WB
11087 conv-mem 0000000000094000-000000000009ffff 0000000c 48KiB UC WC WT WB
11088 conv-mem 0000000000100000-000000000fffffff 0000ff00 255MiB UC WC WT WB
11089 BS-code 0000000010000000-0000000010048fff 00000049 292KiB UC WC WT WB
11090 conv-mem 0000000010049000-000000002354dfff 00013505 316436KiB UC WC WT WB
11091 ldr-data 000000002354e000-000000003ecfffff 0001b7b2 450248KiB UC WC WT WB
11092 BS-data 000000003ed00000-000000003ed7ffff 00000080 512KiB UC WC WT WB
11093 conv-mem 000000003ed80000-000000006af5ffff 0002c1e0 722816KiB UC WC WT WB
11094 reserved 000000006af60000-000000006b55ffff 00000600 6MiB UC WC WT WB
11095 BS-data 000000006b560000-000000006b560fff 00000001 4KiB UC WC WT WB
11096 RT-data 000000006b561000-000000006b5e1fff 00000081 516KiB RT UC WC WT WB
11097 BS-data 000000006b5e2000-000000006ecfafff 00003719 56420KiB UC WC WT WB
11098 BS-code 000000006ecfb000-000000006ecfbfff 00000001 4KiB UC WC WT WB
11099 conv-mem 000000006ecfc000-0000000071222fff 00002527 38044KiB UC WC WT WB
11100 BS-data 0000000071223000-00000000712ddfff 000000bb 748KiB UC WC WT WB
11101 persist 0000000880000000-0000000e7fffffff 00600000 24GiB UC WC WT WB NV
11102 reserved 0000001680000000-0000001c7fffffff 00600000 24GiB UC WC WT WB NV
11104 2015-12-16 Andrei Borzenkov <arvidjaar@gmail.com>
11106 kernel: print and reset grub_errno after each embedded config line
11107 Otherwise it causes subsequent file open to fail, because grub_file_open
11108 misinterprets set grub_errno for grub_file_get_device_name failure.
11112 2015-12-16 Andrei Borzenkov <arvidjaar@gmail.com>
11114 Erase backspaced character in grub_username_get
11115 It probably does not work across linefeed, but hopefully user names are not
11116 that long (and nobody is using terminal that small).
11118 2015-12-16 Hector Marco-Gisbert <hecmargi@upv.es>
11120 Fix security issue when reading username and password
11121 This patch fixes two integer underflows at:
11122 * grub-core/lib/crypto.c
11123 * grub-core/normal/auth.c
11127 Also-By: Andrey Borzenkov <arvidjaar@gmail.com>
11129 2015-12-15 Andrei Borzenkov <arvidjaar@gmail.com>
11131 NEWS: more additions
11132 Also-By: Robert Elliott <elliott@hpe.com>
11134 2015-12-15 Robert Elliott <elliott@hpe.com>
11136 Translate UEFI persistent memory type
11138 * GRUB_EFI_PERSISTENT_MEMORY (UEFI memory map type 14) per UEFI 2.5
11139 * GRUB_MEMORY_PERSISTENT (E820 type 7) per ACPI 3.0
11140 * GRUB_MEMORY_PERSISTENT_LEGACY (E820 unofficial type 12) per ACPI 3.0
11142 and translate GRUB_EFI_PERSISTENT_MEMORY to GRUB_MEMORY_PERSISTENT in
11143 grub_efi_mmap_iterate().
11146 * adding the E820 names to lsmmap
11147 * handling the E820 types in make_efi_memtype()
11149 Suggested-by: Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com>
11150 Suggested-by: Andrei Borzenkov <arvidjaar@gmail.com>
11152 2015-12-14 Vladimir Serbinenko <phcoder@gmail.com>
11154 Document bootlocation discovery limitations and xen platform limitations
11156 2015-12-07 Josef Bacik <jbacik@fb.com>
11158 tcp: ack when we get an OOO/lost packet
11159 While adding tcp window scaling support I was finding that I'd get some packet
11160 loss or reordering when transferring from large distances and grub would just
11161 timeout. This is because we weren't ack'ing when we got our OOO packet, so the
11162 sender didn't know it needed to retransmit anything, so eventually it would fill
11163 the window and stop transmitting, and we'd time out. Fix this by ACK'ing when
11164 we don't find our next sequence numbered packet. With this fix I no longer time
11167 2015-12-01 Michael Chang <mchang@suse.com>
11169 i386: fix TSC calibration using PIT
11170 Condition was accidentally reversed, so PIT calibration always failed
11171 when PIT was present and always succeeded when PIT was missing, but in
11172 the latter case resulted in absurdly fast clock.
11174 Reported and tested by Vitaly Kuznetsov <vkuznets@redhat.com>
11176 2015-11-28 Andrei Borzenkov <arvidjaar@gmail.com>
11178 Do not include generated gnulib headers in tarball
11179 gnulib files are already handled by recursive make distdir invocation.
11180 Including all generated headers (after make completed) causes build
11181 failure if target system is different (different compile version etc).
11183 2015-11-27 Andrei Borzenkov <arvidjaar@gmail.com>
11185 Replace numbers with grub_memory_type_t enums
11187 2015-11-27 Andrei Borzenkov <arvidjaar@gmail.com>
11189 configure: fix macports flex version detection
11190 Macports add extra information after version itself:
11193 flex 2.5.35 Apple(flex-31)
11195 We require at least felx 2.5.35 so do not need to care about prehistoric
11196 "flex version n.n.n"; just use second field always.
11198 Reported by Peter Cheung <mcheung63@hotmail.com>
11200 2015-11-27 Vladimir Serbinenko <phcoder@gmail.com>
11202 tsc: Use alternative delay sources whenever appropriate.
11203 PIT isn't available on some of new hardware including Hyper-V. So
11204 use pmtimer for calibration. Moreover pmtimer calibration is faster, so
11205 use it on coreboor where booting time is important.
11207 Based on patch by Michael Chang.
11209 2015-11-26 Andrei Borzenkov <arvidjaar@gmail.com>
11211 efi: really mark memory of unknown type as reserved
11212 9be4c45dbe3c877d1f4856e99ee15133c6cd2261 added switch case between
11213 fall through cases, causing all memory regions of unknown type to be
11214 marked as available.
11216 Move default case into its own block and add explicit FALLTHROUGH
11219 Reported by Elliott, Robert (Persistent Memory) <elliott@hpe.com>
11221 2015-11-24 Josef Bacik <jbacik@fb.com>
11223 net: reset nb->data per dns record lookup loop
11224 We were resetting nb->data every time we tried a new server, but we need to do
11225 it every time we try for a different record, otherwise we don't end up falling
11226 back to the A record properly. Thanks,
11228 2015-11-18 Andrei Borzenkov <arvidjaar@gmail.com>
11230 unix: do not close stdin in grub_passwd_get
11231 This makes it impossible to read from stdin without controlling tty:
11233 10:/mnt # echo -e passwd\\npasswd | setsid ./grub-mkpasswd-pbkdf2
11235 Reenter password: ./grub-mkpasswd-pbkdf2: error: failure to read password.
11238 2015-11-17 Andrei Borzenkov <arvidjaar@gmail.com>
11240 lsefisystab: add missing comma after 7994077
11242 2015-11-14 Pavel Bludov <pbludov@gmail.com>
11244 Add some UUIDs found in the hardware
11246 2015-11-13 Konstantin Vlasov <kvlasov@odin.com>
11248 gfxterm: fix calculation of terminal-top and terminal-height
11249 They used screen width, not height.
11251 2015-11-12 Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
11253 ofdisk: add sas disks to the device list
11255 2015-11-12 Vladimir Serbinenko <phcoder@gmail.com>
11257 multiboot: Don't rely on particular ordering of options.
11259 multiboot_mbi: Fix handling of --quirk-bad-kludge.
11261 2015-11-12 Fu Wei <fu.wei@linaro.org>
11263 xen_boot: Remove useless file_name_index variable.
11265 Document ARM64 xen commands
11267 2015-11-11 Vladimir Serbinenko <phcoder@gmail.com>
11269 asm-tests/i386-pc: Check that near jumps are 2 bytes.
11270 We already check that jump over 300 bytes gap is 3 bytes in code16-mode.
11271 Some clang versions generate 3-byte opcode for short jumps which makes
11272 boot.img blow over 512-byte limit. Enforce -no-integrated-as in such cases
11274 2015-11-11 Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
11276 ofdisk: add a comment about vscsi method
11278 2015-11-09 Vladimir Serbinenko <phcoder@gmail.com>
11280 fdt.mod: Move license tag to the right file.
11282 2015-11-09 Fu Wei <fu.wei@linaro.org>
11284 fdt.mod: Add missing license tag.
11286 2015-11-09 Vladimir Serbinenko <phcoder@gmail.com>
11288 kern/elf: Ignore cast-align warnings
11290 2015-11-09 Vladimir Serbinenko <phcoder@gmail.com>
11292 cbfs: Fix corner case and compilation with recdent gcc
11293 Accept the header to touch the jump address at 0xfffffff0.
11295 Fix compilation for 64-bit EFI with recent GCC.
11297 2015-11-08 Vladimir Serbinenko <phcoder@gmail.com>
11299 fstester: Enforce LC_ALL=C
11301 Adapt build-system to use imported xen headers.
11303 Import xen headers directly into GRUB
11305 cbfs: Check for ptr range sanity.
11306 Triaged by Andrei and enhanced with suggestions by Aaron Durbin
11307 Also-By: Andrei Borzenkov <arvidjaar@gmail.com>
11309 Remove reliance C.UTF-8
11311 genmoddep.awk: Add a test that we have no circular dependencies
11313 Makefile.core.def: Break circular dependency on arm64.
11315 autogen: Use cp instead of ln -s.
11316 libgcrypt-grub shouldn't be modified directly anyway. With this patch
11317 tarball without contrib can be unpacked on FAT and stay usable for
11318 out-of-tree compile on full POSIX FS (compile on FAT not tested).
11320 2015-11-07 Andrei Borzenkov <arvidjaar@gmail.com>
11322 partmap_test: check that parted is available
11323 Skip test if parted is unavailable instead of returning false failure.
11325 2015-11-07 grub-devel@iam.tj <grub-devel@iam.tj>
11327 cryptodisk: teach grub_cryptodisk_insert() about partitions (bug #45889)
11328 It is not possible to configure encrypted containers on multiple partitions of
11329 the same disk; after the first one all subsequent fail with
11331 disk/cryptodisk.c:978: already mounted as crypto0
11333 Store partition offset in cryptomount descriptor to distinguish between them.
11335 2015-11-07 Andrey Borzenkov <arvidjaar@gmail.com>
11337 doc: document config_directory and config_file variables
11339 2015-11-07 Andrei Borzenkov <arvidjaar@gmail.com>
11341 unix/getroot: remove unused MAJOR definition
11342 We use major() everywhere, these definitions just add to confusion.
11344 Add comments to code for commit d313218
11346 2015-11-07 Andrei Borzenkov <arvidjaar@gmail.com>
11348 devmapper/getroot: use makedev instead of direct shift
11349 Fixes device detection with large number of devices.
11351 Reported by Tim Wallberg <twalberg@comcast.net>
11353 2015-11-06 Andrei Borzenkov <arvidjaar@gmail.com>
11355 mkimage: zero fill alignment space
11356 This did not cause real problem but is good for reproducible builds. I hit
11357 it with recent bootinfoscript that displays embedded config; I was puzzled
11358 by random garbage at the end.
11360 Prezero memory buffer used to assemble core.img. This makes individual
11361 memset redundant. Also ensure buffer is filled with zeroes in several other
11364 Also remove redundant zeroing code where we fill in the whole memory block
11367 2015-11-06 Vladimir Serbinenko <phcoder@gmail.com>
11369 configure.ac: Explicitly add -mno-sse3 on x86.
11371 README: Remove dead link to the wiki
11373 2015-10-29 Andrei Borzenkov <arvidjaar@gmail.com>
11375 NEWS: mention powerpc64le support
11377 2015-10-29 Ignat Korchagin <ignat>
11379 tcp: Fix uninited mac address when accepting connection.
11381 2015-10-29 Fu Wei <fu.wei@linaro.org>
11383 arm64: Add support for xen boot protocol.
11385 2015-10-29 Vladimir Serbinenko <phcoder@gmail.com>
11387 arm64: Move FDT functions to separate module
11389 2015-10-27 Andrei Borzenkov <arvidjaar@gmail.com>
11391 efi: fix warnings with recent GCC
11392 ../../grub-core/term/efi/console.c:128:32: error: suggest parentheses around '&&' within '||' [-Werror=parentheses]
11393 if (key.unicode_char >= 0x20 && key.unicode_char <= 0x7f
11395 2015-10-26 Eric Snowberg <eric.snowberg@oracle.com>
11397 ofdisk: Fix devpath freeing logic.
11399 2015-10-26 Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
11401 Implement cross-endian ELF load for powerpc
11403 2015-10-25 Peter Jones <pjones@redhat.com>
11405 Use EFI_SIMPLE_TEXT_INPUT_EX to support key combinations.
11407 2015-10-14 Andrei Borzenkov <arvidjaar@gmail.com>
11409 configure: find options to force endian on MIPS
11411 2015-10-14 Andrei Borzenkov <arvidjaar@gmail.com>
11413 configure: force o32 ABI on MIPS
11414 GRUB code expects O32 or N32. N32 is less tested than O32, so we prefer to
11415 compile with O32. Some systems (e.g. GNU Guix) default to using newer
11416 n64 or n32 ABI. Try to find suitable options to force o32.
11418 For GCC this is simply -mabi=32. While clang supports this option as well,
11419 o32 ABI is valid for MIPS target and n32/64 ABI are valid for MIPS64 target
11420 only, so use "-target mips/mipsel -mabi=32".
11422 Reported-By: Mark H Weaver <mhw@netris.org>
11423 Also-By: Mark H Weaver <mhw@netris.org>
11425 2015-10-12 Andrei Borzenkov <arvidjaar@gmail.com>
11427 net: avoid closing NULL socket in DNS lookup
11428 Refactor code so that we do not store NULL pointers in array
11429 of in-flight DNS servers.
11431 Reported-By: Josef Bacik <jbacik@fb.com>
11433 2015-10-11 Andrei Borzenkov <arvidjaar@gmail.com>
11435 install: --compress argument is not optional
11436 Fixes crash if argument is not specified. Also use `|' to separate choices
11437 in list of compression methods to align it with --core-compress.
11439 2015-10-11 Vladimir Serbinenko <phcoder@gmail.com>
11441 mips: Make setjmp code N32-compliant.
11443 mips: Make the assembly-code N32-compatible.
11444 There are no $t4 or $t5 in N32 but there are $a4 and $a5.
11446 2015-10-10 Andrei Borzenkov <arvidjaar@gmail.com>
11448 progress: avoid NULL dereference for net files
11449 From original patch by dann frazier <dann.frazier@canonical.com>:
11451 grub_net_fs_open() saves off a copy of the file structure it gets passed and
11452 uses it to create a bufio structure. It then overwrites the passed in file
11453 structure with this new bufio structure. Since file->name doesn't get set
11454 until we return back to grub_file_open(), it means that only the bufio
11455 structure gets a valid file->name. The "real" file's name is left
11456 uninitialized. This leads to a crash when the progress module hook is called
11459 grub_net_fs_open() already saved copy of file name as ->net->name, so change
11460 progress module to use it.
11462 Also, grub_file_open may leave file->name as NULL if grub_strdup fails. Check
11465 Also-By: dann frazier <dann.frazier@canonical.com>
11467 2015-10-10 Andrei Borzenkov <arvidjaar@gmail.com>
11469 file: ignore host disk in blocklist check
11470 It cannot work anyway because host disk cannot be read. This fixes hostfs access
11471 on native Windows build where filenames start with '\' or do not have initial
11472 separator at all (d:\foo).
11474 Issue was observed when running grub-fstest on Windows. On UNIX image name is
11475 canonicalized to always start with `/' so this was not noticed.
11477 This has side effect of allowing relative path names on host, but this already
11478 was the case with `ls' command, so it just extends it to all commands.
11480 Reported-By: Arch Stack <archstacker@gmail.com>
11481 Also-By: Arch Stack <archstacker@gmail.com>
11483 2015-10-09 Vladimir Serbinenko <phcoder@gmail.com>
11485 mips/dl: Handle addend in RELA entries.
11487 gfxmenu/model: Delete empty file.
11489 2015-10-09 Alexander Bluhm <bluhm@genua.de>
11491 ufs: Fix parameters to grub_memset.
11492 len = 0 made simply no sense. Fix parameters to be in line with read.
11494 2015-10-07 Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
11496 ofnet: Do not set SUFFIX for sun4v network devices
11497 sun4v vnet devices do not implement the support of duplex and speed
11498 instance attributes. An attempt to open such a device with
11499 the attributes will fail:
11501 ok select net:speed=auto,duplex=auto
11502 Unknown key 'speed'
11503 Unknown key 'duplex'
11504 Manual Configuration: Host IP, boot server and filename must be specified
11505 WARNING: /virtual-devices@100/channel-devices@200/network@0: Can't open OBP standard TFTP package
11510 Therefore, let's not set SUFFIX for such devices.
11512 2015-10-07 Eric Snowberg <eric.snowberg@oracle.com>
11514 sparc64 - use correct drive name within grub_util_sparc_setup
11515 Incorrect drive name was being passed into grub_util_sparc_setup,
11516 causing the grub-install to fail.
11518 2015-09-13 Andrei Borzenkov <arvidjaar@gmail.com>
11520 cryptodisk: strip parenthesis from backing device name
11521 Otherwise subsequent disk open fails.
11523 Reported-By: Klemens Nanni <contact@autoboot.org>
11525 2015-08-22 Felix Zielcke <fzielcke@z-51.de>
11527 disk/ldm, partmap/msdos.c: fix spelling error
11529 2015-08-13 Andrei Borzenkov <arvidjaar@gmail.com>
11531 net: do not try to load protocol module via itself
11532 Otherwise we get infinite recursion.
11536 2015-08-09 Josef Bacik <jbacik@fb.com>
11538 efinet: handle get_status() on buggy firmware properly
11539 The EFI spec indicates that get_status() should return the address of the buffer
11540 we passed into transmit to indicate the the buffer was transmitted. However we
11541 have boxes where the firmware returns some arbitrary address instead, which
11542 makes grub think that we've not sent anything. So since we have the SNP stuff
11543 opened in exclusive mode just assume any non-NULL txbuf means that our transmit
11544 occurred properly. This makes grub able to do its networking stuff properly on
11545 our broken firmware. Thanks,
11547 cc: Peter Jones <pjones@redhat.com>
11549 2015-08-09 Andrei Borzenkov <arvidjaar@gmail.com>
11551 linguas.sh: fix error when removing non-existing autogenerated files
11553 2015-07-28 Vladimir Serbinenko <phcoder@gmail.com>
11555 ahci: Ensure that bus mastering is set.
11556 Fixes ahci_test failing on several platforms.
11558 2015-07-27 Vladimir Serbinenko <phcoder@gmail.com>
11560 archelp: Never pass NULL as mtime.
11561 Moves complexity from fs code (NULL check) to common code (passing non-NULL).
11563 HFS: Convert to fshelp.
11564 HFS doesn't handle "." and ".." properly. Convert it to fshelp to reuse the
11567 FAT: Convert to fshelp.
11568 exFAT doesn't handle "." and ".." correctly, convert it to fshelp to
11569 reuse the same logic.
11571 BFS: Convert to fshelp.
11572 BFS doesn't handle ".." correctly, so convert it to fshelp to reuse the logic.
11574 fshelp: Add handling of "." and ".." and grub_fshelp_find_file_lookup.
11575 Recent tests have discovered that many of our filesystems have flawed
11576 handling of "." and "..". Rather than attempting to fix it in filesystems
11577 themselves, make the common code fshelp aware of "." and ".." and handle
11578 them in this layer. Add grub_fshelp_find_file_lookup for easy conversion
11579 of BFS, HFS and exFAT which have the same problem and don't use fshelp.
11581 Switch procfs to use archelp.
11582 This fixes handling of "." and "..".
11584 grub-install: Use a+ in fopen rather than r+.
11585 r+ does not create a file if none exists.
11587 Add transform_data as a variant of data with substitutions.
11588 This fixrs name mismatch for grub.chrp with
11589 transform_program_name='s,grub,grub2,g'
11591 2015-07-24 Ignat Korchagin <ignat@cloudflare.com>
11593 efi: fix GetVariable return status check in 81ca24a
11594 GetVariable should return EFI_BUFFER_TOO_SMALL if given buffer of size
11595 zero; commit incorrectly checked for EFI_SUCCESS.
11597 2015-07-24 Vladimir Serbinenko <phcoder@gmail.com>
11599 zfs_test: Skip dotdot in volume root test.
11600 Given special semantics of ZFS it's far from clear what the expected
11601 result is. Just skip it for now
11603 xfs_test: Test both crc and non-crc filesystems.
11605 xfs: Fix handling of symlink with crc-enabled filesystem.
11607 reiserfs: Fix handling of first entry in the directory.
11608 Fixes garbage being added to "." filename.
11610 2015-07-23 Ignat Korchagin <ignat@cloudflare.com>
11612 efi: fix memory leak in variable handling
11614 2015-07-23 Vladimir Serbinenko <phcoder@gmail.com>
11616 exclude.pot: Add missing blacklisted strings.
11618 archelp: Fix handling of dot and dotdot at the end of the name.
11619 Fixes cpio_test and tar_test.
11621 arm-emu: Add __aeabi_memcpy* and __aeabi_memclr* symbols.
11622 Fixes compilation with clang.
11624 2015-07-22 Vladimir Serbinenko <phcoder@gmail.com>
11626 fwstart: Fix loading of address of read_spd_fail.
11628 fwstart: Add missing argument to p2align.
11629 Resulting binary is unchanged as it happens we were already aligned
11632 2015-07-22 Vladimir Serbinenko <phcoder@gmail.com>
11634 fwstart: Replace blt with bltz.
11635 blt A, $zero, B and bltz A, B are equivalent but clang recognizes only
11638 Resulting binary is unchanged.
11640 2015-07-22 Vladimir Serbinenko <phcoder@gmail.com>
11642 Remove mips_attributes.
11643 mips_attributes was introduced to work around clang problems with
11644 -msoft-float. Those problems are now fixed and moreover .gnu_attributes
11645 itself is unportable and creates problem with clang.
11647 Revert "mips: Fix soft-float handling."
11649 This partially reverts commit 6a4ecd276ed39f66be0ad6ff0f8ff67598098605.
11651 2015-07-22 Vladimir Serbinenko <phcoder@gmail.com>
11653 ARM: provide __aeabi_memclr* and __aeabi_memcpy* symbols
11654 Fixes compilation with recent clang.
11656 diskfilter: Make name a const char to fix compilation error.
11658 dmraid_nvidia: Set a name to usable value to avoid null dereference.
11659 Reported by: Andrei Borzenkov
11661 configure.ac: Handle powerpc64le compiler
11662 Also-by: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
11664 2015-07-20 Bernhard Übelacker <bernhardu@vr-web.de>
11666 loader/linux: Make trailer initrd entry aligned again.
11667 Regression from commit:
11668 loader/linux: do not pad initrd with zeroes at the end
11669 a8c473288d3f0a5e17a903a5121dea1a695dda3b
11671 Wimboot fails since the change above because it expects the "trailer"
11672 initrd element on an aligned address.
11673 This issue shows only when newc_name is used and the last initrd
11674 entry has a not aligned size.
11676 2015-07-16 Vladimir Serbinenko <phcoder@gmail.com>
11678 XFS: Fix wrong alignment treatment.
11680 grub_ext2_read_block: Fix return type on error.
11682 2015-07-05 Andrei Borzenkov <arvidjaar@gmail.com>
11684 use TARGET_LDFLAGS in grub_PROG_OBJCOPY_ABSOLUTE
11685 That's what Makefile will use and it is required if unusual flags
11686 must be passed to linker (e.g. to build ppc32 code on ppc64le with clang).
11688 2015-06-26 Michael Chang <mchang@suse.com>
11690 Fix missing byte order conversion in get_btrfs_fs_prefix function
11691 Since btrfs on-disk format uses little-endian, the searched item types
11692 (ROOT_REF, INODE_REF) need converting the byte order in order to
11693 function properly on big-endian systems.
11695 2015-06-26 Andrei Borzenkov <arvidjaar@gmail.com>
11697 chainloader: fix resoource leak
11698 Found by: Coverity scan.
11701 loader/bsd: fix memory leak
11702 Found by: Coverity scan.
11705 2015-06-20 Andrei Borzenkov <arvidjaar@gmail.com>
11707 loader/bsd: free memory leaks
11708 Found by: Coverity scan.
11709 CID: 96671, 96658, 96653
11711 search_wrap: fix memory leak
11712 Found by: Coverity scan.
11715 password_pbkdf2: fix memory leak
11716 Found by: Coverity scan.
11719 normal: fix memory leak
11720 Found by: Coverity scan.
11723 efi/serial: fix memory leak
11724 Found by: Coverity scan.
11727 ohci: fix memory leak
11728 Found by: Coverity scan.
11731 loader/bsd: free memory leaks
11732 Found by: Coverity scan.
11735 multiboot: fix memory leak
11736 Found by: Coverity scan.
11739 normal: fix memory leak
11740 Found by: Coverity scan.
11743 loader/bsd: fix memory leak
11744 Found by: Coverity scan.
11747 reed_solomon: fix memory leak
11748 Found by: Coverity scan.
11751 usb: fix use after free
11752 Found by: Coverity scan.
11755 xnu: fix use after free
11756 Found by: Coverity scan.
11759 disk/scsi: fix use after free
11760 Found by: Coverity scan.
11763 efi/chainloader: fix use after free
11764 Found by: Coverity scan.
11767 search: fix use after free
11768 Found by: Coverity scan.
11771 NEWS: emu libusb support removed
11773 2015-06-19 Andrei Borzenkov <arvidjaar@gmail.com>
11775 grub-probe: fix memory leak in probe (ofpath)
11776 Found by: Coverity scan.
11779 2015-06-19 Andrei Borzenkov <arvidjaar@gmail.com>
11781 grub-probe: restructure code to make static analysis easier
11782 Current code in probe() could not be verified to not contain memory leaks.
11783 Restructure code and ensure grub_device_close is always called at the end of
11786 Calms down Coverity scan.
11789 2015-06-19 Andrei Borzenkov <arvidjaar@gmail.com>
11791 zfs: fix memory leak
11792 Found by: Coverity scan.
11795 xfs: silence Coverity overflow warning
11796 inode size cannot really overflow integer, but Coverity does not know it.
11800 Found by Coverity scan.
11803 unix/getroot: memory leak
11804 Found by Coverity scan.
11807 unix/relpath: memory leak
11808 Found by Coverity scan.
11811 2015-06-19 Andrei Borzenkov <arvidjaar@gmail.com>
11813 syslinux_parse: assorted issues found by Coverity
11814 1. Remove unneeded NULL check
11817 2. Do not allocate storage for initrd, copy it directly from input
11818 buffer. Avoids memory leak in failure path.
11821 3. Unchecked error return from print()
11824 2015-06-19 Andrei Borzenkov <arvidjaar@gmail.com>
11826 syslinux_parse: make print_escaped actually stop before `to'
11827 The only current user is mboot.c32 which unfortunately is not covered
11828 by regression tests.
11830 2015-06-18 Andrei Borzenkov <arvidjaar@gmail.com>
11832 fat: fix handling of "." and ".." directory entries
11833 Emulate dot and dotdot in root directory. For other directories do not
11834 add separator between name and extension for these two special entries.
11838 2015-06-18 Andrei Borzenkov <arvidjaar@gmail.com>
11840 tests: regression tests for "." and ".." directory entries
11842 2015-06-16 Andrei Borzenkov <arvidjaar@gmail.com>
11844 efinet: enable hardware filters when opening interface
11845 Exclusive open on SNP will close all existing protocol instances which
11846 may disable all receive filters on interface. Reinstall them after we
11847 opened protocol exclusively.
11849 Also follow UEFI specification recommendation and stop interfaces when
11852 Unexpected system errors, reboots and hangs can occur if an OS is loaded
11853 and the network devices are not Shutdown() and Stopped().
11855 Also by: Mark Salter <msalter@redhat.com>
11858 2015-06-16 Andrei Borzenkov <arvidjaar@gmail.com>
11860 NEWS: mention libgcc removal
11862 2015-06-15 Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
11864 Add flag for powerpc ieee1275 to avoid unneeded optimizations
11866 2015-06-12 Mark Salter <msalter@redhat.com>
11868 Fix exit to EFI firmware
11869 The current code for EFI grub_exit() calls grub_efi_fini() before
11870 returning to firmware. In the case of ARM, this leaves a timer
11871 event running which could lead to a firmware crash. This patch
11872 changes this so that grub_machine_fini() is called with a NORETURN
11873 flag. This allows machine-specific shutdown to happen as well
11874 as the shutdown done by grub_efi_fini().
11876 2015-06-12 Paul Menzel <paulepanter@users.sourceforge.net>
11878 disk/ahci.c: Use defines `GRUB_AHCI_HBA_PORT_CMD_SPIN_UP` and `GRUB_AHCI_HBA_PORT_CMD_POWER_ON`
11879 Instead of hard coding `2` and `4` use the macros defined already at the
11880 top of the file. As a consequence, wrap the now too long line.
11882 2015-06-12 Andrei Borzenkov <arvidjaar@gmail.com>
11884 NEWS: XFS v5 support
11886 2015-06-12 Jan Kara <jack@suse.cz>
11888 xfs: V5 filesystem format support
11889 Add support for new XFS on disk format. We have to handle optional
11890 filetype fields in directory entries, additional CRC, LSN, UUID entries
11891 in some structures, etc.
11893 xfs: Add helpers for inode size
11894 Add helpers to return size of XFS inode on disk and when loaded in
11897 2015-06-04 Toomas Soome <tsoome@me.com>
11899 multiboot_header_tag_module_align fix to confirm multiboot specification
11901 2015-06-02 Leif Lindholm <leif.lindholm@linaro.org>
11903 configure.ac: clean up arm64 soft-float handling
11904 Fix compilation with gcc 5.1 (avoid internal compiler error), by
11905 replacing explicit -march +nofp+nosimd options with -mgeneral-regs-only.
11907 This also enables the removal of some further conditional build flag
11910 2015-06-01 dann frazier <dann.frazier@canonical.com>
11912 arm64/setjmp: Add missing license macro
11913 Including the setjmp module in an arm64-efi image will cause it to
11914 immediately exit with an "incompatible license" error.
11916 The source file includes a GPLv3+ boilerplate, so fix this by declaring a
11917 GPLv3+ license using the GRUB_MOD_LICENSE macro.
11919 2015-05-31 Paul Menzel <paulepanter@users.sourceforge.net>
11921 disk/ahci.c: Add port number to port debug messages
11922 Currently, some messages cannot be mapped to the port they belong to as
11923 the port number is missing from the output. So add `port: n` to the
11926 2015-05-30 Andrei Borzenkov <arvidjaar@gmail.com>
11928 Clarify use of superusers variable and menu entry access
11929 superusers controls both CLI and editing. Also explicitly mention that
11930 empty superusers disables them.
11932 "Access to menuentry" is a bit vague - change to "execute menuentry"
11933 to make it obvious, what access is granted.
11935 2015-05-30 Paul Menzel <paulepanter@users.sourceforge.net>
11937 Correct spelling of *scheduled*
11938 Run the command below
11940 $ git grep -l schedulded | xargs sed -i 's/schedulded/scheduled/g'
11942 and revert the change in `ChangeLog-2015`.
11944 Including "miscellaneous" spelling fix noted by richardvoigt@gmail.com
11946 2015-05-30 Toomas Soome <tsoome@me.com>
11948 zfs extensible_dataset and large_blocks feature support
11949 large blocks basically use extensible dataset feature, or to be exact,
11950 setting recordsize above 128k will trigger large_block feature to be
11951 enabled and storing such blocks is using feature extensible dataset. so
11952 the extensible dataset is prerequisite.
11954 Changes implement read support extensible dataset… instead of fixed DMU
11955 types they dont specify type, making it possible to use fat zap objects
11958 2015-05-27 Vladimir Serbinenko <phcoder@gmail.com>
11960 multiboot1: never place modules in low memory.
11961 While in theory permitted by the spec, modules rarely fit in low memory
11962 anyway and not every kernel is able to handle modules in low memory anyway.
11963 At least VMWare is known not to be able to handle modules at arbitrary
11966 2015-05-24 Paul Menzel <paulepanter@users.sourceforge.net>
11968 disk/ahci: Use defines `GRUB_ATA_STATUS_BUSY` and `GRUB_ATA_STATUS_DRQ`
11969 Instead of hard coding `0x88` use the macros defined in `disk/ata.h`.
11971 2015-05-19 Paul Menzel <paulepanter@users.sourceforge.net>
11973 cb_timestamps.c: Add new time stamp descriptions
11974 Add the descriptions of the “core”, that means no vendorcode or payload,
11975 coreboot time stamps added up to coreboot commit a7d92441 (timestamps:
11976 You can never have enough of them!) [1].
11978 Running `coreboot_boottime` in the GRUB command line interface now shows
11979 descriptions for all time stamps again on the ASRock E350M1.
11981 [1] http://review.coreboot.org/9608
11983 2015-05-17 Andrei Borzenkov <arvidjaar@gmail.com>
11985 bootp: ignore gateway_ip (relay) field.
11988 The 'giaddr' field is rather poorly named. It exists to facilitate
11989 the transfer of BOOTREQUEST messages from a client, through BOOTP
11990 relay agents, to servers on different networks than the client.
11991 Similarly, it facilitates the delivery of BOOTREPLY messages from the
11992 servers, through BOOTP relay agents, back to the client. In no case
11993 does it represent a general IP router to be used by the client. A
11994 BOOTP client MUST set the 'giaddr' field to zero (0.0.0.0) in all
11995 BOOTREQUEST messages it generates.
11997 A BOOTP client MUST NOT interpret the 'giaddr' field of a BOOTREPLY
11998 message to be the IP address of an IP router. A BOOTP client SHOULD
11999 completely ignore the contents of the 'giaddr' field in BOOTREPLY
12002 Leave code ifdef'd out for the time being in case we see regression.
12004 Suggested by: Rink Springer <rink@rink.nu>
12007 2015-05-17 Andrei Borzenkov <arvidjaar@gmail.com>
12009 hostdisk: fix crash with NULL device.map
12010 grub-macbless calls grub_util_biosdisk_init with NULL device.map.
12012 2015-05-14 Andrei Borzenkov <arvidjaar@gmail.com>
12014 zfs: fix integer truncation in zap_lookup
12015 Size after shift could exceed 16 bits; use grub_unit32_t for result.
12017 Reported and tested by: Kostya Berger <bergerkos@yahoo.co.uk>
12020 2015-05-13 Andrei Borzenkov <arvidjaar@gmail.com>
12022 remove extra newlines in grub_util_* strings
12023 grub_util_{info,warn,error} already add trailing newlines, so remove
12024 them from format strings. Also trailing full stops are already added.
12026 2015-05-12 Jan Kara <jack@suse.cz>
12028 xfs: Convert inode numbers to cpu endianity immediately after reading
12029 Currently XFS driver converted inode numbers to native endianity only
12030 when using them to compute inode position. Although this works, it is
12031 somewhat confusing. So convert inode numbers when reading them from disk
12032 structures as every other field.
12034 2015-05-11 Jan Kara <jack@suse.cz>
12036 xfs: Fix termination loop for directory iteration
12037 Directory iteration used wrong position (sizeof wrong structure) for
12038 termination of iteration inside a directory block. Luckily the position
12039 ended up being wrong by just 1 byte and directory entries are larger so
12040 things worked out fine in practice. But fix the problem anyway.
12042 2015-05-08 Andrei Borzenkov <arvidjaar@gmail.com>
12044 acpi: do not skip BIOS scan if EBDA length is zero
12045 EBDA layout is not standardized so we cannot assume first two bytes
12046 are length. Neither is it required by ACPI standard. HP 8710W is known
12047 to contain zeroes here.
12051 2015-05-07 Andrei Borzenkov <arvidjaar@gmail.com>
12053 Add asm-tests to tarball
12055 2015-05-07 Vladimir Serbinenko <phcoder@gmail.com>
12057 util/grub-mkrescue: Fix compilation
12059 2015-05-07 Andrei Borzenkov <arvidjaar@gmail.com>
12061 efinet: open Simple Network Protocol exclusively
12062 EDK2 network stack is based on Managed Network Protocol which is layered
12063 on top of Simple Management Protocol and does background polling. This
12064 polling races with grub for received (and probably trasmitted) packets
12065 which causes either serious slowdown or complete failure to load files.
12067 Open SNP device exclusively. This destroys all child MNP instances and
12068 stops background polling.
12070 Exclusive open cannot be done when enumerating cards, as it would destroy
12071 PXE information we need to autoconfigure interface; and it cannot be done
12072 during autoconfiguration as we need to do it for non-PXE boot as well. So
12073 move SNP open to card ->open method and add matching ->close to clean up.
12075 Based on patch from Mark Salter <msalter@redhat.com>
12077 Also-By: Mark Salter <msalter@redhat.com>
12080 2015-05-07 Andrei Borzenkov <arvidjaar@gmail.com>
12082 efinet: skip virtual IPv4 and IPv6 devices when enumerating cards
12083 EDK2 PXE driver creates two child devices - IPv4 and IPv6 - with
12084 bound SNP instance. This means we get three cards for every physical
12085 adapter when enumerating. Not only is this confusing, this may result
12086 in grub ignoring packets that come in via the "wrong" card.
12088 Example of device hierarchy is
12090 Ctrl[91] PciRoot(0x0)/Pci(0x3,0x0)
12091 Ctrl[95] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)
12092 Ctrl[B4] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)/IPv4(0.0.0.0)
12093 Ctrl[BC] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)
12095 Skip PXE created virtual devices when enumerating cards. Make sure to
12096 find real card when applying initial autoconfiguration during PXE boot,
12097 this information is associated with one of child devices.
12099 2015-05-07 Andrei Borzenkov <arvidjaar@gmail.com>
12101 efidisk: move device path helpers in core for efinet
12103 convert to, not from, CPU byte order in DNS receive function
12105 2015-05-07 Andrei Borzenkov <arvidjaar@gmail.com>
12107 loader/linux: do not pad initrd with zeroes at the end
12108 Syslinux memdisk is using initrd image and needs to know uncompressed
12109 size in advance. For gzip uncompressed size is at the end of compressed
12110 stream. Grub padded each input file to 4 bytes at the end, which means
12111 syslinux got wrong size.
12113 Linux initramfs loader apparently does not care about trailing alignment.
12114 So change code to align beginning of each file instead which atomatically
12115 gives us the correct size for single file.
12117 Reported-By: David Shaw <dshaw@jabberwocky.com>
12119 2015-05-07 Daniel Kiper <daniel.kiper@oracle.com>
12121 i386/relocator: Remove unused extern grub_relocator64_rip_addr
12123 2015-05-07 Vladimir Serbinenko <phcoder@gmail.com>
12125 grub-install-common: Increase buf size to 8192 as modinfo.sh is bigger.
12127 2015-05-07 Vladimir Serbinenko <phcoder@gmail.com>
12129 grub-mkrescue: Recognize -output as an alias of --output.
12130 This helps us to be in line with xorriso -as mkisofs.
12132 Suggested by: Thomas Schmitt
12134 2015-05-07 Vladimir Serbinenko <phcoder@gmail.com>
12136 linux.c: Ensure that initrd is page-aligned.
12138 Revert parts accidentally committed 2 commits ago.
12140 2015-05-07 Fu Wei <fu.wei@linaro.org>
12142 fdt.h: Add grub_fdt_set_reg64 macro
12144 arm64: Export useful functions from linux.c
12146 2015-05-04 Andrei Borzenkov <arvidjaar@gmail.com>
12148 Revert "efinet: memory leak on module removal"
12149 This reverts commits 47b2bee3ef0ea60fc3f5bfc37f3784e559385297
12150 and 8d3c4544ffdd0289a4b0bdeb0cdc6355f801a4b3. It is not safe
12151 to free allocated cards, dangling pointers main remain. Such
12152 cleanup requires more changes in net core.
12154 efinet: cannot free const char * pointer
12156 efinet: memory leak on module removal
12158 2015-05-03 Andrei Borzenkov <arvidjaar@gmail.com>
12160 zfs: add missing NULL check and fix incorrect buffer overwrite
12161 grub_memset should zero out padding after data end. It is not clear
12162 why it is needed at all - ZFS block is at least 512 bytes and power
12163 of two, so it is always multiple of 16 bytes. This grub_memset
12164 apparently never did anything.
12166 2015-05-03 Toomas Soome <tsoome@me.com>
12168 zfs: com.delphix:embedded_data feature support
12170 zfs: com.delphix:hole_birth feature support
12171 In the past birth was always zero for holes. This feature started
12172 to make use of birth for holes as well, so change code to test for
12173 valid DVA address instead.
12175 2015-04-29 Andrei Borzenkov <arvidjaar@gmail.com>
12177 grub-mkconfig: use $pkgdatadir in scripts
12178 Otherwise scripts will source wrong grub-mkconfig_lib.
12180 2015-04-24 Vladimir Serbinenko <phcoder@gmail.com>
12182 Remove -V in grub-mkrescue.c
12183 It clashhes with -V which is alias to -volid.
12185 2015-04-13 Toomas Soome <tsoome@me.com>
12187 getroot: include sys/mkdev.h for makedev
12188 Solaris (like) systems need to include sys/mkdev.h for makedev() function.
12190 2015-04-13 Toomas Soome <tsoome@me.com>
12192 core/partmap: rename 'sun' to avoid clash with predefined symbol
12193 the symbol “sun” is defined macro in solaris derived systems, from
12196 and therefore can not be used as name.
12198 2015-04-12 Paul Menzel <paulepanter@users.sourceforge.net>
12200 docs/grub.texi: Fix spelling of cbfstool
12202 2015-04-06 Andrei Borzenkov <arvidjaar@gmail.com>
12204 core: avoid NULL derefrence in grub_divmod64s
12205 It can be called with NULL for third argument. grub_divmod32* for
12206 now are called only from within wrappers, so skip check.
12208 Reported-By: Michael Zimmermann <sigmaepsilon92@gmail.com>
12210 2015-03-28 Andrei Borzenkov <arvidjaar@gmail.com>
12212 do not emit cryptomount without crypto UUID
12214 2015-03-28 Sarah Newman <srn@prgmr.com>
12216 grub-core/loader/i386/xen.c: Initialized initrd_ctx so we don't free a random pointer from the stack.
12218 2015-03-27 Andrei Borzenkov <arvidjaar@gmail.com>
12220 net: trivial grub_cpu_to_XX_compile_time cleanup
12222 2015-03-27 Lunar <lunar@torproject.org>
12224 syslinux: Support {vesa,}menu.c32.
12226 2015-03-27 Steve McIntyre <steve@einval.com>
12228 Recognize EFI platform even in case of mismatch between Linux and EFI.
12229 Some x86 systems might be capable of running a 64-bit Linux kernel but
12230 only use a 32-bit EFI (e.g. Intel Bay Trail systems). It's useful for
12231 grub-install to be able to recognise such systems, to set the default
12232 x86 platform correctly.
12234 To allow grub-install to know the size of the firmware rather than
12235 just the size of the kernel, there is now an extra EFI sysfs file to
12236 describe the underlying firmware. Read that if possible, otherwise
12237 fall back to the kernel type as before.
12239 2015-03-27 Michael Zimmermann <sigmaepsilon92@gmail.com>
12241 Add missing initializers to silence suprious warnings.
12243 2015-03-27 Leif Lindholm <leif.lindholm@linaro.org>
12246 Use the new thumb_get_instruction_word/thumb_set_instruction_word
12247 helpers throughout.
12249 Style cleanup (missing spaces).
12251 Move Thumb MOVW/MOVT handlers into Thumb relocation section of file.
12253 2015-03-27 Martin Wilck <martin.wilck@ts.fujitsu.com>
12255 efinet: Check for immediate completition.
12256 This both speeds GRUB up and workarounds unexpected EFI behaviour.
12258 2015-03-27 Vladimir Serbinenko <phcoder@gmail.com>
12260 Make Makefile.util.def independent of platform.
12262 2015-03-27 Daniel Kahn Gillmor <dkg@fifthhorseman.net>
12264 util/mkimage: Use stable timestamp when generating binaries.
12266 2015-03-27 Vladimir Serbinenko <phcoder@gmail.com>
12268 modinfo.sh.in: Add missing config variables.
12270 Makefile.core.def: Remove obsolete LDADD_KERNEL
12272 arp, icmp: Fix handling in case of oversized or invalid packets.
12273 This restrict ARP handling to MAC and IP addresses but in practice we need
12274 only this case anyway and other cases are very rar if exist at all. It makes
12275 code much simpler and less error-prone.
12277 2015-03-23 Colin Watson <cjwatson@ubuntu.com>
12279 hostfs: Drop unnecessary feature test macros
12280 _BSD_SOURCE was added to allow the use of DT_DIR, but that was removed
12281 in e768b77068a0b030a07576852bd0f121c9a077eb. While adding
12282 _DEFAULT_SOURCE as well works around problems with current glibc,
12283 neither is in fact needed nowadays.
12285 2015-03-20 Vladimir Serbinenko <phcoder@gmail.com>
12287 compiler-rt-emu: Add missing file.
12289 emunet: Fix init error checking.
12290 Otherwise emunet doesn't expose any cards.
12292 fddboot_test: Add -no-pad to xorriso.
12294 grub-mkrescue: pass all unrecognized options unchanged to xorriso.
12296 cacheinfo: Add missing license information.
12298 2015-03-19 Andrei Borzenkov <arvidjaar@gmail.com>
12300 grub-fs-tester: add LVM RAID1 support
12301 LVM miscalculates bitmap size with small extent, so start with 16K as
12302 for other RAID types.
12304 Until version 2.02.103 LVM counts metadata segments twice when checking
12305 available space, reduce segment count by one to account for this bug.
12307 2015-03-19 Andrei Borzenkov <arvidjaar@gmail.com>
12309 core: add LVM RAID1 support
12312 2015-03-16 Andrei Borzenkov <arvidjaar@gmail.com>
12314 grub-fs-tester: explicitly set segment type for LVM mirror
12315 LVM mirror defaults to RAID1 today and can be different on different
12316 systems as set in lvm.conf.
12318 2015-03-15 Andrei Borzenkov <arvidjaar@gmail.com>
12320 grub-fs-tester: better estimation of filesystem time for LVM/RAID
12321 Write activity with LVM/RAID can happen after filesystem is unmounted.
12322 In my testing modification time of loop files was 15 - 20 seconds
12323 after unmount. So use time as close to unmount as possible as
12326 2015-03-06 Vladimir Serbinenko <phcoder@gmail.com>
12328 hfsplus: Fix potential access to uninited memory on invalid FS
12330 2015-03-06 Jon McCune <jonmccune@google.com>
12332 autogen.sh: Allow overriding the python to be used by setting $PYTHON.
12333 Some installations have several python versions installed. Allow user
12334 to choose which one to use by setting $PYTHON.
12336 2015-03-05 Andrei Borzenkov <arvidjaar@gmail.com>
12338 update gnulib/argp-help.c to fix garbage in grub-mknetdir --help output
12339 argp_help attempts to translate empty string, which results in printing
12340 meta information about translation, like in
12342 bor@opensuse:~/build/grub> grub2-mknetdir --help
12343 Использование: grub2-mknetdir [ПАРАМЕТР…]
12344 Project-Id-Version: grub 2.02-pre2
12345 Report-Msgid-Bugs-To: bug-grub@gnu.org
12348 Update gnulib/argp-help.c to the current version which fixes this
12349 (commit b9bfe78424b871f5b92e5ee9e7d21ef951a6801d).
12351 2015-03-05 Andrey Borzenkov <arvidjaar@gmail.com>
12353 update m4/extern-inline.m4 to upstream version to fix compilation on FreeBSD
12354 In file included from util/grub-mkimage.c:54:0:
12355 ./grub-core/gnulib/argp.h:627:49: error: '__sbistype' is static but
12356 used in inline function '_option_is_short' which is not static
12357 [-Werror] cc1: all warnings being treated as errors gmake[2]: ***
12358 [util/grub_mkimage-grub-mkimage.o] Error 1
12360 Update m4/extern-inline.m4 to current upstream gnulib version that
12361 contains fix for this (commit b9bfe78424b871f5b92e5ee9e7d21ef951a6801d).
12363 Reported-By: Beeblebrox <zaphod@berentweb.com>
12365 2015-03-04 Vladimir Serbinenko <phcoder@gmail.com>
12367 syslinux_parse: Fix the case of unknown localboot.
12368 Reported by: Jordan Uggla
12370 configure.ac: Fix the name of pciaccess header.
12372 Fix canonicalize_file_name clash.
12373 canonicalize_file_name clashed with gnulib function. Additionally
12374 it was declared in 2 places: emu/misc.h and util/misc.h. Added
12375 grub_ prefix and removed second declaration.
12377 2015-03-03 Vladimir Serbinenko <phcoder@gmail.com>
12379 Remove emu libusb support.
12380 It's disabled by default and has been broken for a long time.
12381 As nobody is interested in fixing and maintaining it, remove it.
12383 configure.ac: Remove unused COND_clang
12385 Remove libgcc dependency.
12386 libgcc for boot environment isn't always present and compatible.
12387 libgcc is often absent if endianness or bit-size at boot is different
12389 libgcc may use optimised opcodes that aren't available on boot time.
12390 So instead of relying on libgcc shipped with the compiler, supply
12391 the functions in GRUB directly.
12392 Tests are present to ensure that those replacement functions behave the
12393 way compiler expects them to.
12395 types.h: Use __builtin_bswap* with clang.
12396 clang pretends to be GCC 4.2 but we use __builtin_bswap* only with GCC 4.3+.
12397 clang support __builtin_bswap*, so use it.
12399 configure.ac: Set $CPPFLAGS when checking for no_app_regs.
12400 Fixes compilation for sparc64 with clang.
12402 Don't continue to query block-size if disk doesn't have it.
12403 Stops poluting screen with a lot of "block-size: exception -21".
12405 2015-02-28 Andrei Borzenkov <arvidjaar@gmail.com>
12407 grub-probe: free temporary variable
12409 2015-02-28 Vladimir Serbinenko <phcoder@gmail.com>
12411 exclude.pot: Add new technical strings
12413 grub-probe: Mark a "[default=]" for translation.
12415 grub-shell: Add missing --locale-directory.
12416 Fixes the language tests is no make install was done.
12418 ntfs_test: Skip is setfattr is unavailable.
12420 2015-02-26 Vladimir Serbinenko <phcoder@gmail.com>
12422 emu/cache: Change declaration of __clear_cache to match builtin declaration.
12423 Fixes compile of arm64-emu.
12425 arm/dl: Fix handling of nonstandard relocation sizes
12427 gzio: Optimize by removing division.
12429 raid6: Optimize by removing division.
12431 dmraid_nvidia: Fix division by 0 and missing byte-swap.
12433 crypto: restrict cipher block size to power of 2.
12434 All current ciphers have blocks which are power of 2 and it's
12435 unlikely to change. Other block length would be tricky to handle anyway.
12436 This restriction allows avoiding extra divisions.
12438 jpeg: Optimise by replacing division with shifts.
12440 png: Optimize by avoiding divisions.
12442 Add missing lib/division.c
12444 fbblit: Optimize by replacing division with additions and shifts.
12446 bitmap_scale: Optimize by moving division out of the loop.
12448 minilzo: Skip parts tha we don't need.
12450 2015-02-23 Vladimir Serbinenko <phcoder@gmail.com>
12452 mips: Fix soft-float handling.
12453 Add -msoft-float alongside clang arguments to specify ABI.
12454 Specify ABI in asm files explicitly.
12455 This trigers asm warning due to gcc failing to propagate -msoft-float
12456 but it's tolerable.
12458 Add missing grub_ prefix in memcpy invocation
12460 Allow clang compilation for thumb with -mthumb-interwork.
12461 clang already uses -mthumb-interwork behaviour even thout it doesn't
12462 support the option.
12464 arm64: Fix compilation failure.
12465 Don't supply +nosimd to asm files.
12466 Otherwise +nosimd coming from flags forbids some of instructions
12467 used in cache_flush.
12469 Supply signed division to fix ARM compilation.
12470 Previously we supplied only unsigned divisions on platforms that need software
12472 Yet compiler may itself use a signed division. A typical example would be a
12473 difference between 2 pointers which involves division by object size.
12475 2015-02-22 Vladimir Serbinenko <phcoder@gmail.com>
12477 acpi: Fix unused function warning.
12479 configure.ac: Add ia64-specific way to disable floats.
12481 i386/tsc: Fix unused function warning on xen.
12483 2015-02-22 Vladimir Serbinenko <phcoder@gmail.com>
12485 Experimental support for clang for sparc64.
12486 Automatically discover command line options to make clang and
12487 gcc behave in same way.
12491 2015-02-22 Vladimir Serbinenko <phcoder@gmail.com>
12493 Discover which option provides soft-float on configure stage.
12494 Deals with clang needing other arguments to stop issuing floating
12495 instructions than gcc.
12497 2015-02-21 Vladimir Serbinenko <phcoder@gmail.com>
12499 mips: Switch to more portable .org
12500 Binary is unchanged.
12502 sparc64: Switch to more portable .org.
12503 Binaries are unchanged.
12505 kernel-8086: Switch to more portable .org.
12507 Relax requirements on asm for non-BIOS i386 platforms.
12508 These platforms don't have a hard limit on size of resulting code16
12509 code, so we don't care if assembly is bigger than necessarry.
12511 qemu: Switch to more portable .org
12512 Binary is checked identical.
12514 qemu: Fix GateA20 enabling.
12515 GateA20 code was inactive due to address error.
12517 qemu: Fix compilation
12519 Remove realmode.S from coreboot and qemu.
12520 It's not used there.
12522 Remove obsolete ADDR32 and DATA32 checks.
12524 i386: Remove needless ADDR32 prefixes when address is known and fixed.
12525 Shaves off 6 bytes in lzma_decompress.img.
12527 i386-pc/boot: Explicitly mark kernel_address[_high] as local.
12528 Otherwise apple asm might try to make accesses relocatable.
12530 Change dot assignmnet to more portable .org.
12531 Binary is unchanged (verified)
12533 i386: Move from explicit ADDR32/DATA32 prefixes to instruction suffixes.
12535 Binary is unchanged (verified).
12537 Test which flags make our asm compile.
12538 Previously we relied on assumption that clang always needs -no-integrated-as
12539 but it's not always true.
12541 INSTALL: clarify that clang support is experimental
12543 zfs/mzap_lookup: Fix argument types
12545 wildcard: Mark unused argument as such.
12547 ofdisk: Exclude floppies from scanning.
12548 It causes similar hang as CD on at least the qemu.
12550 configure: Add -msoft-float to CCASFLAGS
12551 Otherwise mismatch between API flags triggers linker failure
12553 mips/startup_raw: Use more portable .asciz
12555 Provide __aeabi_mem{cpy,set}
12556 Fixes ARM compilation
12558 div_test: Don't try to divide by zero
12560 INSTALL: Fix names of host flags to match actual behaviour
12562 Strip .MIPS.abiflags which causes compile failure
12564 2015-02-20 Vladimir Serbinenko <phcoder@gmail.com>
12566 configure: Move adding of include options to the very end to avoid subshell.
12568 configure: Add missing comma.
12570 2015-02-16 Vladimir Serbinenko <phcoder@gmail.com>
12572 ext2: Ignore INCOMPAT_MMP.
12573 It's not really incompatible as long as driver never writes to FS.
12575 ext2: Support META_BG.
12576 This fixes bug that system would become unbootable after ext*
12577 online resize if no resize_inode was created at ext* format time.
12579 2015-02-16 Andrei Borzenkov <arvidjaar@gmail.com>
12581 tests: remove hardcoded paths from syslinux_test
12582 abs_top_srcdir appeared in Autoconf 2.52f. Minimal grub requirement
12583 is 2.60 so we should be good here.
12585 build-sys: add syslinux test files to tarball
12587 2015-02-16 Vladimir Serbinenko <phcoder@gmail.com>
12589 Add test for syslinux converter
12591 2015-02-16 Vladimir Serbinenko <phcoder@gmail.com>
12593 Don't remove initrd= parameter.
12594 Based on simplified patch by Lunar.
12598 2015-02-16 Vladimir Serbinenko <phcoder@gmail.com>
12600 syslinux_parse: Always output comments even if no entries are found.
12602 2015-02-15 Andrei Borzenkov <arvidjaar@gmail.com>
12604 diskfilter_make_raid: more memory leaks in failure path
12606 2015-02-14 Vladimir Serbinenko <phcoder@gmail.com>
12608 disk/lvm: Use zalloc to ensure that segments are initialised to sane value.
12609 Reported by: EmanueL Czirai.
12611 2015-02-14 Daniel Kiper <daniel.kiper@oracle.com>
12613 multiboot2: Fix information request tag size calculation
12615 2015-02-14 Andrei Borzenkov <arvidjaar@gmail.com>
12617 diskfilter: fix double free of lv names for mdraid
12618 Avoid micro-optimization in grub_diskfilter_make_raid and make sure
12619 name and fullname are independent strings. This avoids need to special
12620 case it everywhere else.
12622 Also fix memory leak in failure case in grub_diskfilter_make_raid.
12626 2015-02-14 Andrei Borzenkov <arvidjaar@gmail.com>
12628 diskfilter: fix crash in validate_lv for mdraid arrays
12629 Commit 750f4bacd3262376ced3f837d8dc78f834ca233a put LV validation before
12630 actual vg assignment. Make grub_diskfilter_make_raid to assign ->vg as
12631 happens in other cases for consistency. Also clean up redundant code and add
12632 explicit NULL lv->vg check in validate_lv.
12634 Also fix segment validation in validate_lv; it became obvious when crash
12639 2015-02-12 Jiri Slaby <jslaby@suse.cz>
12641 util: mkimage, fix gcc5 build failure
12643 ../util/mkimage.c: In function 'grub_install_get_image_target':
12644 ../util/mkimage.c:954:5: error: loop exit may only be reached after undefined behavior [-Werror=aggressive-loop-optimizations]
12645 && j < ARRAY_SIZE (image_targets[i].names); j++)
12647 ../util/mkimage.c:953:39: note: possible undefined statement is here
12648 for (j = 0; image_targets[i].names[j]
12651 Well, let's move the index 'j' test before accesing the array to:
12652 1) make the loop obvious
12655 2015-02-03 Leif Lindholm <leif.lindholm@linaro.org>
12657 arm: implement additional relocations generated by gcc 4.9 at -O3
12658 GCC 4.9 also generates R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_ABS,
12659 as an alternative to ABS32.
12661 2015-01-30 Andrei Borzenkov <arvidjaar@gmail.com>
12663 setup: fix blocklist size calculation
12664 Found by: Coverity scan.
12666 grub-fstest: fix descriptor leak
12667 Found by: Coverity scan.
12669 2015-01-30 Andrei Borzenkov <arvidjaar@gmail.com>
12671 net/pxe: fix error condition
12672 Test return value of grub_netbuff_reserve(), buf itself cannot be
12675 Found by: Coverity scan.
12677 2015-01-30 Andrei Borzenkov <arvidjaar@gmail.com>
12679 grub-mkimage: fix potential NULL pointer dereference
12680 Move fatal check whether symtab_section is NULL before first reference.
12682 Found by: Coverity scan.
12684 2015-01-30 Andrei Borzenkov <arvidjaar@gmail.com>
12686 net/ip: check result of grub_netbuff_push
12687 Found by: Coverity scan.
12689 tests: add test command file tests
12690 This requires access to files in both host and grub image, so
12691 implementing as separate test unit instead of script test was
12694 test: consistently use TMPDIR and same name pattern for temp files
12696 test: fix previous commit - we need to return from subexpression
12697 ( ... ) was processed recursively, we need to return from it. Revert
12700 test: do not stop after first file test or closing bracket
12703 2015-01-28 Leif Lindholm <leif.lindholm@linaro.org>
12705 configure.ac: don't use -msoft-float for arm64
12706 aarch64 toolchains do not support the -msoft-float option added by
12707 commit 3661261f. Insted, for arm64 use -march=armv8-a+nofp+nosimd.
12709 Reported-by: Ryan Harkin <ryan.harkin@linaro.org>
12711 2015-01-28 Andrei Borzenkov <arvidjaar@gmail.com>
12713 script/execute.c: fix memory leak.
12714 Make sure to continue loop over array after failure to free
12717 Found by: Coverity scan.
12719 2015-01-28 Andrei Borzenkov <arvidjaar@gmail.com>
12721 syslinux_parse: fix memory leak.
12722 Found by: Coverity scan.
12724 2015-01-27 Andrei Borzenkov <arvidjaar@gmail.com>
12726 Change quotes to match overall style in NEWS
12728 loader/xnu: fix memory leak.
12729 Foound by: Coverity scan.
12731 util/grub-probe: fix memory leaks.
12732 Found by: Coverity scan.
12734 fs/hfsplus: fix memory leak.
12735 Found by: Coverity scan.
12737 fs/zfs/zfscrypt.c: fix indentation.
12739 fs/zfs/zfscrypt.c: fix memory leaks.
12740 Found by: Coverity scan.
12742 commands/parttool: fix memory leak.
12743 Found by: Coverity scan.
12745 fs/zfs/zfs.c: fix memory leak.
12746 Found by: Coverity scan.
12748 linux/ofpath: fix descriptor leak
12749 Found by: Coverity scan
12751 linux/hostdisk: use strncpy instead of strlcpy
12752 strlcpy is not available on Linux as part of standard libraries.
12753 It probably is not worth extra configure checks espicially as we
12754 need to handle missing function anyway.
12756 2015-01-27 Vladimir Serbinenko <phcoder@gmail.com>
12758 Document intentional fallthroughs.
12759 Found by: Coverity scan.
12761 linux/ofpath: Fix error handling.
12762 Found by: Coverity Scan.
12764 linux/hostdisk: Limit strcpy size to buffer size.
12765 Found by: Coverity scan.
12767 fs/zfscrypt: Add missing explicit cast.
12768 Found by: Coverity scan.
12770 fs/zfs: Fix error handling.
12771 Found by: Coverity Scan.
12773 2015-01-27 Vladimir Serbinenko <phcoder@gmail.com>
12775 fs/{cbfs,cpio}: Remove useless check if mode is NULL.
12776 Callers already ensure that it's not null.
12778 Found by: Coverity Scan.
12780 2015-01-27 Vladimir Serbinenko <phcoder@gmail.com>
12782 commands/acpi: Use ALIGN_UP rather than manual expression.
12783 Improves readability and hopefully automatic scanning.
12785 Found by: Coverity Scan.
12787 2015-01-26 Andrei Borzenkov <arvidjaar@gmail.com>
12789 util/setup: fix memory leak.
12790 Found by: Coverity scan.
12792 util/mkimage: fix memory leaks.
12793 Found by: Coverity scan.
12795 util/grub-mount: fix descriptor leak.
12796 Found by: Coverity scan.
12798 util/grub-mkstandalone: fix memory leak.
12799 Found by: Coverity scan.
12801 util/grub-install: rearrange code to avoid memory leak.
12802 Found by: Coverity scan.
12804 linux/getroot: fix memory leak.
12805 Found by: Coverity scan.
12807 util/install: fix memory leak.
12808 Found by: Coverity scan.
12810 util/setup: fix memory leak.
12811 Found by: Coverity scan.
12813 linux/ofpath: fix various memory leaks.
12814 Found by: Coverity scan.
12816 linux/getroot: fix descriptor leak.
12817 Found by: Coverity scan.
12819 2015-01-26 Vladimir Serbinenko <phcoder@gmail.com>
12821 util/misc.c: Check ftello return value.
12822 Found by: Coverity scan.
12824 grub-macbless: Fix resource leak.
12825 Found by: Coverity scan.
12827 grub-install: Fix memory leak.
12828 Found by: Coverity scan.
12830 grub-install-common: Fix sizeof usage.
12831 Found by: Coverity scan.
12833 util/getroot: Add missing grub_disk_close.
12834 Found by: Coverity scan.
12836 vbe: Fix incorrect register usage.
12837 Found by: Coverity scan.
12839 unix/password: Fix file descriptor leak.
12840 Found by: Coverity scan.
12842 linux/getroot: Fix error handling.
12843 Found by: Coverity scan.
12845 linux/blocklist: Fix memory leak.
12846 Found by: Coverity scan.
12848 devmapper/getroot: Fix memory leak.
12849 Found by: Coverity scan.
12851 normal/misc: Close device on all pathes.
12852 Found by: Coverity scan.
12854 normal/main: Fix error handling.
12855 Found by: Coverity scan.
12857 xnu: Add missing error check.
12858 Found by: Coveriy scan.
12860 plan9: Add missing grub_device_close.
12861 Found by: Coverity scan.
12863 multiboot: Simplify to avoid confusing assignment.
12864 Found by: Coverity scan.
12866 bsd: Add missing null-pointer check.
12867 Found by: Coverity scan.
12869 lib/syslinux_parse: Add missing error check.
12870 Found by: Coverity scan.
12872 lib/syslinux_parse: Fix memory leak.
12873 Found by: Coveriy scan.
12875 lib/syslinux_parse: Add missing alloc check.
12876 Found by: Coverity scan.
12878 i386/pc/mmap: Fix memset size.
12879 Found by: Coverity scan.
12881 gfxmenu/theme_loader: Add missing allos error check.
12882 Found by: Coverity scan.
12884 gfxmenu/icon_manager: Fix null pointer dereference.
12885 Found by: Coverity scan.
12887 fs/ufs: Add missing error check.
12888 Found by: Coverity scan.
12890 configure.ac: Always add -D_FILE_OFFSET_BITS=64.
12892 2015-01-25 Vladimir Serbinenko <phcoder@gmail.com>
12894 fs/sfs: Fix error check and add sanity check.
12895 Found by: Coverity scan.
12897 fs/reiserfs: Fix sector count overflow.
12898 Found by: Coverity scan.
12900 fs/ntfs: Add sizes sanity checks.
12901 Found by: Coverity scan.
12903 fs/ntfs: Add missing free.
12904 Found by: Coverity scan.
12906 2015-01-25 Vladimir Serbinenko <phcoder@gmail.com>
12908 fs/minix: Fix sector promotion to 64-bit.
12909 While on it make GRUB_MINIX_ZONE2SECT into function.
12911 Found by: Coverity scan
12913 2015-01-25 Vladimir Serbinenko <phcoder@gmail.com>
12915 grub_iso9660_read: Explicitly check read_node return value.
12916 Not really needed as grub_errno is already checked but is nicer.
12918 Found by: Coverity scan.
12920 2015-01-25 Andrei Borzenkov <arvidjaar@gmail.com>
12922 commands/fileXX: Fix remaining memory leak.
12923 Found by: Coverity Scan.
12925 2015-01-25 Vladimir Serbinenko <phcoder@gmail.com>
12927 fs/hfs: Add pointer sanity checks.
12928 Found by: Coverity scan.
12930 fs/hfs/hfs_open: Check that mount succeeded.
12931 Found by: Coverity scan.
12933 fs/fat: Fix codepath to properly free on error.
12934 Found by: Coverity scan.
12936 fs/cpio_common: Add a sanity check on namesize.
12937 Found by: Coverity scan.
12939 fs/cbfs: Add missing free.
12940 Found by: Coverity scan.
12942 2015-01-24 Vladimir Serbinenko <phcoder@gmail.com>
12944 font: Add missing free.
12945 Found by: Coverity Scan.
12947 biosdisk: Add missing cast.
12948 Found by: Coverity scan.
12950 disk/geli: Add missing free.
12951 Found by: Coverity scan.
12953 disk/geli: Add missing seek success check.
12954 Found by: Coverity scan.
12956 disk/diskfilter: Add missing lv presence check.
12957 Found by: Coverity scan.
12959 disk/cryptodisk: Add missing error check.
12960 Found by: Coverity scan.
12962 2015-01-24 Vladimir Serbinenko <phcoder@gmail.com>
12964 disk/ahci: Fix device_map_range argument.
12965 Argument is not used on x86, hence it's gone unnoticed.
12967 Found by: Coverity scan.
12969 2015-01-24 Vladimir Serbinenko <phcoder@gmail.com>
12971 disk/AFsplitter: check argument validity before doing any allocs.
12972 This avoids possible memory leaks.
12974 Found by: Coverity scan.
12976 2015-01-24 Vladimir Serbinenko <phcoder@gmail.com>
12978 commands/wildcard: Add missing free.
12979 Found by: Coverity scan.
12981 commands/verify: Fix sha1 context zeroing-out.
12982 Current code doesn't zero-out context completely. It's a minor issue
12983 really as sha1 init already takes care of initing the context.
12985 commands/tr: Simplify and fix missing parameter test.
12986 Found by: Coverity scan
12988 commands/syslinux: Add missing free.
12989 Found by: Coverity scan.
12991 commands/parttool: Add missing device close.
12992 Found by: Coverity scan.
12994 commands/nativedisk: Add missing device_close.
12995 Found by: Coverity scan.
12997 2015-01-24 Vladimir Serbinenko <phcoder@gmail.com>
12999 commands/macbless: Handle device opening errors correctly.
13000 Wrong variable was checked for errors.
13002 Found by: Coverity scan.
13004 2015-01-24 Vladimir Serbinenko <phcoder@gmail.com>
13006 commands/macbless: Fix potential overflow.
13007 Is a minor concern as no such FS would be created under normal circumstances
13008 and failure was benign.
13010 Found by: Coverity scan.
13012 2015-01-24 Vladimir Serbinenko <phcoder@gmail.com>
13014 commands/macbless: Remove incorrect grub_free.
13015 Found by: Coverity Scan
13017 commands/legacycfg: Fix resource leaks.
13019 zfs: Fix disk-matching logic.
13020 Reported by: Tim Chase <dweeezil>
13022 commands/hdparm: Add missing grub_disk_close.
13023 Found by: Coverity scan.
13025 gptsync: Add missing device_close.
13026 Found by: Coverity scan
13028 commands/fileXX: Fix memory leak.
13029 Found by: Coverity Scan.
13031 2015-01-24 Vladimir Serbinenko <phcoder@gmail.com>
13033 commands/file: Change the confusing loop stop condition.
13034 Old condition was used to zero-out header variable on exit of the loop.
13035 This is correct but confusing. Replace with in-loop logic.
13037 Found by: Coverity Scan.
13039 2015-01-24 Vladimir Serbinenko <phcoder@gmail.com>
13041 commands/acpi: Use ALIGN_UP rather than manual expression.
13042 Improves readability and hopefully automatic scanning.
13044 Found by: Coverity Scan.
13046 2015-01-24 Vladimir Serbinenko <phcoder@gmail.com>
13048 uhci: Fix null pointer dereference.
13049 Found by: Coverity scan.
13051 Always add -msoft-float to avoid compiler generating float arithmetics.
13053 2015-01-24 Vladimir Serbinenko <phcoder@gmail.com>
13055 Generate empty ChangeLog if no .git is available.
13056 When making dist from a git snapshot without repo available make dist would
13057 fail to find ChangeLog. Generate empty ChangeLog if no ChangeLog is already
13058 present and repo is not available.
13060 Reported by: Andrei Borzenkov <arvidjaar@gmail.com>
13062 2015-01-24 Vladimir Serbinenko <phcoder@gmail.com>
13064 Makefile.am: Fix Changelog cutoff address.
13065 gitlog-to-changelog Doesn't generate entries for cutoff day, only
13066 for days after the cutoff date, adjust by one to compensate.
13068 efidisk: Return the determined root disk even if partition is unknown.
13070 util/grub-mkrescue.c: Always include part_msdos and part_gpt on EFI.
13071 When booted from stick, EFI would use GPT partition and our root
13072 device detection algortihm depends on GRUB's ability to see the same
13073 partitions. Hence include msdos and gpt partmap modules on EFI even when
13074 they're not needed to access root filesystem.
13076 conf/Makefile.common: Remove unused {LD,C}FLAGS_CPU.
13078 Autogenerate ChangeLog from git changelog.
13079 Old ChangeLog is moved to ChangeLog-2015. For all changes starting from
13080 this one ChangeLog will be generated from gitlog only on explicit make
13081 invocation and make dist.
13083 2015-01-23 Vladimir Serbinenko <phcoder@gmail.com>
13085 * tests/file_filter/file: Really add missing file.
13087 2015-01-23 Andrei Borzenkov <arvidjaar@gmail.com>
13089 Mention platform "none" in NEWS
13091 2015-01-23 Andrey Borzenkov <arvidjaar@gmail.com>
13093 accept also hdX as alias to native Xen disk name
13094 To be compatible with legacy pv-grub, sort disks by increasing order of handle
13095 value. This allows reusing legacy pv-grub menu.lst which is using hdX names.
13097 Suggested-By: Michael Chang <mchang@suse.com>