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]


* Florian Weimer:

> libio: Detect foreign vtables in interposed standard streams [BZ #23313]
>
> 2018-06-20  Florian Weimer  <fweimer@redhat.com>
>
> 	[BZ #23313]
> 	* libio/vtables.c (check_stdfiles_vtables): New ELF constructor.
>
> diff --git a/libio/vtables.c b/libio/vtables.c
> index 9fd4ccf642..5b1b581984 100644
> --- a/libio/vtables.c
> +++ b/libio/vtables.c
> @@ -71,3 +71,17 @@ _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.  */
> +__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?


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