diff options
Diffstat (limited to 'repo/efivar')
-rw-r--r-- | repo/efivar/efivar.xibuild | 36 | ||||
-rw-r--r-- | repo/efivar/musl-compat.patch | 231 | ||||
-rw-r--r-- | repo/efivar/patches/efivar-fix-format_guid.patch | 56 | ||||
-rw-r--r-- | repo/efivar/patches/efivar-fix-packed.patch | 168 | ||||
-rw-r--r-- | repo/efivar/patches/efivar-fix-ucs2.patch | 59 | ||||
-rw-r--r-- | repo/efivar/patches/musl-bswap.patch | 33 |
6 files changed, 246 insertions, 337 deletions
diff --git a/repo/efivar/efivar.xibuild b/repo/efivar/efivar.xibuild index b2830d1..d47e14f 100644 --- a/repo/efivar/efivar.xibuild +++ b/repo/efivar/efivar.xibuild @@ -1,35 +1,29 @@ #!/bin/sh -MAKEDEPS="make patch" -DEPS="musl" +NAME="efivar" +DESC="Tools and library to manipulate EFI variables" + +MAKEDEPS="popt linux-headers mandoc" PKG_VER=38 -SOURCE=https://github.com/rhboot/efivar/releases/download/$PKG_VER/efivar-$PKG_VER.tar.bz2 +SOURCE="https://github.com/rhboot/efivar/releases/download/$PKG_VER/efivar-$PKG_VER.tar.bz2" ADDITIONAL=" - patches/musl-bswap.patch - patches/efivar-fix-format_guid.patch - patches/efivar-fix-packed.patch - patches/efivar-fix-ucs2.patch +musl-compat.patch " -DESC="Tools and libraries to manupulate EFI variables" - prepare() { - apply_patches - - # remove verbosity in ln commands - for f in Makefile src/Makefile src/test/Makefile docs/Makefile Make.rules; do - echo "patching $f" - sed -i "s@-vfs@-fs@g" $f - sed -i "s@-rfv@-rf@g" $f - done + apply_patches + sed -i 's/#include <sys\/cdefs.h>//g' "$BUILD_ROOT/src/compiler.h" } -build () { - make CFLAGS="-O2 -Wno-stringop-truncation" +build() { + cd "$BUILD_ROOT" + libdir="/usr/lib" make } -package () { - make LIBDIR=/usr/lib DESTDIR=$PKG_DEST install +package() { + cd "$BUILD_ROOT" + libdir="/usr/lib" make DESTDIR="$PKG_DEST" install } + diff --git a/repo/efivar/musl-compat.patch b/repo/efivar/musl-compat.patch new file mode 100644 index 0000000..00229be --- /dev/null +++ b/repo/efivar/musl-compat.patch @@ -0,0 +1,231 @@ +From cece3ffd5be2f8641eb694513f2b73e5eb97ffd3 Mon Sep 17 00:00:00 2001 +From: Natanael Copa <ncopa@alpinelinux.org> +Date: Fri, 28 Jan 2022 12:13:30 +0100 +Subject: [PATCH 1/2] efisecdb: fix build with musl libc + +Refactor code to use POSIX atexit(3) instead of the GNU specific +on_exit(3). + +Resolves: #197 +Resolves: #202 +Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> +--- + src/compiler.h | 2 -- + src/efisecdb.c | 68 +++++++++++++++++++------------------------------- + 2 files changed, 26 insertions(+), 44 deletions(-) + +diff --git a/src/compiler.h b/src/compiler.h +index e2f18f0b..d95fb014 100644 +--- a/src/compiler.h ++++ b/src/compiler.h +@@ -7,8 +7,6 @@ + #ifndef COMPILER_H_ + #define COMPILER_H_ + +-#include <sys/cdefs.h> +- + /* GCC version checking borrowed from glibc. */ + #if defined(__GNUC__) && defined(__GNUC_MINOR__) + # define GNUC_PREREQ(maj,min) \ +diff --git a/src/efisecdb.c b/src/efisecdb.c +index f8823737..6bd5ad90 100644 +--- a/src/efisecdb.c ++++ b/src/efisecdb.c +@@ -25,6 +25,10 @@ + extern char *optarg; + extern int optind, opterr, optopt; + ++static efi_secdb_t *secdb = NULL; ++static list_t infiles; ++static list_t actions; ++ + struct hash_param { + char *name; + efi_secdb_type_t algorithm; +@@ -187,12 +191,11 @@ add_action(list_t *list, action_type_t action_type, const efi_guid_t *owner, + } + + static void +-free_actions(int status UNUSED, void *actionsp) ++free_actions(void) + { +- list_t *actions = (list_t *)actionsp; + list_t *pos, *tmp; + +- for_each_action_safe(pos, tmp, actions) { ++ for_each_action_safe(pos, tmp, &actions) { + action_t *action = list_entry(pos, action_t, list); + + list_del(&action->list); +@@ -202,12 +205,11 @@ free_actions(int status UNUSED, void *actionsp) + } + + static void +-free_infiles(int status UNUSED, void *infilesp) ++free_infiles(void) + { +- list_t *infiles = (list_t *)infilesp; + list_t *pos, *tmp; + +- for_each_ptr_safe(pos, tmp, infiles) { ++ for_each_ptr_safe(pos, tmp, &infiles) { + ptrlist_t *entry = list_entry(pos, ptrlist_t, list); + + list_del(&entry->list); +@@ -216,27 +218,12 @@ free_infiles(int status UNUSED, void *infilesp) + } + + static void +-maybe_free_secdb(int status UNUSED, void *voidp) ++maybe_free_secdb(void) + { +- efi_secdb_t **secdbp = (efi_secdb_t **)voidp; +- +- if (secdbp == NULL || *secdbp == NULL) ++ if (secdb == NULL) + return; + +- efi_secdb_free(*secdbp); +-} +- +-static void +-maybe_do_unlink(int status, void *filep) +-{ +- char **file = (char **)filep; +- +- if (status == 0) +- return; +- if (file == NULL || *file == NULL) +- return; +- +- unlink(*file); ++ efi_secdb_free(secdb); + } + + static void +@@ -323,15 +310,6 @@ parse_input_files(list_t *infiles, char **outfile, efi_secdb_t **secdb, + return status; + } + +-/* +- * These need to be static globals so that they're not on main's stack when +- * on_exit() fires. +- */ +-static efi_secdb_t *secdb = NULL; +-static list_t infiles; +-static list_t actions; +-static char *outfile = NULL; +- + int + main(int argc, char *argv[]) + { +@@ -351,6 +329,7 @@ main(int argc, char *argv[]) + bool do_sort_data = false; + bool sort_descending = false; + int status = 0; ++ char *outfile = NULL; + + const char sopts[] = ":aAc:dfg:h:i:Lo:rs:t:v?"; + const struct option lopts[] = { +@@ -376,10 +355,9 @@ main(int argc, char *argv[]) + INIT_LIST_HEAD(&infiles); + INIT_LIST_HEAD(&actions); + +- on_exit(free_actions, &actions); +- on_exit(free_infiles, &infiles); +- on_exit(maybe_free_secdb, &secdb); +- on_exit(maybe_do_unlink, &outfile); ++ atexit(free_actions); ++ atexit(free_infiles); ++ atexit(maybe_free_secdb); + + /* + * parse the command line. +@@ -587,24 +565,30 @@ main(int argc, char *argv[]) + outfd = open(outfile, flags, 0600); + if (outfd < 0) { + char *tmpoutfile = outfile; +- if (errno == EEXIST) +- outfile = NULL; ++ if (errno != EEXIST) ++ unlink(outfile); + err(1, "could not open \"%s\"", tmpoutfile); + } + + rc = ftruncate(outfd, 0); +- if (rc < 0) ++ if (rc < 0) { ++ unlink(outfile); + err(1, "could not truncate output file \"%s\"", outfile); ++ } + + void *output; + size_t size = 0; + rc = efi_secdb_realize(secdb, &output, &size); +- if (rc < 0) ++ if (rc < 0) { ++ unlink(outfile); + secdb_err(1, "could not realize signature list"); ++ } + + rc = write(outfd, output, size); +- if (rc < 0) ++ if (rc < 0) { ++ unlink(outfile); + err(1, "could not write signature list"); ++ } + + close(outfd); + xfree(output); + +From df09b472419466987f2f30176dd00937e640aa9a Mon Sep 17 00:00:00 2001 +From: Natanael Copa <ncopa@alpinelinux.org> +Date: Fri, 28 Jan 2022 12:29:00 +0100 +Subject: [PATCH 2/2] efisecdb: do not free optarg + +The *outfile passed to parse_input_files can only be either set to +optarg or be NULL. optarg should not be free'd and NULL does not need +to. + +Since we no longer use on_exit to unlink outfile we also don't need to +set *outfile to NULL. + +Fixes commit d91787035bc1 (efisecdb: add efisecdb) + +Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> +--- + src/efisecdb.c | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/src/efisecdb.c b/src/efisecdb.c +index 6bd5ad90..70fa1847 100644 +--- a/src/efisecdb.c ++++ b/src/efisecdb.c +@@ -255,8 +255,7 @@ list_guids(void) + * failure. + */ + static int +-parse_input_files(list_t *infiles, char **outfile, efi_secdb_t **secdb, +- bool dump) ++parse_input_files(list_t *infiles, efi_secdb_t **secdb, bool dump) + { + int status = 0; + list_t *pos, *tmp; +@@ -297,8 +296,6 @@ parse_input_files(list_t *infiles, char **outfile, efi_secdb_t **secdb, + if (!dump) + exit(1); + status = 1; +- xfree(*outfile); +- *outfile = NULL; + break; + } + } +@@ -528,7 +525,7 @@ main(int argc, char *argv[]) + efi_secdb_set_bool(secdb, EFI_SECDB_SORT_DATA, do_sort_data); + efi_secdb_set_bool(secdb, EFI_SECDB_SORT_DESCENDING, sort_descending); + +- status = parse_input_files(&infiles, &outfile, &secdb, dump); ++ status = parse_input_files(&infiles, &secdb, dump); + if (status == 0) { + for_each_action_safe(pos, tmp, &actions) { + action_t *action = list_entry(pos, action_t, list); diff --git a/repo/efivar/patches/efivar-fix-format_guid.patch b/repo/efivar/patches/efivar-fix-format_guid.patch deleted file mode 100644 index f40942f..0000000 --- a/repo/efivar/patches/efivar-fix-format_guid.patch +++ /dev/null @@ -1,56 +0,0 @@ -From b98ba8921010d03f46704a476c69861515deb1ca Mon Sep 17 00:00:00 2001 -From: Peter Jones <pjones@redhat.com> -Date: Mon, 7 Jan 2019 10:30:59 -0500 -Subject: [PATCH] dp.h: make format_guid() handle misaligned guid pointers - safely. - -GCC 9 adds -Werror=address-of-packed-member, which causes us to see the -build error reported at - https://bugzilla.opensuse.org/show_bug.cgi?id=1120862 . - -That bug report shows us the following: - -In file included from dp.c:26: -dp.h: In function 'format_vendor_helper': -dp.h:120:37: error: taking address of packed member of 'struct <anonymous>' may result in an unaligned pointer value [-Werror=address-of-packed-member] - 120 | format_guid(buf, size, off, label, &dp->hw_vendor.vendor_guid); - | ^~~~~~~~~~~~~~~~~~~~~~~~~~ -dp.h:74:25: note: in definition of macro 'format_guid' - 74 | _rc = efi_guid_to_str(guid, &_guidstr); \ - | ^~~~ -cc1: all warnings being treated as errors - -This patch makes format_guid() use a local variable as a bounce buffer -in the case that the guid we're passed is aligned as chaotic neutral. - -Note that this only fixes this instance and there may be others that bz -didn't show because it exited too soon, and I don't have a gcc 9 build -in front of me right now. - -Signed-off-by: Peter Jones <pjones@redhat.com> ---- - src/dp.h | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -diff --git a/src/dp.h b/src/dp.h -index aa4e390..20cb608 100644 ---- a/src/dp.h -+++ b/src/dp.h -@@ -70,8 +70,15 @@ - #define format_guid(buf, size, off, dp_type, guid) ({ \ - int _rc; \ - char *_guidstr = NULL; \ -- \ -- _rc = efi_guid_to_str(guid, &_guidstr); \ -+ efi_guid_t _guid; \ -+ const efi_guid_t * const _guid_p = \ -+ likely(__alignof__(guid) == sizeof(guid)) \ -+ ? guid \ -+ : &_guid; \ -+ \ -+ if (unlikely(__alignof__(guid) == sizeof(guid))) \ -+ memmove(&_guid, guid, sizeof(_guid)); \ -+ _rc = efi_guid_to_str(_guid_p, &_guidstr); \ - if (_rc < 0) { \ - efi_error("could not build %s GUID DP string", \ - dp_type); \ diff --git a/repo/efivar/patches/efivar-fix-packed.patch b/repo/efivar/patches/efivar-fix-packed.patch deleted file mode 100644 index bbb6a99..0000000 --- a/repo/efivar/patches/efivar-fix-packed.patch +++ /dev/null @@ -1,168 +0,0 @@ -From c3c553db85ff10890209d0fe48fb4856ad68e4e0 Mon Sep 17 00:00:00 2001 -From: Peter Jones <pjones@redhat.com> -Date: Thu, 21 Feb 2019 15:20:12 -0500 -Subject: [PATCH] Fix all the places -Werror=address-of-packed-member catches. - -This gets rid of all the places GCC 9's -Werror=address-of-packed-member -flags as problematic. - -Fixes github issue #123 - -Signed-off-by: Peter Jones <pjones@redhat.com> ---- - src/dp-message.c | 6 ++++-- - src/dp.h | 12 ++++-------- - src/guid.c | 2 +- - src/include/efivar/efivar.h | 2 +- - src/ucs2.h | 27 +++++++++++++++++++-------- - 5 files changed, 29 insertions(+), 20 deletions(-) - -diff --git a/src/dp-message.c b/src/dp-message.c -index 3724e5f..9f96466 100644 ---- a/src/dp-message.c -+++ b/src/dp-message.c -@@ -620,11 +620,13 @@ _format_message_dn(char *buf, size_t size, const_efidp dp) - ) / sizeof(efi_ip_addr_t); - format(buf, size, off, "Dns", "Dns("); - for (int i=0; i < end; i++) { -- const efi_ip_addr_t *addr = &dp->dns.addrs[i]; -+ efi_ip_addr_t addr; -+ -+ memcpy(&addr, &dp->dns.addrs[i], sizeof(addr)); - if (i != 0) - format(buf, size, off, "Dns", ","); - format_ip_addr(buf, size, off, "Dns", -- dp->dns.is_ipv6, addr); -+ dp->dns.is_ipv6, &addr); - } - format(buf, size, off, "Dns", ")"); - break; -diff --git a/src/dp.h b/src/dp.h -index 20cb608..1f921d5 100644 ---- a/src/dp.h -+++ b/src/dp.h -@@ -71,13 +71,9 @@ - int _rc; \ - char *_guidstr = NULL; \ - efi_guid_t _guid; \ -- const efi_guid_t * const _guid_p = \ -- likely(__alignof__(guid) == sizeof(guid)) \ -- ? guid \ -- : &_guid; \ -- \ -- if (unlikely(__alignof__(guid) == sizeof(guid))) \ -- memmove(&_guid, guid, sizeof(_guid)); \ -+ const efi_guid_t * const _guid_p = &_guid; \ -+ \ -+ memmove(&_guid, guid, sizeof(_guid)); \ - _rc = efi_guid_to_str(_guid_p, &_guidstr); \ - if (_rc < 0) { \ - efi_error("could not build %s GUID DP string", \ -@@ -86,7 +82,7 @@ - _guidstr = onstack(_guidstr, \ - strlen(_guidstr)+1); \ - _rc = format(buf, size, off, dp_type, "%s", \ -- _guidstr); \ -+ _guidstr); \ - } \ - _rc; \ - }) -diff --git a/src/guid.c b/src/guid.c -index 306c9ff..3156b3b 100644 ---- a/src/guid.c -+++ b/src/guid.c -@@ -31,7 +31,7 @@ - extern const efi_guid_t efi_guid_zero; - - int NONNULL(1, 2) PUBLIC --efi_guid_cmp(const efi_guid_t *a, const efi_guid_t *b) -+efi_guid_cmp(const void * const a, const void * const b) - { - return memcmp(a, b, sizeof (efi_guid_t)); - } -diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h -index 316891c..ad6449d 100644 ---- a/src/include/efivar/efivar.h -+++ b/src/include/efivar/efivar.h -@@ -128,7 +128,7 @@ extern int efi_symbol_to_guid(const char *symbol, efi_guid_t *guid) - - extern int efi_guid_is_zero(const efi_guid_t *guid); - extern int efi_guid_is_empty(const efi_guid_t *guid); --extern int efi_guid_cmp(const efi_guid_t *a, const efi_guid_t *b); -+extern int efi_guid_cmp(const void * const a, const void * const b); - - /* import / export functions */ - typedef struct efi_variable efi_variable_t; -diff --git a/src/ucs2.h b/src/ucs2.h -index dbb5900..edd8367 100644 ---- a/src/ucs2.h -+++ b/src/ucs2.h -@@ -23,16 +23,21 @@ - (((val) & ((mask) << (shift))) >> (shift)) - - static inline size_t UNUSED --ucs2len(const uint16_t * const s, ssize_t limit) -+ucs2len(const void *vs, ssize_t limit) - { - ssize_t i; -- for (i = 0; i < (limit >= 0 ? limit : i+1) && s[i] != (uint16_t)0; i++) -+ const uint16_t *s = vs; -+ const uint8_t *s8 = vs; -+ -+ for (i = 0; -+ i < (limit >= 0 ? limit : i+1) && s8[0] != 0 && s8[1] != 0; -+ i++, s8 += 2, s++) - ; - return i; - } - - static inline size_t UNUSED --ucs2size(const uint16_t * const s, ssize_t limit) -+ucs2size(const void *s, ssize_t limit) - { - size_t rc = ucs2len(s, limit); - rc *= sizeof (uint16_t); -@@ -69,10 +74,11 @@ utf8size(uint8_t *s, ssize_t limit) - } - - static inline unsigned char * UNUSED --ucs2_to_utf8(const uint16_t * const chars, ssize_t limit) -+ucs2_to_utf8(const void * const voidchars, ssize_t limit) - { - ssize_t i, j; - unsigned char *ret; -+ const uint16_t * const chars = voidchars; - - if (limit < 0) - limit = ucs2len(chars, -1); -@@ -124,10 +130,12 @@ ucs2_to_utf8(const uint16_t * const chars, ssize_t limit) - } - - static inline ssize_t UNUSED NONNULL(4) --utf8_to_ucs2(uint16_t *ucs2, ssize_t size, int terminate, uint8_t *utf8) -+utf8_to_ucs2(void *ucs2void, ssize_t size, int terminate, uint8_t *utf8) - { - ssize_t req; - ssize_t i, j; -+ uint16_t *ucs2 = ucs2void; -+ uint16_t val16; - - if (!ucs2 && size > 0) { - errno = EINVAL; -@@ -162,10 +170,13 @@ utf8_to_ucs2(uint16_t *ucs2, ssize_t size, int terminate, uint8_t *utf8) - val = utf8[i] & 0x7f; - i += 1; - } -- ucs2[j] = val; -+ val16 = val; -+ ucs2[j] = val16; -+ } -+ if (terminate) { -+ val16 = 0; -+ ucs2[j++] = val16; - } -- if (terminate) -- ucs2[j++] = (uint16_t)0; - return j; - }; - diff --git a/repo/efivar/patches/efivar-fix-ucs2.patch b/repo/efivar/patches/efivar-fix-ucs2.patch deleted file mode 100644 index 594da61..0000000 --- a/repo/efivar/patches/efivar-fix-ucs2.patch +++ /dev/null @@ -1,59 +0,0 @@ -From fdb803402fb32fa6d020bac57a40c7efe4aabb7d Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas <javierm@redhat.com> -Date: Tue, 5 Mar 2019 17:23:24 +0100 -Subject: [PATCH] ucs2.h: remove unused variable - -The const uint16_t pointer is not used since now the two bytes of the -UCS-2 chars are checked to know if is the termination of the string. - -Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> ---- - src/ucs2.h | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/src/ucs2.h b/src/ucs2.h -index edd8367..e0390c3 100644 ---- a/src/ucs2.h -+++ b/src/ucs2.h -@@ -26,12 +26,11 @@ static inline size_t UNUSED - ucs2len(const void *vs, ssize_t limit) - { - ssize_t i; -- const uint16_t *s = vs; - const uint8_t *s8 = vs; - - for (i = 0; - i < (limit >= 0 ? limit : i+1) && s8[0] != 0 && s8[1] != 0; -- i++, s8 += 2, s++) -+ i++, s8 += 2) - ; - return i; - } -From 4e04afc2df9bbc26e5ab524b53a6f4f1e61d7c9e Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas <javierm@redhat.com> -Date: Tue, 5 Mar 2019 17:23:32 +0100 -Subject: [PATCH] ucs2.h: fix logic that checks for UCS-2 string termination - -Currently the loop to count the lenght of the UCS-2 string ends if either -of the two bytes are 0, but 0 is a valid value for UCS-2 character codes. - -So only break the loop when 0 is the value for both UCS-2 char bytes. - -Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> ---- - src/ucs2.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/ucs2.h b/src/ucs2.h -index e0390c3..fd8b056 100644 ---- a/src/ucs2.h -+++ b/src/ucs2.h -@@ -29,7 +29,7 @@ ucs2len(const void *vs, ssize_t limit) - const uint8_t *s8 = vs; - - for (i = 0; -- i < (limit >= 0 ? limit : i+1) && s8[0] != 0 && s8[1] != 0; -+ i < (limit >= 0 ? limit : i+1) && !(s8[0] == 0 && s8[1] == 0); - i++, s8 += 2) - ; - return i; diff --git a/repo/efivar/patches/musl-bswap.patch b/repo/efivar/patches/musl-bswap.patch deleted file mode 100644 index 8b86d9a..0000000 --- a/repo/efivar/patches/musl-bswap.patch +++ /dev/null @@ -1,33 +0,0 @@ -From c9b54ee2cd504542cac4ed95fa7842bd14b39f9c Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" <AWilcox@Wilcox-Tech.com> -Date: Fri, 18 Aug 2017 20:36:03 -0500 -Subject: [PATCH] makeguids: Ensure compatibility with other libcs - -The musl libc does not provide __bswap_constant_XX. -If <endian.h> does not provide these macros, use our own. - -This fixes issue #84. ---- - src/makeguids.c | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/src/makeguids.c b/src/makeguids.c -index ec75a86..6b0d80e 100644 ---- a/src/makeguids.c -+++ b/src/makeguids.c -@@ -152,6 +152,15 @@ main(int argc, char *argv[]) - fprintf(symout, "#include <efivar/efivar.h>\n"); - fprintf(symout, "#include <endian.h>\n"); - fprintf(symout, """\n\ -+#ifndef __bswap_constant_16\n\ -+#define __bswap_constant_16(x)\\\n\ -+ ((unsigned short int) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))\n\ -+#endif\n\ -+#ifndef __bswap_constant_32\n\ -+#define __bswap_constant_32(x)\\\n\ -+ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \\\n\ -+ (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))\n\ -+#endif\n\ - #if BYTE_ORDER == BIG_ENDIAN\n\ - #define cpu_to_be32(n) (n)\n\ - #define cpu_to_be16(n) (n)\n\ |