summaryrefslogtreecommitdiff
path: root/gnu/packages/patches
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2019-02-14 00:20:28 +0100
committerMarius Bakke <mbakke@fastmail.com>2019-02-14 00:20:28 +0100
commit6901878894e9c6405fa811c512a32f448e8b9fa2 (patch)
tree5b04c4234f4022533692c36a83047ec9801aada9 /gnu/packages/patches
parentbaf766a7ff9db45c707b4539176f2143fbd90efd (diff)
parent58c6a93d9d60660d8425d8c52d4b73a42d4a5b55 (diff)
Merge branch 'master' into staging
Diffstat (limited to 'gnu/packages/patches')
-rw-r--r--gnu/packages/patches/glibc-CVE-2018-11236.patch149
-rw-r--r--gnu/packages/patches/glibc-CVE-2018-11237.patch55
-rw-r--r--gnu/packages/patches/gnome-shell-theme.patch53
-rw-r--r--gnu/packages/patches/kio-search-smbd-on-PATH.patch2
-rw-r--r--gnu/packages/patches/ledger-revert-boost-python-fix.patch39
-rw-r--r--gnu/packages/patches/red-eclipse-remove-gamma-name-hack.patch52
-rw-r--r--gnu/packages/patches/runc-CVE-2019-5736.patch343
-rw-r--r--gnu/packages/patches/scalapack-blacs-mpi-deprecations.patch170
8 files changed, 823 insertions, 40 deletions
diff --git a/gnu/packages/patches/glibc-CVE-2018-11236.patch b/gnu/packages/patches/glibc-CVE-2018-11236.patch
new file mode 100644
index 0000000000..4f8a72943c
--- /dev/null
+++ b/gnu/packages/patches/glibc-CVE-2018-11236.patch
@@ -0,0 +1,149 @@
+https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=patch;h=5460617d1567657621107d895ee2dd83bc1f88f2
+with ChangeLog removed
+
+From 5460617d1567657621107d895ee2dd83bc1f88f2 Mon Sep 17 00:00:00 2001
+From: Paul Pluzhnikov <ppluzhnikov@google.com>
+Date: Tue, 8 May 2018 18:12:41 -0700
+Subject: [PATCH] Fix BZ 22786: integer addition overflow may cause stack
+ buffer overflow when realpath() input length is close to SSIZE_MAX.
+
+2018-05-09 Paul Pluzhnikov <ppluzhnikov@google.com>
+
+ [BZ #22786]
+ * stdlib/canonicalize.c (__realpath): Fix overflow in path length
+ computation.
+ * stdlib/Makefile (test-bz22786): New test.
+ * stdlib/test-bz22786.c: New test.
+---
+ ChangeLog | 8 +++++
+ stdlib/Makefile | 2 +-
+ stdlib/canonicalize.c | 2 +-
+ stdlib/test-bz22786.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++
+ 4 files changed, 100 insertions(+), 2 deletions(-)
+ create mode 100644 stdlib/test-bz22786.c
+
+diff --git a/stdlib/Makefile b/stdlib/Makefile
+index af1643c..1ddb1f9 100644
+--- a/stdlib/Makefile
++++ b/stdlib/Makefile
+@@ -84,7 +84,7 @@ tests := tst-strtol tst-strtod testmb testrand testsort testdiv \
+ tst-cxa_atexit tst-on_exit test-atexit-race \
+ test-at_quick_exit-race test-cxa_atexit-race \
+ test-on_exit-race test-dlclose-exit-race \
+- tst-makecontext-align
++ tst-makecontext-align test-bz22786
+
+ tests-internal := tst-strtod1i tst-strtod3 tst-strtod4 tst-strtod5i \
+ tst-tls-atexit tst-tls-atexit-nodelete
+diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c
+index 4135f3f..390fb43 100644
+--- a/stdlib/canonicalize.c
++++ b/stdlib/canonicalize.c
+@@ -181,7 +181,7 @@ __realpath (const char *name, char *resolved)
+ extra_buf = __alloca (path_max);
+
+ len = strlen (end);
+- if ((long int) (n + len) >= path_max)
++ if (path_max - n <= len)
+ {
+ __set_errno (ENAMETOOLONG);
+ goto error;
+diff --git a/stdlib/test-bz22786.c b/stdlib/test-bz22786.c
+new file mode 100644
+index 0000000..e7837f9
+--- /dev/null
++++ b/stdlib/test-bz22786.c
+@@ -0,0 +1,90 @@
++/* Bug 22786: test for buffer overflow in realpath.
++ Copyright (C) 2018 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
++
++/* This file must be run from within a directory called "stdlib". */
++
++#include <errno.h>
++#include <limits.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++#include <sys/stat.h>
++#include <sys/types.h>
++#include <support/test-driver.h>
++#include <libc-diag.h>
++
++static int
++do_test (void)
++{
++ const char dir[] = "bz22786";
++ const char lnk[] = "bz22786/symlink";
++
++ rmdir (dir);
++ if (mkdir (dir, 0755) != 0 && errno != EEXIST)
++ {
++ printf ("mkdir %s: %m\n", dir);
++ return EXIT_FAILURE;
++ }
++ if (symlink (".", lnk) != 0 && errno != EEXIST)
++ {
++ printf ("symlink (%s, %s): %m\n", dir, lnk);
++ return EXIT_FAILURE;
++ }
++
++ const size_t path_len = (size_t) INT_MAX + 1;
++
++ DIAG_PUSH_NEEDS_COMMENT;
++#if __GNUC_PREREQ (7, 0)
++ /* GCC 7 warns about too-large allocations; here we need such
++ allocation to succeed for the test to work. */
++ DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than=");
++#endif
++ char *path = malloc (path_len);
++ DIAG_POP_NEEDS_COMMENT;
++
++ if (path == NULL)
++ {
++ printf ("malloc (%zu): %m\n", path_len);
++ return EXIT_UNSUPPORTED;
++ }
++
++ /* Construct very long path = "bz22786/symlink/aaaa....." */
++ char *p = mempcpy (path, lnk, sizeof (lnk) - 1);
++ *(p++) = '/';
++ memset (p, 'a', path_len - (path - p) - 2);
++ p[path_len - (path - p) - 1] = '\0';
++
++ /* This call crashes before the fix for bz22786 on 32-bit platforms. */
++ p = realpath (path, NULL);
++
++ if (p != NULL || errno != ENAMETOOLONG)
++ {
++ printf ("realpath: %s (%m)", p);
++ return EXIT_FAILURE;
++ }
++
++ /* Cleanup. */
++ unlink (lnk);
++ rmdir (dir);
++
++ return 0;
++}
++
++#define TEST_FUNCTION do_test
++#include <support/test-driver.c>
+--
+2.9.3
+
diff --git a/gnu/packages/patches/glibc-CVE-2018-11237.patch b/gnu/packages/patches/glibc-CVE-2018-11237.patch
new file mode 100644
index 0000000000..8a7c604ecd
--- /dev/null
+++ b/gnu/packages/patches/glibc-CVE-2018-11237.patch
@@ -0,0 +1,55 @@
+https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=patch;h=9aaaab7c6e4176e61c59b0a63c6ba906d875dc0e
+with the ChangeLog removed
+
+From 9aaaab7c6e4176e61c59b0a63c6ba906d875dc0e Mon Sep 17 00:00:00 2001
+From: Andreas Schwab <schwab@suse.de>
+Date: Tue, 22 May 2018 10:37:59 +0200
+Subject: [PATCH] Don't write beyond destination in
+ __mempcpy_avx512_no_vzeroupper (bug 23196)
+
+When compiled as mempcpy, the return value is the end of the destination
+buffer, thus it cannot be used to refer to the start of it.
+---
+ ChangeLog | 9 +++++++++
+ string/test-mempcpy.c | 1 +
+ sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S | 5 +++--
+ 3 files changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/string/test-mempcpy.c b/string/test-mempcpy.c
+index c08fba8..d98ecdd 100644
+--- a/string/test-mempcpy.c
++++ b/string/test-mempcpy.c
+@@ -18,6 +18,7 @@
+ <http://www.gnu.org/licenses/>. */
+
+ #define MEMCPY_RESULT(dst, len) (dst) + (len)
++#define MIN_PAGE_SIZE 131072
+ #define TEST_MAIN
+ #define TEST_NAME "mempcpy"
+ #include "test-string.h"
+diff --git a/sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S b/sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S
+index 23c0f7a..effc3ac 100644
+--- a/sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S
++++ b/sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S
+@@ -336,6 +336,7 @@ L(preloop_large):
+ vmovups (%rsi), %zmm4
+ vmovups 0x40(%rsi), %zmm5
+
++ mov %rdi, %r11
+ /* Align destination for access with non-temporal stores in the loop. */
+ mov %rdi, %r8
+ and $-0x80, %rdi
+@@ -366,8 +367,8 @@ L(gobble_256bytes_nt_loop):
+ cmp $256, %rdx
+ ja L(gobble_256bytes_nt_loop)
+ sfence
+- vmovups %zmm4, (%rax)
+- vmovups %zmm5, 0x40(%rax)
++ vmovups %zmm4, (%r11)
++ vmovups %zmm5, 0x40(%r11)
+ jmp L(check)
+
+ L(preloop_large_bkw):
+--
+2.9.3
+
diff --git a/gnu/packages/patches/gnome-shell-theme.patch b/gnu/packages/patches/gnome-shell-theme.patch
new file mode 100644
index 0000000000..fc7f7caf0f
--- /dev/null
+++ b/gnu/packages/patches/gnome-shell-theme.patch
@@ -0,0 +1,53 @@
+Adjust GNOME-Shell so that it uses a Guix theme by default.
+
+Patch by Ludovic Courtès <ludo@gnu.org>.
+
+diff --git a/data/gnome-shell-theme.gresource.xml b/data/gnome-shell-theme.gresource.xml
+index 76aeaa5..8eaf32e 100644
+--- a/data/gnome-shell-theme.gresource.xml
++++ b/data/gnome-shell-theme.gresource.xml
+@@ -22,6 +22,8 @@
+ <file>no-events.svg</file>
+ <file>no-notifications.svg</file>
+ <file>noise-texture.png</file>
++ <file>guix-background.png</file>
++ <file>guix-logo.png</file>
+ <file>pad-osd.css</file>
+ <file>page-indicator-active.svg</file>
+ <file>page-indicator-inactive.svg</file>
+diff --git a/data/theme/gnome-shell-sass/_common.scss b/data/theme/gnome-shell-sass/_common.scss
+index 54d9f39..b9badd0 100644
+--- a/data/theme/gnome-shell-sass/_common.scss
++++ b/data/theme/gnome-shell-sass/_common.scss
+@@ -1742,7 +1742,16 @@ $legacy_icon_size: 24px;
+
+ }
+
+- .login-dialog-logo-bin { padding: 24px 0px; }
++ .login-dialog-logo-bin {
++ /* Make it a bit narrower than .login-dialog-user-list. */
++ width: 12em;
++ height: 8em;
++ background: url(resource:///org/gnome/shell/theme/guix-logo.png);
++ background-color: transparent;
++ background-repeat: no-repeat;
++ background-size: contain;
++ background-position: center; }
++
+ .login-dialog-banner { color: darken($osd_fg_color,10%); }
+ .login-dialog-button-box { spacing: 5px; }
+ .login-dialog-message-warning { color: $warning_color; }
+@@ -1889,9 +1898,10 @@ $legacy_icon_size: 24px;
+ }
+
+ #lockDialogGroup {
+- background: #2e3436 url(resource:///org/gnome/shell/theme/noise-texture.png);
+- background-repeat: repeat;
+-}
++ background: #2e3436 url(resource:///org/gnome/shell/theme/guix-background.png);
++ background-repeat: no-repeat;
++ background-size: cover;
++ background-position: center; }
+
+ #screenShieldNotifications {
+ StButton#vhandle, StButton#hhandle {
diff --git a/gnu/packages/patches/kio-search-smbd-on-PATH.patch b/gnu/packages/patches/kio-search-smbd-on-PATH.patch
index 47e20cfc0b..55535ffa11 100644
--- a/gnu/packages/patches/kio-search-smbd-on-PATH.patch
+++ b/gnu/packages/patches/kio-search-smbd-on-PATH.patch
@@ -16,7 +16,7 @@ pkgs/development/libraries/kde-frameworks/kio/samba-search-path.patch
+ QLatin1Char pathSep(':');
+ QStringList paths = QFile::decodeName(pathEnv).split(pathSep, QString::SkipEmptyParts);
+ for (QStringList::iterator it = paths.begin(); it != paths.end(); ++it) {
-+ it->append("/smbd");
++ it->append(QStringLiteral("/smbd"));
+ if (QFile::exists(*it)) {
+ return true;
+ }
diff --git a/gnu/packages/patches/ledger-revert-boost-python-fix.patch b/gnu/packages/patches/ledger-revert-boost-python-fix.patch
deleted file mode 100644
index 99f48f6e46..0000000000
--- a/gnu/packages/patches/ledger-revert-boost-python-fix.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-From 01220484f428a447e9b00e071a0d85185f30e1de Mon Sep 17 00:00:00 2001
-From: Alexis Hildebrandt <afh@surryhill.net>
-Date: Wed, 22 Jun 2016 15:43:37 +0200
-Subject: [PATCH] Revert "[python] Add fix for Boost.Python compile errors"
-
-This reverts commit 11590e134eafa768ccc4a171cc7fb216e906095f.
----
- src/py_commodity.cc | 3 ---
- src/py_journal.cc | 3 ---
- 2 files changed, 6 deletions(-)
-
-diff --git a/src/py_commodity.cc b/src/py_commodity.cc
-index 5aafa6c..c457e64 100644
---- a/src/py_commodity.cc
-+++ b/src/py_commodity.cc
-@@ -243,9 +243,6 @@ namespace {
-
- void export_commodity()
- {
--#if BOOST_VERSION >= 106000
-- python::register_ptr_to_python< shared_ptr<commodity_pool_t> >();
--#endif
- class_< commodity_pool_t, shared_ptr<commodity_pool_t>,
- boost::noncopyable > ("CommodityPool", no_init)
- .add_property("null_commodity",
-diff --git a/src/py_journal.cc b/src/py_journal.cc
-index c1c38a9..879f954 100644
---- a/src/py_journal.cc
-+++ b/src/py_journal.cc
-@@ -232,9 +232,6 @@ void export_journal()
- boost::noncopyable >("PostHandler")
- ;
-
--#if BOOST_VERSION >= 106000
-- python::register_ptr_to_python< shared_ptr<collector_wrapper> >();
--#endif
- class_< collector_wrapper, shared_ptr<collector_wrapper>,
- boost::noncopyable >("PostCollectorWrapper", no_init)
- .def("__len__", &collector_wrapper::length)
diff --git a/gnu/packages/patches/red-eclipse-remove-gamma-name-hack.patch b/gnu/packages/patches/red-eclipse-remove-gamma-name-hack.patch
new file mode 100644
index 0000000000..573920cb99
--- /dev/null
+++ b/gnu/packages/patches/red-eclipse-remove-gamma-name-hack.patch
@@ -0,0 +1,52 @@
+From b16b4963c1ad81bb9ef784bc4913a4c8ab5f1bb4 Mon Sep 17 00:00:00 2001
+From: Lee Salzman <lsalzman@gmail.com>
+Date: Tue, 12 Sep 2017 14:45:10 -0400
+Subject: [PATCH] remove gamma name hack
+
+---
+ src/engine/main.cpp | 6 +++---
+ src/shared/cube.h | 8 --------
+ 2 files changed, 3 insertions(+), 11 deletions(-)
+
+diff --git a/src/engine/main.cpp b/src/engine/main.cpp
+index 1032004d..77c9233a 100644
+--- a/src/engine/main.cpp
++++ b/src/engine/main.cpp
+@@ -278,10 +278,10 @@ static void setgamma(int val)
+ }
+
+ static int curgamma = 100;
+-VARF(IDF_PERSIST, gamma, 30, 100, 300,
++VARFN(IDF_PERSIST, gamma, reqgamma, 30, 100, 300,
+ {
+- if(initing || gamma == curgamma) return;
+- curgamma = gamma;
++ if(initing || reqgamma == curgamma) return;
++ curgamma = reqgamma;
+ setgamma(curgamma);
+ });
+
+diff --git a/src/shared/cube.h b/src/shared/cube.h
+index 3864c492..7ff5e267 100644
+--- a/src/shared/cube.h
++++ b/src/shared/cube.h
+@@ -3,19 +3,11 @@
+
+ #define _FILE_OFFSET_BITS 64
+
+-#ifdef __GNUC__
+-#define gamma __gamma
+-#endif
+-
+ #ifdef WIN32
+ #define _USE_MATH_DEFINES
+ #endif
+ #include <math.h>
+
+-#ifdef __GNUC__
+-#undef gamma
+-#endif
+-
+ #include <string.h>
+ #include <stdio.h>
+ #include <stdlib.h>
diff --git a/gnu/packages/patches/runc-CVE-2019-5736.patch b/gnu/packages/patches/runc-CVE-2019-5736.patch
new file mode 100644
index 0000000000..f629fcbfb4
--- /dev/null
+++ b/gnu/packages/patches/runc-CVE-2019-5736.patch
@@ -0,0 +1,343 @@
+Fix CVE-2019-5736:
+
+https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-5736
+https://seclists.org/oss-sec/2019/q1/119
+
+Patch copied from upstream source repository:
+
+https://github.com/opencontainers/runc/commit/0a8e4117e7f715d5fbeef398405813ce8e88558b
+
+From 0a8e4117e7f715d5fbeef398405813ce8e88558b Mon Sep 17 00:00:00 2001
+From: Aleksa Sarai <asarai@suse.de>
+Date: Wed, 9 Jan 2019 13:40:01 +1100
+Subject: [PATCH] nsenter: clone /proc/self/exe to avoid exposing host binary
+ to container
+
+There are quite a few circumstances where /proc/self/exe pointing to a
+pretty important container binary is a _bad_ thing, so to avoid this we
+have to make a copy (preferably doing self-clean-up and not being
+writeable).
+
+We require memfd_create(2) -- though there is an O_TMPFILE fallback --
+but we can always extend this to use a scratch MNT_DETACH overlayfs or
+tmpfs. The main downside to this approach is no page-cache sharing for
+the runc binary (which overlayfs would give us) but this is far less
+complicated.
+
+This is only done during nsenter so that it happens transparently to the
+Go code, and any libcontainer users benefit from it. This also makes
+ExtraFiles and --preserve-fds handling trivial (because we don't need to
+worry about it).
+
+Fixes: CVE-2019-5736
+Co-developed-by: Christian Brauner <christian.brauner@ubuntu.com>
+Signed-off-by: Aleksa Sarai <asarai@suse.de>
+---
+ libcontainer/nsenter/cloned_binary.c | 268 +++++++++++++++++++++++++++
+ libcontainer/nsenter/nsexec.c | 11 ++
+ 2 files changed, 279 insertions(+)
+ create mode 100644 libcontainer/nsenter/cloned_binary.c
+
+diff --git a/libcontainer/nsenter/cloned_binary.c b/libcontainer/nsenter/cloned_binary.c
+new file mode 100644
+index 000000000..c8a42c23f
+--- /dev/null
++++ b/libcontainer/nsenter/cloned_binary.c
+@@ -0,0 +1,268 @@
++/*
++ * Copyright (C) 2019 Aleksa Sarai <cyphar@cyphar.com>
++ * Copyright (C) 2019 SUSE LLC
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++#define _GNU_SOURCE
++#include <unistd.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <stdbool.h>
++#include <string.h>
++#include <limits.h>
++#include <fcntl.h>
++#include <errno.h>
++
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <sys/vfs.h>
++#include <sys/mman.h>
++#include <sys/sendfile.h>
++#include <sys/syscall.h>
++
++/* Use our own wrapper for memfd_create. */
++#if !defined(SYS_memfd_create) && defined(__NR_memfd_create)
++# define SYS_memfd_create __NR_memfd_create
++#endif
++#ifdef SYS_memfd_create
++# define HAVE_MEMFD_CREATE
++/* memfd_create(2) flags -- copied from <linux/memfd.h>. */
++# ifndef MFD_CLOEXEC
++# define MFD_CLOEXEC 0x0001U
++# define MFD_ALLOW_SEALING 0x0002U
++# endif
++int memfd_create(const char *name, unsigned int flags)
++{
++ return syscall(SYS_memfd_create, name, flags);
++}
++#endif
++
++/* This comes directly from <linux/fcntl.h>. */
++#ifndef F_LINUX_SPECIFIC_BASE
++# define F_LINUX_SPECIFIC_BASE 1024
++#endif
++#ifndef F_ADD_SEALS
++# define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
++# define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
++#endif
++#ifndef F_SEAL_SEAL
++# define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
++# define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
++# define F_SEAL_GROW 0x0004 /* prevent file from growing */
++# define F_SEAL_WRITE 0x0008 /* prevent writes */
++#endif
++
++#define RUNC_SENDFILE_MAX 0x7FFFF000 /* sendfile(2) is limited to 2GB. */
++#ifdef HAVE_MEMFD_CREATE
++# define RUNC_MEMFD_COMMENT "runc_cloned:/proc/self/exe"
++# define RUNC_MEMFD_SEALS \
++ (F_SEAL_SEAL | F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE)
++#endif
++
++static void *must_realloc(void *ptr, size_t size)
++{
++ void *old = ptr;
++ do {
++ ptr = realloc(old, size);
++ } while(!ptr);
++ return ptr;
++}
++
++/*
++ * Verify whether we are currently in a self-cloned program (namely, is
++ * /proc/self/exe a memfd). F_GET_SEALS will only succeed for memfds (or rather
++ * for shmem files), and we want to be sure it's actually sealed.
++ */
++static int is_self_cloned(void)
++{
++ int fd, ret, is_cloned = 0;
++
++ fd = open("/proc/self/exe", O_RDONLY|O_CLOEXEC);
++ if (fd < 0)
++ return -ENOTRECOVERABLE;
++
++#ifdef HAVE_MEMFD_CREATE
++ ret = fcntl(fd, F_GET_SEALS);
++ is_cloned = (ret == RUNC_MEMFD_SEALS);
++#else
++ struct stat statbuf = {0};
++ ret = fstat(fd, &statbuf);
++ if (ret >= 0)
++ is_cloned = (statbuf.st_nlink == 0);
++#endif
++ close(fd);
++ return is_cloned;
++}
++
++/*
++ * Basic wrapper around mmap(2) that gives you the file length so you can
++ * safely treat it as an ordinary buffer. Only gives you read access.
++ */
++static char *read_file(char *path, size_t *length)
++{
++ int fd;
++ char buf[4096], *copy = NULL;
++
++ if (!length)
++ return NULL;
++
++ fd = open(path, O_RDONLY | O_CLOEXEC);
++ if (fd < 0)
++ return NULL;
++
++ *length = 0;
++ for (;;) {
++ int n;
++
++ n = read(fd, buf, sizeof(buf));
++ if (n < 0)
++ goto error;
++ if (!n)
++ break;
++
++ copy = must_realloc(copy, (*length + n) * sizeof(*copy));
++ memcpy(copy + *length, buf, n);
++ *length += n;
++ }
++ close(fd);
++ return copy;
++
++error:
++ close(fd);
++ free(copy);
++ return NULL;
++}
++
++/*
++ * A poor-man's version of "xargs -0". Basically parses a given block of
++ * NUL-delimited data, within the given length and adds a pointer to each entry
++ * to the array of pointers.
++ */
++static int parse_xargs(char *data, int data_length, char ***output)
++{
++ int num = 0;
++ char *cur = data;
++
++ if (!data || *output != NULL)
++ return -1;
++
++ while (cur < data + data_length) {
++ num++;
++ *output = must_realloc(*output, (num + 1) * sizeof(**output));
++ (*output)[num - 1] = cur;
++ cur += strlen(cur) + 1;
++ }
++ (*output)[num] = NULL;
++ return num;
++}
++
++/*
++ * "Parse" out argv and envp from /proc/self/cmdline and /proc/self/environ.
++ * This is necessary because we are running in a context where we don't have a
++ * main() that we can just get the arguments from.
++ */
++static int fetchve(char ***argv, char ***envp)
++{
++ char *cmdline = NULL, *environ = NULL;
++ size_t cmdline_size, environ_size;
++
++ cmdline = read_file("/proc/self/cmdline", &cmdline_size);
++ if (!cmdline)
++ goto error;
++ environ = read_file("/proc/self/environ", &environ_size);
++ if (!environ)
++ goto error;
++
++ if (parse_xargs(cmdline, cmdline_size, argv) <= 0)
++ goto error;
++ if (parse_xargs(environ, environ_size, envp) <= 0)
++ goto error;
++
++ return 0;
++
++error:
++ free(environ);
++ free(cmdline);
++ return -EINVAL;
++}
++
++static int clone_binary(void)
++{
++ int binfd, memfd;
++ ssize_t sent = 0;
++
++#ifdef HAVE_MEMFD_CREATE
++ memfd = memfd_create(RUNC_MEMFD_COMMENT, MFD_CLOEXEC | MFD_ALLOW_SEALING);
++#else
++ memfd = open("/tmp", O_TMPFILE | O_EXCL | O_RDWR | O_CLOEXEC, 0711);
++#endif
++ if (memfd < 0)
++ return -ENOTRECOVERABLE;
++
++ binfd = open("/proc/self/exe", O_RDONLY | O_CLOEXEC);
++ if (binfd < 0)
++ goto error;
++
++ sent = sendfile(memfd, binfd, NULL, RUNC_SENDFILE_MAX);
++ close(binfd);
++ if (sent < 0)
++ goto error;
++
++#ifdef HAVE_MEMFD_CREATE
++ int err = fcntl(memfd, F_ADD_SEALS, RUNC_MEMFD_SEALS);
++ if (err < 0)
++ goto error;
++#else
++ /* Need to re-open "memfd" as read-only to avoid execve(2) giving -EXTBUSY. */
++ int newfd;
++ char *fdpath = NULL;
++
++ if (asprintf(&fdpath, "/proc/self/fd/%d", memfd) < 0)
++ goto error;
++ newfd = open(fdpath, O_RDONLY | O_CLOEXEC);
++ free(fdpath);
++ if (newfd < 0)
++ goto error;
++
++ close(memfd);
++ memfd = newfd;
++#endif
++ return memfd;
++
++error:
++ close(memfd);
++ return -EIO;
++}
++
++int ensure_cloned_binary(void)
++{
++ int execfd;
++ char **argv = NULL, **envp = NULL;
++
++ /* Check that we're not self-cloned, and if we are then bail. */
++ int cloned = is_self_cloned();
++ if (cloned > 0 || cloned == -ENOTRECOVERABLE)
++ return cloned;
++
++ if (fetchve(&argv, &envp) < 0)
++ return -EINVAL;
++
++ execfd = clone_binary();
++ if (execfd < 0)
++ return -EIO;
++
++ fexecve(execfd, argv, envp);
++ return -ENOEXEC;
++}
+diff --git a/libcontainer/nsenter/nsexec.c b/libcontainer/nsenter/nsexec.c
+index 28269dfc0..7750af35e 100644
+--- a/libcontainer/nsenter/nsexec.c
++++ b/libcontainer/nsenter/nsexec.c
+@@ -534,6 +534,9 @@ void join_namespaces(char *nslist)
+ free(namespaces);
+ }
+
++/* Defined in cloned_binary.c. */
++extern int ensure_cloned_binary(void);
++
+ void nsexec(void)
+ {
+ int pipenum;
+@@ -549,6 +552,14 @@ void nsexec(void)
+ if (pipenum == -1)
+ return;
+
++ /*
++ * We need to re-exec if we are not in a cloned binary. This is necessary
++ * to ensure that containers won't be able to access the host binary
++ * through /proc/self/exe. See CVE-2019-5736.
++ */
++ if (ensure_cloned_binary() < 0)
++ bail("could not ensure we are a cloned binary");
++
+ /* Parse all of the netlink configuration. */
+ nl_parse(pipenum, &config);
+
diff --git a/gnu/packages/patches/scalapack-blacs-mpi-deprecations.patch b/gnu/packages/patches/scalapack-blacs-mpi-deprecations.patch
new file mode 100644
index 0000000000..6ec1b8f21f
--- /dev/null
+++ b/gnu/packages/patches/scalapack-blacs-mpi-deprecations.patch
@@ -0,0 +1,170 @@
+From f11c3f094ed5ca727ec819983425b6641db8227c Mon Sep 17 00:00:00 2001
+From: Eric Bavier <bavier@member.fsf.org>
+Date: Wed, 13 Feb 2019 09:32:11 -0600
+Subject: [PATCH] BLACS: Remove use of long-deprecated MPI1 functions.
+
+* BLACS/SRC/blacs_get_.c: 'MPI_Attr_get' -> 'MPI_Comm_get_attr'.
+* BLACS/SRC/cgamn2d_.c, BLACS/SRC/cgamx2d_.c, BLACS/SRC/dgamn2d_.c,
+BLACS/SRC/dgamx2d_.c, BLACS/SRC/igamn2d_.c, BLACS/SRC/igamx2d_.c,
+BLACS/SRC/sgamn2d_.c, BLACS/SRC/sgamx2d_.c, BLACS/SRC/zgamn2d_.c,
+BLACS/SRC/zgamx2d_.c: 'MPI_Type_struct' -> 'MPI_Type_create_struct'.
+---
+ BLACS/SRC/blacs_get_.c | 2 +-
+ BLACS/SRC/cgamn2d_.c | 2 +-
+ BLACS/SRC/cgamx2d_.c | 2 +-
+ BLACS/SRC/dgamn2d_.c | 2 +-
+ BLACS/SRC/dgamx2d_.c | 2 +-
+ BLACS/SRC/igamn2d_.c | 2 +-
+ BLACS/SRC/igamx2d_.c | 2 +-
+ BLACS/SRC/sgamn2d_.c | 2 +-
+ BLACS/SRC/sgamx2d_.c | 2 +-
+ BLACS/SRC/zgamn2d_.c | 2 +-
+ BLACS/SRC/zgamx2d_.c | 2 +-
+ 11 files changed, 11 insertions(+), 11 deletions(-)
+
+diff --git a/BLACS/SRC/blacs_get_.c b/BLACS/SRC/blacs_get_.c
+index e979767..d4b04cf 100644
+--- a/BLACS/SRC/blacs_get_.c
++++ b/BLACS/SRC/blacs_get_.c
+@@ -23,7 +23,7 @@ F_VOID_FUNC blacs_get_(int *ConTxt, int *what, int *val)
+ case SGET_MSGIDS:
+ if (BI_COMM_WORLD == NULL) Cblacs_pinfo(val, &val[1]);
+ iptr = &val[1];
+- ierr=MPI_Attr_get(MPI_COMM_WORLD, MPI_TAG_UB, (BVOID **) &iptr,val);
++ ierr=MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_TAG_UB, (BVOID **) &iptr,val);
+ val[0] = 0;
+ val[1] = *iptr;
+ break;
+diff --git a/BLACS/SRC/cgamn2d_.c b/BLACS/SRC/cgamn2d_.c
+index 2db6ccb..6958f32 100644
+--- a/BLACS/SRC/cgamn2d_.c
++++ b/BLACS/SRC/cgamn2d_.c
+@@ -221,7 +221,7 @@ F_VOID_FUNC cgamn2d_(int *ConTxt, F_CHAR scope, F_CHAR top, int *m, int *n,
+ {
+ #endif
+ i = 2;
+- ierr=MPI_Type_struct(i, len, disp, dtypes, &MyType);
++ ierr=MPI_Type_create_struct(i, len, disp, dtypes, &MyType);
+ ierr=MPI_Type_commit(&MyType);
+ bp->N = bp2->N = 1;
+ bp->dtype = bp2->dtype = MyType;
+diff --git a/BLACS/SRC/cgamx2d_.c b/BLACS/SRC/cgamx2d_.c
+index 707c0b6..f802d01 100644
+--- a/BLACS/SRC/cgamx2d_.c
++++ b/BLACS/SRC/cgamx2d_.c
+@@ -221,7 +221,7 @@ F_VOID_FUNC cgamx2d_(int *ConTxt, F_CHAR scope, F_CHAR top, int *m, int *n,
+ {
+ #endif
+ i = 2;
+- ierr=MPI_Type_struct(i, len, disp, dtypes, &MyType);
++ ierr=MPI_Type_create_struct(i, len, disp, dtypes, &MyType);
+ ierr=MPI_Type_commit(&MyType);
+ bp->N = bp2->N = 1;
+ bp->dtype = bp2->dtype = MyType;
+diff --git a/BLACS/SRC/dgamn2d_.c b/BLACS/SRC/dgamn2d_.c
+index dff23b4..a2627ac 100644
+--- a/BLACS/SRC/dgamn2d_.c
++++ b/BLACS/SRC/dgamn2d_.c
+@@ -221,7 +221,7 @@ F_VOID_FUNC dgamn2d_(int *ConTxt, F_CHAR scope, F_CHAR top, int *m, int *n,
+ {
+ #endif
+ i = 2;
+- ierr=MPI_Type_struct(i, len, disp, dtypes, &MyType);
++ ierr=MPI_Type_create_struct(i, len, disp, dtypes, &MyType);
+ ierr=MPI_Type_commit(&MyType);
+ bp->N = bp2->N = 1;
+ bp->dtype = bp2->dtype = MyType;
+diff --git a/BLACS/SRC/dgamx2d_.c b/BLACS/SRC/dgamx2d_.c
+index a51f731..2a644d0 100644
+--- a/BLACS/SRC/dgamx2d_.c
++++ b/BLACS/SRC/dgamx2d_.c
+@@ -221,7 +221,7 @@ F_VOID_FUNC dgamx2d_(int *ConTxt, F_CHAR scope, F_CHAR top, int *m, int *n,
+ {
+ #endif
+ i = 2;
+- ierr=MPI_Type_struct(i, len, disp, dtypes, &MyType);
++ ierr=MPI_Type_create_struct(i, len, disp, dtypes, &MyType);
+ ierr=MPI_Type_commit(&MyType);
+ bp->N = bp2->N = 1;
+ bp->dtype = bp2->dtype = MyType;
+diff --git a/BLACS/SRC/igamn2d_.c b/BLACS/SRC/igamn2d_.c
+index 16bc003..f6a7859 100644
+--- a/BLACS/SRC/igamn2d_.c
++++ b/BLACS/SRC/igamn2d_.c
+@@ -218,7 +218,7 @@ F_VOID_FUNC igamn2d_(int *ConTxt, F_CHAR scope, F_CHAR top, int *m, int *n,
+ {
+ #endif
+ i = 2;
+- ierr=MPI_Type_struct(i, len, disp, dtypes, &MyType);
++ ierr=MPI_Type_create_struct(i, len, disp, dtypes, &MyType);
+ ierr=MPI_Type_commit(&MyType);
+ bp->N = bp2->N = 1;
+ bp->dtype = bp2->dtype = MyType;
+diff --git a/BLACS/SRC/igamx2d_.c b/BLACS/SRC/igamx2d_.c
+index 8165cbe..a7cfcc6 100644
+--- a/BLACS/SRC/igamx2d_.c
++++ b/BLACS/SRC/igamx2d_.c
+@@ -218,7 +218,7 @@ F_VOID_FUNC igamx2d_(int *ConTxt, F_CHAR scope, F_CHAR top, int *m, int *n,
+ {
+ #endif
+ i = 2;
+- ierr=MPI_Type_struct(i, len, disp, dtypes, &MyType);
++ ierr=MPI_Type_create_struct(i, len, disp, dtypes, &MyType);
+ ierr=MPI_Type_commit(&MyType);
+ bp->N = bp2->N = 1;
+ bp->dtype = bp2->dtype = MyType;
+diff --git a/BLACS/SRC/sgamn2d_.c b/BLACS/SRC/sgamn2d_.c
+index d6c95e5..569c797 100644
+--- a/BLACS/SRC/sgamn2d_.c
++++ b/BLACS/SRC/sgamn2d_.c
+@@ -221,7 +221,7 @@ F_VOID_FUNC sgamn2d_(int *ConTxt, F_CHAR scope, F_CHAR top, int *m, int *n,
+ {
+ #endif
+ i = 2;
+- ierr=MPI_Type_struct(i, len, disp, dtypes, &MyType);
++ ierr=MPI_Type_create_struct(i, len, disp, dtypes, &MyType);
+ ierr=MPI_Type_commit(&MyType);
+ bp->N = bp2->N = 1;
+ bp->dtype = bp2->dtype = MyType;
+diff --git a/BLACS/SRC/sgamx2d_.c b/BLACS/SRC/sgamx2d_.c
+index 4b0af6f..8897ece 100644
+--- a/BLACS/SRC/sgamx2d_.c
++++ b/BLACS/SRC/sgamx2d_.c
+@@ -221,7 +221,7 @@ F_VOID_FUNC sgamx2d_(int *ConTxt, F_CHAR scope, F_CHAR top, int *m, int *n,
+ {
+ #endif
+ i = 2;
+- ierr=MPI_Type_struct(i, len, disp, dtypes, &MyType);
++ ierr=MPI_Type_create_struct(i, len, disp, dtypes, &MyType);
+ ierr=MPI_Type_commit(&MyType);
+ bp->N = bp2->N = 1;
+ bp->dtype = bp2->dtype = MyType;
+diff --git a/BLACS/SRC/zgamn2d_.c b/BLACS/SRC/zgamn2d_.c
+index 9de2b23..37897df 100644
+--- a/BLACS/SRC/zgamn2d_.c
++++ b/BLACS/SRC/zgamn2d_.c
+@@ -221,7 +221,7 @@ F_VOID_FUNC zgamn2d_(int *ConTxt, F_CHAR scope, F_CHAR top, int *m, int *n,
+ {
+ #endif
+ i = 2;
+- ierr=MPI_Type_struct(i, len, disp, dtypes, &MyType);
++ ierr=MPI_Type_create_struct(i, len, disp, dtypes, &MyType);
+ ierr=MPI_Type_commit(&MyType);
+ bp->N = bp2->N = 1;
+ bp->dtype = bp2->dtype = MyType;
+diff --git a/BLACS/SRC/zgamx2d_.c b/BLACS/SRC/zgamx2d_.c
+index 414c381..0e9d474 100644
+--- a/BLACS/SRC/zgamx2d_.c
++++ b/BLACS/SRC/zgamx2d_.c
+@@ -221,7 +221,7 @@ F_VOID_FUNC zgamx2d_(int *ConTxt, F_CHAR scope, F_CHAR top, int *m, int *n,
+ {
+ #endif
+ i = 2;
+- ierr=MPI_Type_struct(i, len, disp, dtypes, &MyType);
++ ierr=MPI_Type_create_struct(i, len, disp, dtypes, &MyType);
+ ierr=MPI_Type_commit(&MyType);
+ bp->N = bp2->N = 1;
+ bp->dtype = bp2->dtype = MyType;
+--
+2.20.1
+