From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84681 invoked by alias); 21 Jun 2018 21:20:31 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 84672 invoked by uid 89); 21 Jun 2018 21:20:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=H*r:TLS1.2, foreign X-HELO: albireo.enyo.de From: Florian Weimer To: Szabolcs Nagy Cc: libc-alpha@sourceware.org, nd@arm.com Subject: Re: [PATCH] libio: Disable vtable validation in case of interposition [BZ #23313] References: <773dfddc-66ed-730f-d8b3-a0c9392cc5de@arm.com> <87in6f5858.fsf@mid.deneb.enyo.de> <87h8ly3805.fsf@mid.deneb.enyo.de> <87woutzyvb.fsf@mid.deneb.enyo.de> Date: Thu, 21 Jun 2018 21:20:00 -0000 In-Reply-To: <87woutzyvb.fsf@mid.deneb.enyo.de> (Florian Weimer's message of "Wed, 20 Jun 2018 09:43:52 +0200") Message-ID: <87bmc3bzvq.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2018-06/txt/msg00695.txt.bz2 * Florian Weimer: > libio: Detect foreign vtables in interposed standard streams [BZ #23313] > > 2018-06-20 Florian Weimer > > [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?