From patchwork Tue Jul 6 11:46:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 44169 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9087B388801F for ; Tue, 6 Jul 2021 11:47:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9087B388801F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625572041; bh=kwnmDIYjwKOvjw6j0ygPquNLVjoRpCqlULOFWV6SDoM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=l4jDIOlvQXwvvumi/NrjLnAFxWhCFaIWDOeJaNoX7XKMWvOv26cBD0vJkLZr05bh9 PZDCvQjrloPRdKBPtqC+vnPGFxp9cmSTRH9xM0+SbM336Jz2GikKYQiP0Q8WwMgGd7 nL0ApO1QO3rAt2L80kcwMeikNGYhUYT6UiZ/rQtk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 65016384A881 for ; Tue, 6 Jul 2021 11:47:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 65016384A881 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-283-62J82vSVOIGcawO31a1hrA-1; Tue, 06 Jul 2021 07:46:58 -0400 X-MC-Unique: 62J82vSVOIGcawO31a1hrA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E706491279 for ; Tue, 6 Jul 2021 11:46:57 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-115-5.ams2.redhat.com [10.36.115.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4ACE560864 for ; Tue, 6 Jul 2021 11:46:57 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH] elf: Call free from base namespace on error in dl-libc.c [BZ #27646] Date: Tue, 06 Jul 2021 13:46:55 +0200 Message-ID: <87zguzfyvk.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" In dlerror_run, free corresponds to the local malloc in the namespace, but GLRO (dl_catch_error) uses the malloc from the base namespace. elf/tst-dlmopen-gethostbyname triggers this mismatch, but it does not crash, presumably because of a fastbin deallocation. Fixes commit c2059edce20c124d1a99f1a94cc52e83b77a917a ("elf: Use _dl_catch_error from base namespace in dl-libc.c [BZ #27646]") and commit b2964eb1d9a6b8ab1250e8a881cf406182da5875 ("dlfcn: Failures after dlmopen should not terminate process [BZ #24772]"). --- elf/dl-libc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elf/dl-libc.c b/elf/dl-libc.c index a49df22029..ba792e9589 100644 --- a/elf/dl-libc.c +++ b/elf/dl-libc.c @@ -48,7 +48,7 @@ dlerror_run (void (*operate) (void *), void *args) ?: last_errstring != NULL); if (result && malloced) - free ((char *) last_errstring); + GLRO (dl_error_free) ((char *) last_errstring); return result; }