Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/glibc/, sys-libs/glibc/files/
Date: Wed, 01 Dec 2021 14:29:01
Message-Id: 1638368923.16d8fcd2df5e1f0d11f507257b71f69a1031749f.sam@gentoo
1 commit: 16d8fcd2df5e1f0d11f507257b71f69a1031749f
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Mon Nov 29 21:03:34 2021 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Wed Dec 1 14:28:43 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=16d8fcd2
7
8 sys-libs/glibc: allow disabling clone3 sysflag (breaks older Electron)
9
10 Bug: https://bugs.gentoo.org/827386
11 Bug: https://bugs.gentoo.org/819045
12 Signed-off-by: Sam James <sam <AT> gentoo.org>
13 Closes: https://github.com/gentoo/gentoo/pull/23118
14 Signed-off-by: Sam James <sam <AT> gentoo.org>
15
16 .../files/glibc-2.34-disable-clone3-syscall.patch | 38 ++++++++++++++++++++++
17 sys-libs/glibc/glibc-2.34-r3.ebuild | 9 ++++-
18 sys-libs/glibc/metadata.xml | 1 +
19 3 files changed, 47 insertions(+), 1 deletion(-)
20
21 diff --git a/sys-libs/glibc/files/glibc-2.34-disable-clone3-syscall.patch b/sys-libs/glibc/files/glibc-2.34-disable-clone3-syscall.patch
22 new file mode 100644
23 index 000000000000..3c65a125c3b4
24 --- /dev/null
25 +++ b/sys-libs/glibc/files/glibc-2.34-disable-clone3-syscall.patch
26 @@ -0,0 +1,38 @@
27 +We're disabling clone3 for now _CONDITIONALLY_ (not by default) to allow
28 +compatibility with applications using older Electron.
29 +
30 +This was impacting e.g. Discord and Skype. This patch stops glibc from using
31 +clone3 internally (which is the only real use of it) and falls back to the old
32 +behaviour.
33 +
34 +Specifically, we want https://github.com/electron/electron/pull/31091
35 +to work its way downstream to various Electron applications.
36 +
37 +https://bugs.gentoo.org/819045
38 +https://bugs.gentoo.org/827386
39 +
40 +https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/glibc/plain/debian/patches/ubuntu/disable-clone3.patch
41 +
42 +This is the same as the patch that was considered but ultimately rejected
43 +for 2.34 because Docker got sorted out in time:
44 +https://patchwork.ozlabs.org/project/glibc/patch/87eebkf8ph.fsf@××××××××××××××××××××.com/.
45 +--- a/sysdeps/unix/sysv/linux/clone-internal.c
46 ++++ b/sysdeps/unix/sysv/linux/clone-internal.c
47 +@@ -48,17 +48,6 @@
48 + int (*func) (void *arg), void *arg)
49 + {
50 + int ret;
51 +-#ifdef HAVE_CLONE3_WRAPPER
52 +- /* Try clone3 first. */
53 +- int saved_errno = errno;
54 +- ret = __clone3 (cl_args, sizeof (*cl_args), func, arg);
55 +- if (ret != -1 || errno != ENOSYS)
56 +- return ret;
57 +-
58 +- /* NB: Restore errno since errno may be checked against non-zero
59 +- return value. */
60 +- __set_errno (saved_errno);
61 +-#endif
62 +
63 + /* Map clone3 arguments to clone arguments. NB: No need to check
64 + invalid clone3 specific bits in flags nor exit_signal since this
65
66 diff --git a/sys-libs/glibc/glibc-2.34-r3.ebuild b/sys-libs/glibc/glibc-2.34-r3.ebuild
67 index c06bdbcbb4b8..d98d8a72fba5 100644
68 --- a/sys-libs/glibc/glibc-2.34-r3.ebuild
69 +++ b/sys-libs/glibc/glibc-2.34-r3.ebuild
70 @@ -46,7 +46,7 @@ SRC_URI+=" https://gitweb.gentoo.org/proj/locale-gen.git/snapshot/locale-gen-${L
71 SRC_URI+=" multilib-bootstrap? ( https://dev.gentoo.org/~dilfridge/distfiles/gcc-multilib-bootstrap-${GCC_BOOTSTRAP_VER}.tar.xz )"
72 SRC_URI+=" systemd? ( https://gitweb.gentoo.org/proj/toolchain/glibc-systemd.git/snapshot/glibc-systemd-${GLIBC_SYSTEMD_VER}.tar.gz )"
73
74 -IUSE="audit caps cet compile-locales +crypt custom-cflags doc gd headers-only +multiarch multilib multilib-bootstrap nscd profile selinux +ssp +static-libs static-pie suid systemd systemtap test vanilla"
75 +IUSE="audit caps cet +clone3 compile-locales +crypt custom-cflags doc gd headers-only +multiarch multilib multilib-bootstrap nscd profile selinux +ssp +static-libs static-pie suid systemd systemtap test vanilla"
76
77 # Minimum kernel version that glibc requires
78 MIN_KERN_VER="3.2.0"
79 @@ -791,6 +791,13 @@ src_prepare() {
80 einfo "Done."
81 fi
82
83 + if ! use clone3 ; then
84 + elog "Disabling the clone3 syscall for compatibility with older Electron apps."
85 + elog "Please re-enable this flag before filing bugs!"
86 + # See e.g. bug #827386, bug #819045.
87 + eapply "${FILESDIR}"/${P}-disable-clone3-syscall.patch
88 + fi
89 +
90 default
91
92 gnuconfig_update
93
94 diff --git a/sys-libs/glibc/metadata.xml b/sys-libs/glibc/metadata.xml
95 index a87c547c6a07..613e58eff7ee 100644
96 --- a/sys-libs/glibc/metadata.xml
97 +++ b/sys-libs/glibc/metadata.xml
98 @@ -7,6 +7,7 @@
99 </maintainer>
100 <use>
101 <flag name="cet">Enable Intel Control-flow Enforcement Technology (needs binutils 2.29 and gcc 8)</flag>
102 + <flag name="clone3">Enable the new clone3 syscall within glibc. Can be disabled to allow compatibility with older Electron applications.</flag>
103 <flag name="compile-locales">build *all* locales in src_install; this is generally meant for stage building only as it ignores /etc/locale.gen file and can be pretty slow</flag>
104 <flag name="crypt">build and install libcrypt and crypt.h</flag>
105 <flag name="debug">When USE=hardened, allow fortify/stack violations to dump core (SIGABRT) and not kill self (SIGKILL)</flag>