From patchwork Thu Mar 27 16:44:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 314 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (caibbdcaabij.dreamhost.com [208.113.200.189]) by wilcox.dreamhost.com (Postfix) with ESMTP id C8CC63600C4 for ; Thu, 27 Mar 2014 09:44:29 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14307373) id 806E451F505A; Thu, 27 Mar 2014 09:44:29 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx22.g.dreamhost.com 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 homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id 52EFE51F502F for ; Thu, 27 Mar 2014 09:44:29 -0700 (PDT) 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:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=kAM8zWc7Hv6RI72Yd1uRFvHVPa5cj VRiqryVdccKAWZSntL2fq1kf8w3cKD74xExsCta6xWzFoiTi8FsJizLfZvB+X4d+ 10bdZ648C5n6ovpue58kyWMBVH0WlqewrP7ywkt8yNnaogAlxSPivbsZQ2NhRYzW o515UaR6mkEL+E= 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:subject:date:message-id:mime-version :content-type; s=default; bh=4l8G55OOmYuDV7E/KjLDGhXLFo0=; b=oJj xy9tUDXR4N8TAMkm7ziuEHeismP4HVPmDKsYBZin72XAqRqSI0k4e75LMT+I5WoT nUYdCCHm9APdpR8/D5bKgLsXFC9iCRZqbjY4eY43jPQ0FkG2d2vTxPR27yV+flLK S0hlslB/7qg7E4XHrBbLclEISbARO1eV2hWcwcSQ= Received: (qmail 29109 invoked by alias); 27 Mar 2014 16:44:27 -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 29097 invoked by uid 89); 27 Mar 2014 16:44:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de From: Andreas Schwab To: libc-alpha@sourceware.org Subject: [PATCH] Skip checks in pthread_mutex_destroy when doing elision X-Yow: Why is it that when you DIE, you can't take your HOME ENTERTAINMENT CENTER with you?? Date: Thu, 27 Mar 2014 17:44:21 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-DH-Original-To: glibc@patchwork.siddhesh.in When doing elisison the __nusers field is not updated, thus can have an arbitrary value. [BZ #16657] * nptl/pthread_mutex_destroy.c (__pthread_mutex_destroy): Skip checks when doing elision. * nptl/sysdeps/unix/sysv/linux/x86/pthread_mutex_destroy.c: New file. --- nptl/pthread_mutex_destroy.c | 6 +++++- .../unix/sysv/linux/x86/pthread_mutex_destroy.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 nptl/sysdeps/unix/sysv/linux/x86/pthread_mutex_destroy.c diff --git a/nptl/pthread_mutex_destroy.c b/nptl/pthread_mutex_destroy.c index 35a2dfe..f6bd6d9 100644 --- a/nptl/pthread_mutex_destroy.c +++ b/nptl/pthread_mutex_destroy.c @@ -21,6 +21,9 @@ #include +#ifndef DO_ELISION +# define DO_ELISION(m) 0 +#endif int __pthread_mutex_destroy (mutex) @@ -28,7 +31,8 @@ __pthread_mutex_destroy (mutex) { LIBC_PROBE (mutex_destroy, 1, mutex); - if ((mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) == 0 + if (!DO_ELISION (mutex) + && (mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) == 0 && mutex->__data.__nusers != 0) return EBUSY; diff --git a/nptl/sysdeps/unix/sysv/linux/x86/pthread_mutex_destroy.c b/nptl/sysdeps/unix/sysv/linux/x86/pthread_mutex_destroy.c new file mode 100644 index 0000000..b125f75 --- /dev/null +++ b/nptl/sysdeps/unix/sysv/linux/x86/pthread_mutex_destroy.c @@ -0,0 +1,22 @@ +/* Elided version of pthread_mutex_destroy. + Copyright (C) 2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include "force-elision.h" + +#include "nptl/pthread_mutex_destroy.c"