68 Commits

Author SHA1 Message Date
Daniel Kiper
35bfd6c478 build: Add grub-core/tests/crypto_cipher_mode_vectors.h file to EXTRA_DIST
This file was not added to EXTRA_DIST during test creation.

Fixes: 51ebc6f67 (tests: Add functional tests for ecb/cbc helpers)

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Alec Brown <alec.r.brown@oracle.com>
Reviewed-by: Srish Srinivasan <ssrish@linux.ibm.com>
Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
2026-01-14 14:28:37 +01:00
Andrew Hamilton
f62269767e build: Add tpm2key.asn file for reference to dist archive
Add the tpm2key.asn file to the dist archive for reference by end users.

Signed-off-by: Andrew Hamilton <adhamilt@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-10-28 12:19:34 +01:00
Andrew Hamilton
46be4488fd build: Include new zstd test support files in dist archive
Include the two new zstd test support files in the dist archive
so end users can successfully run this test.

Signed-off-by: Andrew Hamilton <adhamilt@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-10-28 12:19:34 +01:00
Andrew Hamilton
fa79d5ea9c build: Include MAINTAINERS and SECURITY files in dist archive
Include the MAINTAINERS and SECURITY files in the dist archive
for reference in distributed archives by end users.

Signed-off-by: Andrew Hamilton <adhamilt@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-10-28 12:19:34 +01:00
Daniel Kiper
8271bcc130 build: Add appended signatures header file to EXTRA_DIST
This file was not added to EXTRA_DIST during the appended signatures merge.

Fixes: 3e4ff6ffb (appended signatures: Parse ASN1 node)

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Alec Brown <alec.r.brown@oracle.com>
2025-10-24 20:18:18 +02:00
Gary Lin
f8f68f14ae libgcrypt: Add hardware acceleration for gcry_sha512
Enable hardware acceleration for the gcry_sha512 module when building
for the x86_64 EFI target.

Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-10-23 19:15:00 +02:00
Gary Lin
70b2f5f08d libgcrypt: Add hardware acceleration for gcry_sha256
Enable hardware acceleration for the gcry_sha256 module when building
for the x86_64 EFI target.

Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-10-23 19:15:00 +02:00
Gary Lin
2158d8e8a7 libgcrypt: Declare the sha256 shaext function
There is no prototype of _gcry_sha256_transform_intel_shaext() defined
in the header or libgcrypt-grub/cipher/sha256.c, and gcc may complain
the missing-prototypes error when compiling sha256-intel-shaext.c.

Declare the prototype in sha256-intel-shaext.c to avoid the error.

Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-10-23 19:15:00 +02:00
Gary Lin
0ff5faf8cd libgcrypt: Implement _gcry_get_hw_features()
Implement _gcry_get_hw_features() and enable hardware feature detection
for x86_64.

Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-10-23 19:15:00 +02:00
Gary Lin
de201105d4 libgcrypt/kdf: Fix 64-bit modulus on 32-bit platforms
Use grub_divmod64() for the 64-bit modulus to prevent creation of
special division calls such as __umoddi3() and __aeabi_uldivmod() on
32-bit platforms.

Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-10-21 13:48:29 +02:00
Gary Lin
93544861bc libgcrypt/kdf: Remove unsupported KDFs
Clean up _gcry_kdf_*() to remove unsupported KDFs.

Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-10-21 13:47:50 +02:00
Gary Lin
1ff7206417 libgcrypt/kdf: Get rid of gpg_err_code_from_errno()
gpg_err_code_from_errno() requires libgcrypt_wrap/mem.c which is not in
Makefile.utilgcry.def. This commit replaces gpg_err_code_from_errno()
with GPG_ERR_* to avoid the build errors.

Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-10-21 13:47:25 +02:00
Gary Lin
0c06a454fc libgcrypt/kdf: Implement hash_buffers() for BLAKE2b-512
The hash_buffers() functions are disabled in GRUB by default but the
Argon2 implementation requires hash_buffers() for BLAKE2b-512.

This commit implements argon2_blake2b_512_hash_buffers() as the
replacement of _gcry_digest_spec_blake2b_512.hash_buffers().

Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-10-21 13:46:22 +02:00
Andrew Hamilton
1d2ee8f8b3 tests: Add test ISO files to dist package
Add test ISO files to dist package to allow ISO test to pass.

Signed-off-by: Andrew Hamilton <adhamilt@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-09-10 01:12:17 +02:00
Mate Kukri
29d515b4cc build: Add new libgcrypt and libtasn1 related files to EXTRA_DISTS
These files were not added to EXTRA_DISTS during the libgcrypt
and libtasn1 imports but are required for autogen.sh to work.

Signed-off-by: Mate Kukri <mate.kukri@canonical.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-08-14 21:21:42 +02:00
Mate Kukri
eb76b064d2 build: Add util/import_gcrypt_inth.sed to EXTRA_DISTS
This new file was not added to the distribution tarball during the last
libgcrypt import.

Fixes: 0739d24cd164 (libgcrypt: Adjust import script, definitions and API users for libgcrypt 1.11)

Signed-off-by: Mate Kukri <mate.kukri@canonical.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-08-14 21:21:42 +02:00
Lidong Chen
5eca564b19 gnulib: Bring back the fix for resolving unused variable issue
This patch resolved a minor issue spotted by Coverity:
  a983d36bd917 (gnulib/regexec: Resolve unused variable)

But, it was removed by the Gnulib update:
  2b7902459803 (Update gnulib version and drop most gnulib patches)

It caused Coverity to continue to flag the issue. Daniel Kiper
suggested to bring back the patch a983d36bd917 (gnulib/regexec: Resolve
unused variable).

Fixes: CID 292459

Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-06-26 17:19:25 +02:00
Andrew Hamilton
ac1512b872 gnulib: Add patch to allow GRUB w/GCC-15 compile
Pull in Gnulib fix to allow lib/base64.c to compile using GCC 15 or newer.

Pulled from Gnulib commit 25df6dc425 (Silence some
-Wunterminated-string-initialization warnings.)

GCC 15 adds a new compiler warning "-Wunterminated-string-initialization"
that will trigger what is considered a false-positive in lib/base64.c as
this array is not treated as a string but an array of characters so the
lack of NUL string terminator is expected.

GCC team has added ability to flag such instances of arrays that the
compiler may think are strings as "nonstring" arrays to avoid this
warning: __attribute__((nonstring)).

Fixes: https://savannah.gnu.org/bugs/?66470

Signed-off-by: Andrew Hamilton <adhamilt@gmail.com>
Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-06-26 17:02:21 +02:00
Alec Brown
db506b3b83 gnulib/regexec: Fix resource leak
In the function merge_state_with_log(), memory is allocated for the variable
next_nodes when creating a union of the variables table_nodes and log_nodes.
However, if next_state->entrance_nodes is NULL, then table_nodes becomes NULL
and we still allocate memory to copy the content of log_nodes. This can cause
a resource leak since we only free the memory for next_nodes if table_nodes
isn't NULL. To prevent this, we need to check that next_state->entrance_nodes
isn't NULL before allocating memory for the union.

This issue has been fixed in the latest version of gnulib and I've backported
this change to maintain consistency.

This issue was found by a Coverity scan of GRUB2 under the CID 473887.

Fixes: CID 473887

Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-06-17 14:29:29 +02:00
Alec Brown
bba7dd7363 gnulib/regcomp: Fix resource leak
In the functions create_initial_state() and calc_eclosure_iter(), memory
is allocated for the elems member of a re_node_set structure but that
memory isn't freed on error. Before returning an error, a call to
re_node_set_free() should be made to prevent the resource leak.

This issue has been fixed in the latest version of gnulib and I've
backported this change to maintain consistency.

This issue was found by a Coverity scan of GRUB2 under the following
CIDs: 473869, 473888.

Fixes: CID 473869
Fixes: CID 473888

Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-06-17 14:17:56 +02:00
Andrew Hamilton
ce23919cac build: Add new header files to dist to allow building from tar
Several new header files have been added to GRUB which need
to be manually added to the dist archive. This allows building
from the tar archive created by "make dist".

Signed-off-by: Andrew Hamilton <adhamilt@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-06-17 13:51:46 +02:00
Andrew Hamilton
e3b15bafd1 build: Remove extra_deps.lst from EXTRA_DIST
This file is auto-generated based on the selected platform and should
not be included in the source tarball.

Fixes: 6744840b (build: Track explicit module dependencies in Makefile.core.def)

Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Signed-off-by: Andrew Hamilton <adhamilt@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2025-06-17 13:47:21 +02:00
Oskari Pirhonen
b835601c76 build: Include grub-core/extra_deps.lst in dist
Fixes build failure due to the extra_deps.lst file not existing in the
tarball. Found while trying to package GRUB 2.12 for Gentoo.

  make[3]: *** No rule to make target '/var/tmp/portage/sys-boot/grub-2.12/work/grub-2.12/grub-core/extra_deps.lst', needed by 'syminfo.lst'.  Stop.

Fixes: 89fbe0cac (grub-core/Makefile.am: Make path to extra_deps.lst relative to $(top_srcdir)/grub-core)
Fixes: 154dcb1ae (build: Allow explicit module dependencies)

Signed-off-by: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2023-12-22 16:07:36 +01:00
Robbie Harwood
2b79024598 gnulib: Update gnulib version and drop most gnulib patches
In addition to the changes carried in our gnulib patches, several
Coverity and code hygiene fixes that were previously downstream are also
included in this 3-year gnulib increment.

Unfortunately, fix-width.patch is retained.

Bump minimum autoconf version from 2.63 to 2.64 and automake from 1.11
to 1.14, as required by gnulib.

Sync bootstrap script itself with gnulib.

Update regexp module for new dynarray dependency.

Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2022-03-21 19:14:54 +01:00
Robbie Harwood
cd37d3d391 gnulib: Drop no-abort.patch
Originally added in commit db7337a3d (grub-core/lib/posix_wrap/stdlib.h
(abort): Removed), this patched out all relevant invocations of abort()
in gnulib. While it was not documented why at the time, testing suggests
that there's no abort() implementation available for gnulib to use.

gnulib's position is that the use of abort() is correct here, since it
happens when input violates a "shall" from POSIX. Additionally, the
code in question is probably not reachable. Since abort() is more
friendly to user-space, they prefer to make no change, so we can just
carry a define instead (suggested by Paul Eggert).

Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2022-03-21 18:58:44 +01:00
Robbie Harwood
ea780522e1 gnulib: Drop fix-base64.patch
Originally added in commit 9fbdec2f (bootstrap: Add gnulib's base64
module) and subsequently modified in commit 552c9fd08 (gnulib: Fix build
of base64 when compiling with memory debugging), fix-base64.patch
handled two problems we have using gnulib, which are exercised by the
base64 module but not directly caused by it.

First, GRUB defines its own bool type, while gnulib expects the
equivalent of stdbool.h to be present. Rather than patching gnulib,
instead use gnulib's stdbool module to provide a bool type if needed
(suggested by Simon Josefsson).

Second, our config.h doesn't always inherit config-util.h, which is
where gnulib-related options like _GL_ATTRIBUTE_CONST end up.
fix-base64.h worked around this by defining the attribute away, but this
workaround is better placed in config.h itself, not a gnulib patch.

Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2022-03-21 18:50:13 +01:00
Darren Kenny
03477085f9 gnulib/regcomp: Fix uninitialized re_token
This issue has been fixed in the latest version of gnulib, so to
maintain consistency, I've backported that change rather than doing
something different.

Fixes: CID 73828

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2021-03-02 15:54:16 +01:00
Darren Kenny
0b7f347638 gnulib/regexec: Fix possible null-dereference
It appears to be possible that the mctx->state_log field may be NULL,
and the name of this function, clean_state_log_if_needed(), suggests
that it should be checking that it is valid to be cleaned before
assuming that it does.

Fixes: CID 86720

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2021-03-02 15:54:16 +01:00
Darren Kenny
3a37bf120a gnulib/argp-help: Fix dereference of a possibly NULL state
All other instances of call to __argp_failure() where there is
a dgettext() call is first checking whether state is NULL before
attempting to dereference it to get the root_argp->argp_domain.

Fixes: CID 292436

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2021-03-02 15:54:16 +01:00
Darren Kenny
75c3d3cec4 gnulib/regcomp: Fix uninitialized token structure
The code is assuming that the value of br_token.constraint was
initialized to zero when it wasn't.

While some compilers will ensure that, not all do, so it is better to
fix this explicitly than leave it to chance.

Fixes: CID 73749

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2021-03-02 15:54:16 +01:00
Darren Kenny
a983d36bd9 gnulib/regexec: Resolve unused variable
This is a really minor issue where a variable is being assigned to but
not checked before it is overwritten again.

The reason for this issue is that we are not building with DEBUG set and
this in turn means that the assert() that reads the value of the
variable match_last is being processed out.

The solution, move the assignment to match_last in to an ifdef DEBUG too.

Fixes: CID 292459

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2021-03-02 15:54:16 +01:00
Colin Watson
ac116bd659 gettext: Restore patches to po/Makefile.in.in
These were inadvertently lost during the conversion to Gnulib (gnulib:
Upgrade Gnulib and switch to bootstrap tool; commit 35b909062). The
files in po/gettext-patches/ can be imported using "git am" on top of
the gettext tag corresponding to AM_GNU_GETTEXT_VERSION in configure.ac
(currently 0.18.3). They handle translation of messages in shell files,
make msgfmt output in little-endian format, and arrange to use @SHELL@
rather than /bin/sh.

There were some changes solely for the purpose of distributing extra
files; for ease of maintenance, I've added these to
conf/Makefile.extra-dist instead.

Fixes: https://savannah.gnu.org/bugs/?57298

Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-03-10 21:17:54 +01:00
Patrick Steinhardt
9fbdec2f6b bootstrap: Add gnulib's base64 module
The upcoming support for LUKS2 disc encryption requires us to include a
parser for base64-encoded data, as it is used to represent salts and
digests. As gnulib already has code to decode such data, we can just
add it to the boostrapping configuration in order to make it available
in GRUB.

The gnulib module makes use of booleans via the <stdbool.h> header. As
GRUB does not provide any POSIX wrapper header for this, but instead
implements support for bool in <sys/types.h>, we need to patch
base64.h to not use <stdbool.h> anymore. We unfortunately cannot include
<sys/types.h> instead, as it would then use gnulib's internal header
while compiling the gnulib object but our own <sys/types.h> when
including it in a GRUB module. Because of this, the patch replaces the
include with a direct typedef.

A second fix is required to make available _GL_ATTRIBUTE_CONST, which
is provided by the configure script. As base64.h does not include
<config.h>, it is thus not available and results in a compile error.
This is fixed by adding an include of <config-util.h>.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-01-10 14:26:40 +01:00
Colin Watson
35b909062e gnulib: Upgrade Gnulib and switch to bootstrap tool
Upgrade Gnulib files to 20190105.

It's much easier to maintain GRUB's use of portability support files
from Gnulib when the process is automatic and driven by a single
configuration file, rather than by maintainers occasionally running
gnulib-tool and committing the result.  Removing these
automatically-copied files from revision control also removes the
temptation to hack the output in ways that are difficult for future
maintainers to follow.  Gnulib includes a "bootstrap" program which is
designed for this.

The canonical way to bootstrap GRUB from revision control is now
"./bootstrap", but "./autogen.sh" is still useful if you just want to
generate the GRUB-specific parts of the build system.

GRUB now requires Autoconf >= 2.63 and Automake >= 1.11, in line with
Gnulib.

Gnulib source code is now placed in grub-core/lib/gnulib/ (which should
not be edited directly), and GRUB's patches are in
grub-core/lib/gnulib-patches/.  I've added a few notes to the developer
manual on how to maintain this.

Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2019-03-05 10:48:12 +01:00
Andrei Borzenkov
c67025fad5 Add grub-module-verifier files to EXTRA_DIST 2015-12-31 21:35:11 +03:00
Andrei Borzenkov
346a494d7c Do not include generated gnulib headers in tarball
gnulib files are already handled by recursive make distdir invocation.
Including all generated headers (after make completed) causes build
failure if target system is different (different compile version etc).
2015-11-28 21:11:34 +03:00
Andrei Borzenkov
6a5c78c8c8 Add asm-tests to tarball 2015-05-07 22:15:16 +03:00
Andrei Borzenkov
35a492e4a2 tests: remove hardcoded paths from syslinux_test
abs_top_srcdir appeared in Autoconf 2.52f. Minimal grub requirement
is 2.60 so we should be good here.
2015-02-16 22:24:05 +03:00
Andrei Borzenkov
251ddf26dc build-sys: add syslinux test files to tarball 2015-02-16 20:31:22 +03:00
Andrei Borzenkov
272e0466da add file filters tests
Tests file access with all filters enabled. It does it both for local
and network access, due to regression in signature checking over network.

This includes all files in distribution to not depend on existence
of compression tools and gpg. Test preloads all required modules to
avoid having to provide signatures for them.

Still not implemented is file offset filter (is not available in grub
script, needs extra module)
2014-12-05 21:04:06 +03:00
Vladimir Serbinenko
5f5bb10748 * conf/Makefile.extra-dist: Adjust path to conf/i386-cygwin-img-ld.sc. 2013-12-14 23:33:05 +01:00
Colin Watson
ab4f15013a Generate Makefile.*.am directly from gentpl.py, eliminating the use of Autogen. The Autogen definitions files remain intact as they offer a useful abstraction. 2013-11-26 17:13:01 +00:00
Vladimir Serbinenko
48eb35cd78 * coreboot.cfg: Add missing file. 2013-11-20 00:52:23 +01:00
Colin Watson
4e7d433dfb * Makefile.util.def (grub-mkimage): Add
grub-core/osdep/aros/config.c to extra_dist.
* conf/Makefile.extra-dist (EXTRA_DIST): Add docs/autoiso.cfg,
docs/osdetect.cfg, grub-core/gnulib-fix-null-deref.diff,
grub-core/gnulib-fix-width.diff, grub-core/gnulib-no-abort.diff, and
grub-core/gnulib-no-gets.diff.
2013-11-19 20:39:16 +00:00
Vladimir 'phcoder' Serbinenko
2028576504 Add haiku-specific functions. 2013-10-19 16:39:38 +02:00
Vladimir 'phcoder' Serbinenko
70671037c8 Split emunet into platform-dependent and GRUB-binding parts. Keep
platform-dependent part in kernel for easy access to OS functions.
2013-10-15 11:55:20 +02:00
Andrey Borzenkov
d9d68ef020 * conf/Makefile.extra-dist: Add osdep/*/init.c 2013-10-14 21:03:14 +04:00
Vladimir 'phcoder' Serbinenko
ed8c0887f4 * conf/Makefile.extra-dist: Fix extra-dist list.
* grub-core/Makefile.core.def: Likewise.
2013-10-10 09:47:39 +02:00
Vladimir 'phcoder' Serbinenko
7e518ca84f Use Winapi on both cygwin and mingw32 to share more code between both. 2013-09-23 11:21:09 +02:00
Vladimir 'phcoder' Serbinenko
3ff4063dd3 * grub-core/kern/emu/hostdisk.c: Disentagle into a series of OS-specific
files rather than one file with loads of #if's.
	* util/getroot.c: Likewise.
2013-09-22 07:36:17 +02:00