]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
libio: Disable vtable validation in case of interposition [BZ #23313]
authorFlorian Weimer <fweimer@redhat.com>
Tue, 26 Jun 2018 08:24:52 +0000 (10:24 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 28 Nov 2019 15:22:07 +0000 (16:22 +0100)
(cherry picked from commit c402355dfa7807b8e0adb27c009135a7e2b9f1b0)

ChangeLog
libio/vtables.c

index 3ca1f72be02276345a5005922000df356e348529..3eba7630c68c5bd2c4ba86b4901ffb548a4bcf30 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.
+
 2019-11-01  Dragan Mladjenovic  <dmladjenovic@wavecomp.com>
 
        * sysdeps/unix/sysv/linux/mips/Makefile
index b361f44e91b694bb1aa67abfbd0f34f49d8d99ac..722a0907900fce25be73fb2e4c76795e7495dca4 100644 (file)
@@ -70,3 +70,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