Compare commits

...

No commits in common. "c8" and "c9" have entirely different histories.
c8 ... c9

11 changed files with 97 additions and 357 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/libffi-3.1.tar.gz
SOURCES/libffi-3.4.2.tar.gz

View File

@ -1 +1 @@
cb373ef2115ec7c57913b84ca72eee14b10ccdc3 SOURCES/libffi-3.1.tar.gz
460882cfdb52a2bd13fc08edc540b242ae421033 SOURCES/libffi-3.4.2.tar.gz

View File

@ -1,11 +0,0 @@
--- a/src/aarch64/sysv.S
+++ b/src/aarch64/sysv.S
@@ -396,3 +396,8 @@
#ifdef __ELF__
.size CNAME(ffi_closure_SYSV), .-CNAME(ffi_closure_SYSV)
#endif
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",%progbits
+#endif
+

View File

@ -1,79 +0,0 @@
From 8daeed9570af72eb135c8ded460d2888f05b2e68 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= <mic@digikod.net>
Date: Sun, 11 May 2014 22:54:58 +0200
Subject: [PATCH 626/627] closures: Create temporary file with O_TMPFILE and
O_CLOEXEC when available
The open_temp_exec_file_dir function can create a temporary file without
file system accessible link. If the O_TMPFILE flag is not defined (old
Linux kernel or libc) the behavior is unchanged.
The open_temp_exec_file_name function now need a new argument "flags"
(like O_CLOEXEC) used for temporary file creation.
The O_TMPFILE flag allow temporary file creation without race condition.
This feature/fix prevent another process to access the (future)
executable file from the file system.
The O_CLOEXEC flag automatically close the temporary file for any
execve. This avoid transmitting (executable) file descriptor to a child
process.
---
src/closures.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff -rup a/src/closures.c b/src/closures.c
--- a/src/closures.c 2019-06-14 14:24:01.510844835 -0400
+++ b/src/closures.c 2019-06-14 14:26:48.248924350 -0400
@@ -265,9 +265,9 @@ static size_t execsize = 0;
/* Open a temporary file name, and immediately unlink it. */
static int
-open_temp_exec_file_name (char *name)
+open_temp_exec_file_name (char *name, int flags)
{
- int fd = mkstemp (name);
+ int fd = mkostemp (name, flags);
if (fd != -1)
unlink (name);
@@ -280,8 +280,28 @@ static int
open_temp_exec_file_dir (const char *dir)
{
static const char suffix[] = "/ffiXXXXXX";
- size_t lendir = strlen (dir);
- char *tempname = __builtin_alloca (lendir + sizeof (suffix));
+ size_t lendir;
+ int flags, fd;
+ char *tempname;
+
+#ifdef O_CLOEXEC
+ flags = O_CLOEXEC;
+#else
+ flags = 0;
+#endif
+
+#ifdef O_TMPFILE
+ fd = open (dir, flags | O_RDWR | O_EXCL | O_TMPFILE, 0700);
+ /* If the running system does not support the O_TMPFILE flag then retry without it. */
+ if (fd != -1 || (errno != EINVAL && errno != EISDIR && errno != EOPNOTSUPP)) {
+ return fd;
+ } else {
+ errno = 0;
+ }
+#endif
+
+ lendir = strlen (dir);
+ tempname = __builtin_alloca (lendir + sizeof (suffix));
if (!tempname)
return -1;
@@ -289,7 +309,7 @@ open_temp_exec_file_dir (const char *dir
memcpy (tempname, dir, lendir);
memcpy (tempname + lendir, suffix, sizeof (suffix));
- return open_temp_exec_file_name (tempname);
+ return open_temp_exec_file_name (tempname, flags);
}
/* Open a temporary file in the directory in the named environment

View File

@ -1,31 +0,0 @@
From 978c9540154d320525488db1b7049277122f736d Mon Sep 17 00:00:00 2001
From: Samuli Suominen <ssuominen@gentoo.org>
Date: Sat, 31 May 2014 08:53:10 -0400
Subject: [PATCH] Add missing GNU stack markings in win32.S
---
src/x86/win32.S | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/x86/win32.S b/src/x86/win32.S
index daf0e79..e42baf2 100644
--- a/src/x86/win32.S
+++ b/src/x86/win32.S
@@ -1,5 +1,6 @@
/* -----------------------------------------------------------------------
- win32.S - Copyright (c) 1996, 1998, 2001, 2002, 2009 Red Hat, Inc.
+ win32.S - Copyright (c) 2014 Anthony Green
+ Copyright (c) 1996, 1998, 2001, 2002, 2009 Red Hat, Inc.
Copyright (c) 2001 John Beniton
Copyright (c) 2002 Ranjit Mathew
Copyright (c) 2009 Daniel Witte
@@ -1304,3 +1305,6 @@ L_ffi_closure_SYSV_inner$stub:
#endif /* !_MSC_VER */
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
--
1.9.3

View File

@ -1,17 +0,0 @@
diff -up libffi-3.1/libffi.pc.in.fixpath libffi-3.1/libffi.pc.in
--- libffi-3.1/libffi.pc.in.fixpath 2014-04-25 19:45:13.000000000 +0200
+++ libffi-3.1/libffi.pc.in 2014-06-12 12:06:06.000000000 +0200
@@ -1,11 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
-toolexeclibdir=@toolexeclibdir@
-includedir=${libdir}/@PACKAGE_NAME@-@PACKAGE_VERSION@/include
+includedir=@includedir@
Name: @PACKAGE_NAME@
Description: Library supporting Foreign Function Interfaces
Version: @PACKAGE_VERSION@
-Libs: -L${toolexeclibdir} -lffi
+Libs: -L${libdir} -lffi
Cflags: -I${includedir}

View File

@ -1,17 +0,0 @@
Most temp file directories need to be hardened against execution, but
libffi needs execute privileges. Add a libffi-specific temp directory
that can be set up by sysadmins as needed with suitable permissions.
This both ensures that libffi will have a valid temp directory to use
as well as preventing attempts to access other directories.
diff -rup a/src/closures.c b/src/closures.c
--- a/src/closures.c 2014-05-11 09:54:19.000000000 -0400
+++ b/src/closures.c 2020-04-29 20:50:00.454853909 -0400
@@ -362,6 +362,7 @@ static struct
const char *arg;
int repeat;
} open_temp_exec_file_opts[] = {
+ { open_temp_exec_file_env, "LIBFFI_TMPDIR", 0 },
{ open_temp_exec_file_env, "TMPDIR", 0 },
{ open_temp_exec_file_dir, "/tmp", 0 },
{ open_temp_exec_file_dir, "/var/tmp", 0 },

View File

@ -1,120 +0,0 @@
From 5c63b463b87d3c06102a4a7f05f395929d9ea79b Mon Sep 17 00:00:00 2001
From: DJ Delorie <dj@delorie.com>
Date: Wed, 2 Dec 2020 16:14:27 -0500
Subject: Use memfd_create() (#604)
memfd_create creates a file in a memory-only filesystem that may
bypass strict security protocols in filesystem-based temporary
files.
diff -rup a/configure.ac b/configure.ac
--- a/configure.ac 2014-05-11 09:57:49.000000000 -0400
+++ b/configure.ac 2021-11-03 17:41:31.935391831 -0400
@@ -63,6 +63,9 @@ EOF
AM_MAINTAINER_MODE
+AC_CHECK_HEADERS(sys/memfd.h)
+AC_CHECK_FUNCS([memfd_create])
+
AC_CHECK_HEADERS(sys/mman.h)
AC_CHECK_FUNCS(mmap)
AC_FUNC_MMAP_BLACKLIST
diff -rup a/configure b/configure
--- a/configure 2014-05-19 09:44:03.000000000 -0400
+++ b/configure 2021-11-18 17:29:45.484951520 -0500
@@ -16976,6 +16976,30 @@ fi
+for ac_header in sys/memfd.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "sys/memfd.h" "ac_cv_header_sys_memfd_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_memfd_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_MEMFD_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_func in memfd_create
+do :
+ ac_fn_c_check_func "$LINENO" "memfd_create" "ac_cv_func_memfd_create"
+if test "x$ac_cv_func_memfd_create" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_MEMFD_CREATE 1
+_ACEOF
+
+fi
+done
+
+
for ac_header in sys/mman.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default"
diff -rup a/fficonfig.h.in b/fficonfig.h.in
--- a/fficonfig.h.in 2014-05-19 09:44:04.000000000 -0400
+++ b/fficonfig.h.in 2021-11-18 17:45:39.000000000 -0500
@@ -79,6 +79,9 @@
/* Define to 1 if you have the `memcpy' function. */
#undef HAVE_MEMCPY
+/* Define to 1 if you have the `memfd_create' function. */
+#undef HAVE_MEMFD_CREATE
+
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
@@ -109,6 +112,9 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
+/* Define to 1 if you have the <sys/memfd.h> header file. */
+#undef HAVE_SYS_MEMFD_H
+
/* Define to 1 if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
diff -rup a/src/closures.c b/src/closures.c
--- a/src/closures.c 2021-11-03 17:37:37.841416436 -0400
+++ b/src/closures.c 2021-11-03 17:43:19.027498783 -0400
@@ -117,6 +117,9 @@
#endif /* HAVE_MNTENT */
#include <sys/param.h>
#include <pthread.h>
+#ifdef HAVE_SYS_MEMFD_H
+#include <sys/memfd.h>
+#endif
/* We don't want sys/mman.h to be included after we redefine mmap and
dlmunmap. */
@@ -263,6 +266,17 @@ static int execfd = -1;
/* The amount of space already allocated from the temporary file. */
static size_t execsize = 0;
+#ifdef HAVE_MEMFD_CREATE
+/* Open a temporary file name, and immediately unlink it. */
+static int
+open_temp_exec_file_memfd (const char *name)
+{
+ int fd;
+ fd = memfd_create (name, MFD_CLOEXEC);
+ return fd;
+}
+#endif
+
/* Open a temporary file name, and immediately unlink it. */
static int
open_temp_exec_file_name (char *name, int flags)
@@ -382,6 +396,9 @@ static struct
const char *arg;
int repeat;
} open_temp_exec_file_opts[] = {
+#ifdef HAVE_MEMFD_CREATE
+ { open_temp_exec_file_memfd, "libffi", 0 },
+#endif
{ open_temp_exec_file_env, "LIBFFI_TMPDIR", 0 },
{ open_temp_exec_file_env, "TMPDIR", 0 },
{ open_temp_exec_file_dir, "/tmp", 0 },

View File

@ -1,7 +1,7 @@
diff -rup a/src/closures.c b/src/closures.c
--- a/src/closures.c 2022-11-16 15:27:45.632725415 -0500
+++ b/src/closures.c 2022-11-18 13:56:17.948172306 -0500
@@ -140,6 +140,9 @@ selinux_enabled_check (void)
--- a/src/closures.c 2021-06-27 14:03:12.000000000 -0400
+++ b/src/closures.c 2023-04-06 23:37:18.742954529 -0400
@@ -432,6 +432,9 @@ selinux_enabled_check (void)
char *buf = NULL;
size_t len = 0;

View File

@ -1,11 +0,0 @@
--- libffi-3.1/src/aarch64/ffi.c.orig 2014-04-25 18:45:13.000000000 +0100
+++ libffi-3.1/src/aarch64/ffi.c 2015-01-15 02:36:56.314906455 +0000
@@ -728,7 +728,7 @@
state.ngrn = N_X_ARG_REG;
memcpy (allocate_to_stack (&state, stack, ty->alignment,
- ty->size), ecif->avalue + i, ty->size);
+ ty->size), ecif->avalue[i], ty->size);
}
break;

View File

@ -1,24 +1,25 @@
%global multilib_arches %{ix86} ppc ppc64 ppc64p7 s390 s390x x86_64
%bcond_with bootstrap
%global multilib_arches %{ix86} x86_64
Name: libffi
Version: 3.1
Release: 24%{?dist}
Version: 3.4.2
Release: 8%{?dist}
Summary: A portable foreign function interface library
Group: System Environment/Libraries
License: MIT
URL: http://sourceware.org/libffi
Source0: ftp://sourceware.org/pub/libffi/libffi-%{version}.tar.gz
Source0: https://github.com/libffi/libffi/releases/download/v3.4.2/libffi-3.4.2.tar.gz
Source1: ffi-multilib.h
Source2: ffitarget-multilib.h
Patch0: libffi-3.1-fix-include-path.patch
Patch1: libffi-3.1-fix-exec-stack.patch
Patch2: libffi-aarch64-rhbz1174037.patch
Patch3: libffi-3.1-aarch64-fix-exec-stack.patch
Patch5: libffi-3.1-closures-Create-temporary-file-with-O_TMPFILE-and-O_.patch
Patch6: libffi-3.1-libffi_tmpdir.patch
Patch7: libffi-3.1-memfd.patch
Patch8: libffi-3.1-rh2014228.patch
Patch1: libffi-3.4.2-rh2152228.patch
BuildRequires: make
BuildRequires: gcc
%if %{without bootstrap}
BuildRequires: gcc-c++
BuildRequires: dejagnu
%endif
%description
Compilers for high level languages generate code that follow certain
@ -47,40 +48,36 @@ layer of a fully featured foreign function interface. A layer must
exist above `libffi' that handles type conversions for values passed
between the two languages.
%package devel
Summary: Development files for %{name}
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: pkgconfig
Requires(post): /sbin/install-info
Requires(preun): /sbin/install-info
%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
%prep
%setup -q
%patch0 -p1 -b .fixpath
%patch1 -p1 -b .execstack
%patch2 -p1 -b .aarch64
%patch3 -p1 -b .aarch64execstack
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch1 -p1
%build
export CFLAGS="%{build_cflags} -Wa,--generate-missing-build-notes=yes"
%configure --disable-static
make %{?_smp_mflags}
# For now we disable the static templates to avoid ghc and
# gobject-introspection failures:
# https://gitlab.haskell.org/ghc/ghc/-/issues/20051
# https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/283
# We need to get these fixes into Fedora before we can reeanble them.
%configure --disable-static --disable-exec-static-tramp
%make_build
%check
%if %{without bootstrap}
%make_build check
%endif
%install
make install DESTDIR=$RPM_BUILD_ROOT
%make_install
find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
rm -f $RPM_BUILD_ROOT%{_infodir}/dir
@ -96,65 +93,94 @@ mkdir -p $RPM_BUILD_ROOT%{_includedir}
# can have both a 32- and 64-bit version of the library, and they each need
# their own correct-but-different versions of the headers to be usable.
for i in ffi ffitarget; do
mv $RPM_BUILD_ROOT%{_libdir}/libffi-%{version}/include/$i.h $RPM_BUILD_ROOT%{_includedir}/$i-${basearch}.h
mv $RPM_BUILD_ROOT%{_includedir}/$i.h $RPM_BUILD_ROOT%{_includedir}/$i-${basearch}.h
done
install -m644 %{SOURCE1} $RPM_BUILD_ROOT%{_includedir}/ffi.h
install -m644 %{SOURCE2} $RPM_BUILD_ROOT%{_includedir}/ffitarget.h
%else
mv $RPM_BUILD_ROOT%{_libdir}/libffi-%{version}/include/{ffi,ffitarget}.h $RPM_BUILD_ROOT%{_includedir}
%endif
rm -rf $RPM_BUILD_ROOT%{_libdir}/libffi-%{version}
%ldconfig_scriptlets
%post devel
/sbin/install-info --info-dir=%{_infodir} %{_infodir}/libffi.info.gz || :
%preun devel
if [ $1 = 0 ] ;then
/sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/libffi.info.gz || :
fi
%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc README
%{_libdir}/*.so.*
%doc README.md
%{_libdir}/libffi.so.8
%{_libdir}/libffi.so.8.1.0
%files devel
%{_libdir}/pkgconfig/*.pc
%{_includedir}/ffi*.h
%{_libdir}/*.so
%{_mandir}/man3/*.gz
%{_infodir}/libffi.info.gz
%{_infodir}/libffi.info.*
%changelog
* Wed Nov 16 2022 DJ Delorie <dj@redhat.com> - 3.1-24
* Fri Apr 07 2023 DJ Delorie <dj@redhat.com> - 3.4.2-8
- Use /etc/sysconfig/libffi-force-shared-memory-check-first to
override selinux permissions check for shared memory access (#2014228)
override selinux permissions check for shared memory access (#2152228)
* Fri Nov 19 2021 DJ Delorie <dj@redhat.com> - 3.1-23
- Use memfd_create() to allocate closures (#1875340)
* Thu Aug 26 2021 Carlos O'Donell <codonell@redhat.com> - 3.4.2-7
- Remove compat-libffi3.1 subpackage to complete SONAME transition.
Related: rhbz#1891914
* Wed May 6 2020 DJ Delorie <dj@redhat.com> - 3.1-22
- Add $LIBFFI_TMPDIR environment variable support (#1723951)
* Wed Aug 18 2021 Carlos O'Donell <carlos@redhat.com> - 3.4.2-6
- Rebuilt for libffi 3.4.2 SONAME transition. Related: rhbz#1891914
* Thu Aug 1 2019 DJ Delorie <dj@redhat.com> - 3.1-21
- Revert 1652930 until 1721569 can be fixed (#1652930)
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 3.4.2-5
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Fri Jun 14 2019 DJ Delorie <dj@redhat.com> - 3.1-20
- closures: Create temporary file with O_TMPFILE and O_CLOEXEC (#1720600)
* Thu Jul 29 2021 Carlos O'Donell <carlos@redhat.com> - 3.4.2-4
- Drop pkgconf support for compat-libffi3.1.
* Fri Jun 14 2019 Florian Weimer <fweimer@redhat.com> - 3.1-19
- aarch64: Flush code alias mapping after creating closure (#1652930)
* Tue Jul 27 2021 Carlos O'Donell <carlos@redhat.com> - 3.4.2-3
- Add temporary compat-libffi3.1 for library transition.
* Tue Nov 27 2018 Severin Gehwolf <sgehwolf@redhat.com> - 3.1-18
- Compile with -Wa,--generate-missing-build-notes=yes
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Fri Aug 10 2018 Severin Gehwolf <sgehwolf@redhat.com> - 3.1-17
- Fix declared license: BSD => MIT.
* Mon Jun 28 2021 Carlos O'Donell <carlos@redhat.com> - 3.4.2-1
- Rebase to libffi 3.4.2.
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 3.1-29
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-28
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Wed Dec 02 2020 Carlos O'Donell <carlos@redhat.com> - 3.1-27
- Use make macros
- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-26
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Thu Apr 30 2020 DJ Delorie <idj@redhat.com> - 3.1-25
- Add $LIBFFI_TMPDIR environment variable support (#1667620)
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-24
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-23
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Tue Jul 9 2019 Florian Weimer <fweimer@redhat.com> - 3.1-22
- Run test suite during build (#1727088)
* Wed Jun 19 2019 Anthony Green <green@redhat.com> - 3.1-21
- Fix license tag
* Wed Apr 24 2019 Björn Esser <besser82@fedoraproject.org> - 3.1-20
- Remove hardcoded gzip suffix from GNU info pages
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-19
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Sun Jul 22 2018 Peter Robinson <pbrobinson@fedoraproject.org> 3.1-28
- Fix FTBFS
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-17
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.1-16
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild