From patchwork Thu Apr 6 19:58:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rabin Vincent X-Patchwork-Id: 747965 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vzYRp1y3Tz9s80 for ; Fri, 7 Apr 2017 05:58:30 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="jJHc3D62"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=EpRQUURgvqAlPqCMaXXLYF0zcefXMIQPxaYfUvstSZ4Kl1/B6sSVf jkfy/ddSPljYeAgIrDNhd/tHtpIvvSczNWqxD/XBEReLS2v/DqbTZkUnJfKBm0+k 1GA+xte5ezyq+72jiCx6GB7M0IGhrgHLsYkrbphSRa0/sfsUj0mkgw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=geu2DOCfHRhZLf7mYLdbuC5zarM=; b=jJHc3D62RLVcFgjjQHIH0mvfRXfh lvjZr4TC0vq1QZvf4Ykmf6BIujaveV5iT8OXEfAoCkk5lpLAwcaGZPfDC/Zbkx+A GkByGTdcQDTw2l92Z7xd5bsIk9ZtDriV989x8AcuZuMCGByXeIpzSh1Rtdu+pbF+ 16AjtkRJEWoFx4c= Received: (qmail 56593 invoked by alias); 6 Apr 2017 19:58:22 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 56580 invoked by uid 89); 6 Apr 2017 19:58:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=holding X-HELO: bes.se.axis.com From: Rabin Vincent To: libc-alpha@sourceware.org Cc: Rabin Vincent Subject: [PATCH][BZ 21357] unwind-dw2-fde: Call free() outside of unwind mutex Date: Thu, 6 Apr 2017 21:58:01 +0200 Message-Id: <1491508681-30385-1-git-send-email-rabin.vincent@axis.com> X-TM-AS-GCONF: 00 From: Rabin Vincent __deregister_frame_info_bases() calls free() while holding a mutex which is also used from _Unwind_Find_FDE(). This leads to a deadlock if AddressSanitizer uses _Unwind_Backtrace() from its free() implementation. 2017-04-06 Rabin Vincent [BZ #21357] * sysdeps/generic/unwind-dw2-fde.c (__deregister_frame_info_bases): Call free() outside of mutex. diff --git a/sysdeps/generic/unwind-dw2-fde.c b/sysdeps/generic/unwind-dw2-fde.c index 2f0bcd2..104a255 100644 --- a/sysdeps/generic/unwind-dw2-fde.c +++ b/sysdeps/generic/unwind-dw2-fde.c @@ -202,6 +202,7 @@ __deregister_frame_info_bases (void *begin) { struct object **p; struct object *ob = 0; + struct fde_vector *tofree = NULL; /* If .eh_frame is empty, we haven't registered. */ if (*(uword *) begin == 0) @@ -225,7 +226,7 @@ __deregister_frame_info_bases (void *begin) { ob = *p; *p = ob->next; - free (ob->u.sort); + tofree = ob->u.sort; goto out; } } @@ -244,6 +245,7 @@ __deregister_frame_info_bases (void *begin) out: __gthread_mutex_unlock (&object_mutex); + free (tofree); return (void *) ob; } hidden_def (__deregister_frame_info_bases)