This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] libio: Disable vtable validation in case of interposition [BZ #23313]


On 06/22/2018 12:15 PM, Szabolcs Nagy wrote:
On 21/06/18 22:20, Florian Weimer wrote:
+/* 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.  */
+__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);
+}

Any comments on this?


is this useful to do with static linking too?
(i'd assume ctor ordering is not well defined then
so stdio access can happen before this check)

with dynamic linking the check looks ok to me
(i did not think about the copy relocation issue)

Right. I don't think we need to support static linking for backwards compatibility with these old libraries, so I'll “#ifndef SHARED” around the constructor.

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]