Compare commits

..

No commits in common. "4ceee0c0e89ee7a8645410754e905b23ce77edbf" and "f2d40698abfdae90db643109b331993a78ef9dd6" have entirely different histories.

12 changed files with 295 additions and 211 deletions

View File

@ -1,43 +0,0 @@
From ee3a1a046da9fd3f14965876340886167121057b Mon Sep 17 00:00:00 2001
From: Wei Fu <wefu@redhat.com>
#From: panchenbo <panchenbo@kylinsec.com.cn>
Date: Wed, 26 Apr 2023 17:47:25 +0800
Subject: [PATCH] Fix the -march issue for riscv64 sw_64
There is an issue on riscv64 system when compiling it natively:
gcc: error: '-march=native': ISA string must begin with rv32 or rv64
This patch set HOST_MARCH= like ia64 to resolve the issue.
Signed-off-by: Wei Fu <wefu@redhat.com>
(cherry picked from commit aab4e9b10ac9e98588a1b19771cf6f4c8c0a3096)
---
src/include/defaults.mk | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/include/defaults.mk b/src/include/defaults.mk
index 632b155..a25458f 100644
--- a/src/include/defaults.mk
+++ b/src/include/defaults.mk
@@ -72,10 +72,14 @@ override SOFLAGS = $(_SOFLAGS) \
$(call family,SOFLAGS)
HOST_ARCH=$(shell uname -m)
-ifneq ($(HOST_ARCH),ia64)
- HOST_MARCH=-march=native
-else
+ifeq ($(HOST_ARCH),ia64)
+ HOST_MARCH=
+else ifeq ($(HOST_ARCH),riscv64)
HOST_MARCH=
+else ifeq ($(HOST_ARCH),sw_64)
+ HOST_MARCH=
+else
+ HOST_MARCH=-march=native
endif
HOST_CPPFLAGS ?= $(CPPFLAGS)
override _HOST_CPPFLAGS := $(HOST_CPPFLAGS)
--
2.27.0

View File

@ -1,56 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Robbie Harwood <rharwood@redhat.com>
Date: Thu, 28 Jul 2022 16:11:24 -0400
Subject: [PATCH] Fix glibc 2.36 build (mount.h conflicts)
glibc has decided that sys/mount.h and linux/mount.h are no longer
usable at the same time. This broke the build, since linux/fs.h itself
includes linux/mount.h. For now, fix the build by only including
sys/mount.h where we need it.
See-also: https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E
Resolves: #227
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
(cherry picked from commit bc65d63ebf8fe6ac8a099ff15ca200986dba1565)
---
src/gpt.c | 1 +
src/linux.c | 1 +
src/util.h | 1 -
3 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/gpt.c b/src/gpt.c
index 1eda049..21413c3 100644
--- a/src/gpt.c
+++ b/src/gpt.c
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/mount.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/utsname.h>
diff --git a/src/linux.c b/src/linux.c
index 47e45ae..1780816 100644
--- a/src/linux.c
+++ b/src/linux.c
@@ -20,6 +20,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <sys/ioctl.h>
+#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/sysmacros.h>
#include <sys/types.h>
diff --git a/src/util.h b/src/util.h
index 3300666..1e67e44 100644
--- a/src/util.h
+++ b/src/util.h
@@ -23,7 +23,6 @@
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
-#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <tgmath.h>

View File

@ -1,29 +0,0 @@
From 6be2cb1c0139ac177e754b0767abf1ca1533847f Mon Sep 17 00:00:00 2001
From: Robbie Harwood <rharwood@redhat.com>
Date: Mon, 18 Apr 2022 13:08:18 -0400
Subject: [PATCH] Fix invalid free in main()
data is allocated by mmap() in prepare_data().
Resolves: #173
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Conflict:NA
Reference:https://github.com/rhboot/efivar/commit/6be2cb1c0139ac177e754b0767abf1ca1533847f
---
src/efivar.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/efivar.c b/src/efivar.c
index 5cd1eb2b..09f85edd 100644
--- a/src/efivar.c
+++ b/src/efivar.c
@@ -633,7 +633,7 @@ int main(int argc, char *argv[])
if (sz < 0)
err(1, "Could not import data from \"%s\"", infile);
- free(data);
+ munmap(data, data_size);
data = NULL;
data_size = 0;

View File

@ -0,0 +1,29 @@
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 e0390c34..fd8b056a 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;
--

View File

@ -0,0 +1,32 @@
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 edd8367b..e0390c34 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;
}
--

View File

@ -1,26 +0,0 @@
From 3f233dd9c8cbb267b2cf931c6191e650e8ab8a5f Mon Sep 17 00:00:00 2001
From: Qiumiao Zhang <zhangqiumiao1@huawei.com>
Date: Sat, 26 Aug 2023 14:36:24 +0800
Subject: [PATCH] dp.h: check _ucs2size in format_ucs2()
Signed-off-by: Qiumiao Zhang <zhangqiumiao1@huawei.com>
---
src/dp.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/dp.h b/src/dp.h
index 8290cc1..27f7650 100644
--- a/src/dp.h
+++ b/src/dp.h
@@ -123,7 +123,7 @@ format_vendor_helper(unsigned char *buf, size_t size, char *label,
uint16_t *_ucs2buf; \
uint32_t _ucs2size = sizeof(uint16_t) * len; \
_ucs2buf = alloca(_ucs2size); \
- if (_ucs2buf == NULL) \
+ if (_ucs2buf == NULL || _ucs2size < sizeof(uint16_t)) \
return -1; \
memset(_ucs2buf, '\0', _ucs2size); \
memcpy(_ucs2buf, str, _ucs2size - sizeof(uint16_t)); \
--
2.23.0

View File

@ -1,11 +0,0 @@
diff -Naur efivar-38.org/src/include/defaults.mk efivar-38.sw/src/include/defaults.mk
--- efivar-38.org/src/include/defaults.mk 2022-02-27 04:16:18.440000000 +0000
+++ efivar-38.sw/src/include/defaults.mk 2022-02-27 04:16:41.880000000 +0000
@@ -1,6 +1,6 @@
PREFIX ?= /usr
EXEC_PREFIX ?= $(PREFIX)
-LIBDIR ?= $(PREFIX)/lib64
+LIBDIR ?= $(PREFIX)/lib
DATADIR ?= $(PREFIX)/share
MANDIR ?= $(DATADIR)/man
INCLUDEDIR ?= $(PREFIX)/include

BIN
efivar-37.tar.bz2 Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,21 +1,17 @@
Name: efivar
Version: 38
Release: 4
Version: 37
Release: 8
Summary: Tools and libraries to work with EFI variables
License: LGPL-2.1-only
License: LGPLv2.1
URL: https://github.com/rhboot/%{name}
Source0: https://github.com/rhboot/%{name}/releases/download/%{version}/%{name}-%{version}.tar.bz2
Patch0001: 0001-Fix-the-march-issue-for-riscv64-and-sw_64.patch
Patch0002: 0002-Fix-glibc-2.36-build-mount.h-conflicts.patch
%ifarch sw_64
Patch0003: efivar-37-sw.patch
%endif
Patch9000: dp_h-check-_ucs2size-in-format_ucs2.patch
Patch9001: backport-Fix-invalid-free-in-main.patch
Patch0001: first-fix-gcc9-new-waring.patch
Patch0002: second-fix-gcc9-new-waring.patch
Patch0003: backport-ucs2.h-remove-unused-variable.patch
Patch0004: backport-ucs2.h-fix-logic-that-checks-for-UCS-2-string-termin.patch
BuildRequires: popt-devel glibc-static
BuildRequires: gcc mandoc
BuildRequires: gcc
Requires: %{name}-libs = %{version}-%{release}
%description
@ -45,14 +41,13 @@ export LDFLAGS="-flto-partition=none"
%install
%make_install
install -m 0644 src/abignore %{buildroot}%{_includedir}/efivar/.abignore
%ldconfig_scriptlets libs
%files
%defattr(-,root,root)
%license COPYING
%{_bindir}/*
%{_bindir}/%{name}
%files libs
%defattr(-,root,root)
@ -61,48 +56,17 @@ install -m 0644 src/abignore %{buildroot}%{_includedir}/efivar/.abignore
%files devel
%defattr(-,root,root)
%{_includedir}/%{name}/*.h
%{_includedir}/%{name}/.abignore
%{_libdir}/pkgconfig/*.pc
%{_libdir}/libefiboot.so
%{_libdir}/libefivar.so
%{_libdir}/libefisec.so
%files help
%defattr(-,root,root)
%doc README.md
%{_mandir}/man1/*.1.gz
%{_mandir}/man1/%{name}.1.gz
%{_mandir}/man3/*
%changelog
* Wed Mar 13 2024 zhouyihang <zhouyihang3@h-partners.com> - 38-4
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:Fix invalid free in main()
* Tue Sep 12 2023 zhangqiumiao <zhangqiumiao1@huawei.com> - 38-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:dp.h: check _ucs2size in format_ucs2()
* Wed Apr 26 2023 panchenbo <panchenbo@kylinsec.com.cn> - 38-2
- ID:NA
- SUG:NA
- DESC:fix sw_64 build error
* Mon Nov 07 2022 zhouyihang <zhouyihang3@h-partners.com> - 38-1
- Type:requirements
- ID:NA
- SUG:NA
- DESC:update efivar to 38
* Wed Oct 19 2022 wuzx<wuzx1226@qq.com> - 37-9
- Type:feature
- CVE:NA
- SUG:NA
- DESC:Add sw64 architecture
* Mon May 16 2022 mylee <liweiganga@uniontech.com> - 37-8
- fix spec changelog date

View File

@ -0,0 +1,56 @@
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); \

View File

@ -0,0 +1,168 @@
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;
};