From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 45620 invoked by alias); 28 Nov 2019 16:48:37 -0000 Mailing-List: contact libc-stable-help@sourceware.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: List-Archive: Sender: libc-stable-owner@sourceware.org Received: (qmail 45606 invoked by uid 89); 28 Nov 2019 16:48:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-18.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy= X-Spam-Status: No, score=-18.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 28 Nov 2019 16:48:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574959714; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SZbwiWALXOdl9K+BB3htLEhERrTqGQj4bYVUj+RGBKU=; b=f6gCY0g/R6iXBOvgSicQD2RCQ8vZHbDeahnMPqCz7kP2CZRaFDjTFLRJKp7sqNWqlAjgvC sovmddhZ8+5akfSqLUkLgojdjocPZcTkc4YPVaIET3089HbxRP8yDOzPHGlYd1wI6lSmpg k9DS/X5OwTvS54QnId/PXcJuWF9gOeg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-WvyU5WK8Mcyxfb3DItltyA-1; Thu, 28 Nov 2019 11:48:33 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8EF42107ACC4 for ; Thu, 28 Nov 2019 16:48:32 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-116-178.ams2.redhat.com [10.36.116.178]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 569BB5D9C5 for ; Thu, 28 Nov 2019 16:48:32 +0000 (UTC) Received: by oldenburg2.str.redhat.com (Postfix, from userid 1000) id 60F298AF7C0A; Thu, 28 Nov 2019 17:48:30 +0100 (CET) Date: Tue, 01 Jan 2019 00:00:00 -0000 To: libc-stable@sourceware.org Subject: [2.24 COMMITTED] libio: Disable vtable validation in case of interposition [BZ #23313] User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20191128164830.60F298AF7C0A@oldenburg2.str.redhat.com> From: Florian Weimer X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: WvyU5WK8Mcyxfb3DItltyA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-11/txt/msg00038.txt.bz2 (cherry picked from commit c402355dfa7807b8e0adb27c009135a7e2b9f1b0) 2018-06-26 Florian Weimer [BZ #23313] * libio/vtables.c (check_stdfiles_vtables): New ELF constructor. diff --git a/libio/vtables.c b/libio/vtables.c index b361f44e91..722a090790 100644 --- a/libio/vtables.c +++ b/libio/vtables.c @@ -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