Package: android-platform-external-libselinux
Version: 8.1.0+r23-2
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu focal ubuntu-patch

Hi,

This package currently FTBFS against glibc 2.30+ (2.30 is currently in
experimental) because it defines its own gettid(), which conflicts with
the one provided in the newer versions of glibc.

In Ubuntu, the attached patch was applied to achieve the following:

  * Import patch from upstream Git to fix FTBFS against glibc 2.30.

Thanks for considering the patch.

Logan

-- System Information:
Debian Release: bullseye/sid
  APT prefers focal
  APT policy: (500, 'focal')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.4.0-14-generic (SMP w/8 CPU cores)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru 
android-platform-external-libselinux-8.1.0+r23/debian/patches/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch
 
android-platform-external-libselinux-8.1.0+r23/debian/patches/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch
--- 
android-platform-external-libselinux-8.1.0+r23/debian/patches/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch
       1969-12-31 19:00:00.000000000 -0500
+++ 
android-platform-external-libselinux-8.1.0+r23/debian/patches/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch
       2020-02-23 22:08:04.000000000 -0500
@@ -0,0 +1,56 @@
+From 707e4b8610733b5c9eaac0f00239778f3edb23c2 Mon Sep 17 00:00:00 2001
+From: Petr Lautrbach <plaut...@redhat.com>
+Date: Mon, 11 Mar 2019 16:00:41 +0100
+Subject: [PATCH] libselinux: Do not define gettid() if glibc >= 2.30 is used
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+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 <plaut...@redhat.com>
+---
+ libselinux/src/procattr.c | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/libselinux/src/procattr.c b/libselinux/src/procattr.c
+index 48dd8aff..c6799ef2 100644
+--- a/libselinux/src/procattr.c
++++ b/libselinux/src/procattr.c
+@@ -22,8 +22,19 @@ static pthread_key_t destructor_key;
+ static int destructor_key_initialized = 0;
+ static __thread char destructor_initialized;
+ 
+-#ifndef __BIONIC__
+-/* Bionic declares this in unistd.h and has a definition for it */
++/* 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);
+-- 
+2.25.0
+
diff -Nru android-platform-external-libselinux-8.1.0+r23/debian/patches/series 
android-platform-external-libselinux-8.1.0+r23/debian/patches/series
--- android-platform-external-libselinux-8.1.0+r23/debian/patches/series        
2018-06-18 08:57:44.000000000 -0400
+++ android-platform-external-libselinux-8.1.0+r23/debian/patches/series        
2020-02-23 22:08:04.000000000 -0500
@@ -1 +1,2 @@
 Fix-header-path
+0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch

Reply via email to