diff --git a/SOURCES/libffi-3.0.13-closures-Create-temporary-file-with-O_TMPFILE-and-O_.patch b/SOURCES/libffi-3.0.13-closures-Create-temporary-file-with-O_TMPFILE-and-O_.patch new file mode 100644 index 0000000..d5bb938 --- /dev/null +++ b/SOURCES/libffi-3.0.13-closures-Create-temporary-file-with-O_TMPFILE-and-O_.patch @@ -0,0 +1,82 @@ +From 8daeed9570af72eb135c8ded460d2888f05b2e68 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= +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 --git a/src/closures.c b/src/closures.c +index c7863f3..9799ce6 100644 +--- a/src/closures.c ++++ b/src/closures.c +@@ -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,27 @@ static int + open_temp_exec_file_dir (const char *dir) + { + static const char suffix[] = "/ffiXXXXXX"; +- int lendir = strlen (dir); +- char *tempname = __builtin_alloca (lendir + sizeof (suffix)); ++ int lendir, 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 +308,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 +-- +1.7.12.1 + diff --git a/SOURCES/libffi-aarch64-rhbz1174037.patch b/SOURCES/libffi-aarch64-rhbz1174037.patch new file mode 100644 index 0000000..dbf6308 --- /dev/null +++ b/SOURCES/libffi-aarch64-rhbz1174037.patch @@ -0,0 +1,11 @@ +--- 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; + diff --git a/SPECS/libffi.spec b/SPECS/libffi.spec index e2299c0..7f2919b 100644 --- a/SPECS/libffi.spec +++ b/SPECS/libffi.spec @@ -2,7 +2,7 @@ Name: libffi Version: 3.0.13 -Release: 16%{?dist} +Release: 18%{?dist} Summary: A portable foreign function interface library Group: System Environment/Libraries @@ -19,6 +19,10 @@ Patch10: libffi-3.0.13-ppc64le-0.patch Patch11: libffi-3.0.13-ppc64le-1.patch Patch12: libffi-3.0.13-ppc64le-2.patch Patch13: libffi-3.0.13-ppc64le-3.patch +# rhbz 1287815: +Patch20: libffi-aarch64-rhbz1174037.patch + +Patch21: libffi-3.0.13-closures-Create-temporary-file-with-O_TMPFILE-and-O_.patch %ifarch ppc64le BuildRequires: autoconf automake libtool texinfo %endif @@ -78,7 +82,8 @@ developing applications that use %{name}. autoreconf -vif %endif - +%patch20 -p1 -b .aarch64 +%patch21 -p1 -b .tmpfile %build CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" %configure --disable-static make %{?_smp_mflags} @@ -139,6 +144,14 @@ fi %{_infodir}/libffi.info.gz %changelog +* Tue Apr 5 2016 Andrew Haley - 3.0.13-18 +- closures: Create temporary file with O_TMPFILE and O_CLOEXEC +- Resolves: RHBZ1151568 + +* Tue Apr 5 2016 Andrew Haley - 3.0.13-17 +- libffi needs fix for structures not passed in registers +- Resolves: RHBZ1287815 + * Tue Sep 02 2014 Dan HorĂ¡k - 3.0.13-16 - Drop ppc64le from the multilib list - Use additional BR: only in ppc64le build