From 84cca56fbd4c2605d60d8341a652c4f65b84aa44 Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Mon, 23 Nov 2020 14:13:30 +0100 Subject: [PATCH] sys-libs/libselinux: un-break build with >=glibc-2.30 Signed-off-by: Thilo Fromm --- ...fine-gettid-for-glibc-2.30-and-above.patch | 49 +++++++++++++++++++ .../sys-libs/libselinux/libselinux-2.4.ebuild | 3 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 sdk_container/src/third_party/coreos-overlay/sys-libs/libselinux/files/0008-do-not-define-gettid-for-glibc-2.30-and-above.patch diff --git a/sdk_container/src/third_party/coreos-overlay/sys-libs/libselinux/files/0008-do-not-define-gettid-for-glibc-2.30-and-above.patch b/sdk_container/src/third_party/coreos-overlay/sys-libs/libselinux/files/0008-do-not-define-gettid-for-glibc-2.30-and-above.patch new file mode 100644 index 0000000000..39a3139ef3 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/sys-libs/libselinux/files/0008-do-not-define-gettid-for-glibc-2.30-and-above.patch @@ -0,0 +1,49 @@ +See https://github.com/SELinuxProject/selinux/commit/707e4b8610733b5c9eaac0f00239778f3edb23c2 + +(original patch ported to work with Flatcar libselinux version) + +libselinux: Do not define gettid() if glibc >= 2.30 is used + +Since version 2.30 glibc implements gettid() system call wrapper, see +https://sourceware.org/bugzilla/show_bug.cgi?id=6399 + +Fixes: +cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I../include -D_GNU_SOURCE -DNO_ANDROID_BACKEND -c -o procattr.o procattr.c +procattr.c:28:14: error: static declaration of ‘gettid’ follows non-static declaration + 28 | static pid_t gettid(void) + | ^~~~~~ +In file included from /usr/include/unistd.h:1170, + from procattr.c:2: +/usr/include/bits/unistd_ext.h:34:16: note: previous declaration of ‘gettid’ was here + 34 | extern __pid_t gettid (void) __THROW; + | ^~~~~~ + +Signed-off-by: Petr Lautrbach + +--- a/src/procattr.c ++++ b/src/procattr.c +@@ -22,10 +22,24 @@ static pthread_key_t destructor_key; + static int destructor_key_initialized = 0; + static __thread char destructor_initialized; + ++/* Bionic and glibc >= 2.30 declare gettid() system call wrapper in unistd.h and ++ * has a definition for it */ ++#ifdef __BIONIC__ ++ #define OVERRIDE_GETTID 0 ++#elif !defined(__GLIBC_PREREQ) ++ #define OVERRIDE_GETTID 1 ++#elif !__GLIBC_PREREQ(2,30) ++ #define OVERRIDE_GETTID 1 ++#else ++ #define OVERRIDE_GETTID 0 ++#endif ++ ++#if OVERRIDE_GETTID + static pid_t gettid(void) + { + return syscall(__NR_gettid); + } ++#endif + + static void procattr_thread_destructor(void __attribute__((unused)) *unused) + { diff --git a/sdk_container/src/third_party/coreos-overlay/sys-libs/libselinux/libselinux-2.4.ebuild b/sdk_container/src/third_party/coreos-overlay/sys-libs/libselinux/libselinux-2.4.ebuild index 887196ca60..e6fb496c9f 100644 --- a/sdk_container/src/third_party/coreos-overlay/sys-libs/libselinux/libselinux-2.4.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/sys-libs/libselinux/libselinux-2.4.ebuild @@ -38,7 +38,8 @@ S="${WORKDIR}/${MY_P}" src_prepare() { epatch "${FILESDIR}/0005-use-ruby-include-with-rubylibver.patch" epatch "${FILESDIR}/0006-build-related-fixes-bug-500674.patch" - epatch "${FILESDIR}/0007-fix-setexeccon-on-exec.patch" + epatch "${FILESDIR}/0007-fix-setexeccon-on-exec.patch" + epatch "${FILESDIR}/0008-do-not-define-gettid-for-glibc-2.30-and-above.patch" epatch_user