]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
libio: Disable vtable validation in case of interposition [BZ #23313]
authorFlorian Weimer <fweimer@redhat.com>
Tue, 3 Jul 2018 13:54:49 +0000 (15:54 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 3 Jul 2018 13:54:49 +0000 (15:54 +0200)
(cherry picked from commit c402355dfa7807b8e0adb27c009135a7e2b9f1b0)

ChangeLog
NEWS
libio/vtables.c

index 40383d9ee3a272f8c725d7ef4aa44ff878165571..c096ba3f25965c8fc91001810379597e3c4b7090 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-06-26  Florian Weimer  <fweimer@redhat.com>
+
+       [BZ #23313]
+       * libio/vtables.c (check_stdfiles_vtables): New ELF constructor.
+
 2018-06-29  Daniel Alvarez  <dalvarez@redhat.com>
            Jakub Sitnicki  <jkbs@redhat.com>
 
diff --git a/NEWS b/NEWS
index 501d97bc7af00326eba1370592ba77e5fca39ce2..7b38967e86a2b1c98eb2b8c74888ee1f4973a3b5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -81,6 +81,7 @@ The following bugs are resolved with this release:
   [23236] Harden function pointers in _IO_str_fields
   [23259] Unsubstituted ${ORIGIN} remains in DT_NEEDED for AT_SECURE
   [23264] libc: posix_spawnp wrongly executes ENOEXEC in non compat mode
+  [23313] libio: Disable vtable validation in case of interposition
   [23349] Various glibc headers no longer compatible with <linux/time.h>
 
 \f
index 9fd4ccf642ab19556bde101201282d3e654a71c7..9df75668c8a3c8d34865b4dc48a944cc8f89b05f 100644 (file)
@@ -71,3 +71,19 @@ _IO_vtable_check (void)
 
   __libc_fatal ("Fatal error: glibc detected an invalid stdio handle\n");
 }
+
+/* Some variants of libstdc++ interpose _IO_2_1_stdin_ etc. and
+   install their own vtables directly, without calling _IO_init or
+   other functions.  Detect this by looking at the vtables values
+   during startup, and disable vtable validation in this case.  */
+#ifdef SHARED
+__attribute__ ((constructor))
+static void
+check_stdfiles_vtables (void)
+{
+  if (_IO_2_1_stdin_.vtable != &_IO_file_jumps
+      || _IO_2_1_stdout_.vtable != &_IO_file_jumps
+      || _IO_2_1_stderr_.vtable != &_IO_file_jumps)
+    IO_set_accept_foreign_vtables (&_IO_vtable_check);
+}
+#endif