Fix a race in JIT locking condition

This commit is contained in:
Petr Písař 2016-06-03 10:24:38 +02:00
parent 955e257c12
commit f1cd1d424b
2 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,42 @@
From d317164a936f976aa94bcc88e4cc4d09b8354c27 Mon Sep 17 00:00:00 2001
From: zherczeg <zherczeg@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Thu, 19 May 2016 18:09:07 +0000
Subject: [PATCH] A racing condition is fixed in JIT reported by Mozilla.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Ported to 10.21 from upstream:
commit 78c2458423ce34b08dd0a119b774e37c908d57ef
Author: zherczeg <zherczeg@6239d852-aaf2-0410-a92c-79f79f948069>
Date: Thu May 19 18:09:07 2016 +0000
A racing condition is fixed in JIT reported by Mozilla.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@514 6239d852-aaf2-0410-a92c-79f79f948069
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
src/sljit/sljitUtils.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/sljit/sljitUtils.c b/src/sljit/sljitUtils.c
index 5294b5f..b7ad3dc 100644
--- a/src/sljit/sljitUtils.c
+++ b/src/sljit/sljitUtils.c
@@ -182,7 +182,10 @@ static pthread_mutex_t dev_zero_mutex = PTHREAD_MUTEX_INITIALIZER;
static SLJIT_INLINE sljit_si open_dev_zero(void)
{
pthread_mutex_lock(&dev_zero_mutex);
- dev_zero = open("/dev/zero", O_RDWR);
+ /* The dev_zero might be initialized by another thread during the waiting. */
+ if (dev_zero < 0) {
+ dev_zero = open("/dev/zero", O_RDWR);
+ }
pthread_mutex_unlock(&dev_zero_mutex);
return dev_zero < 0;
}
--
2.5.5

View File

@ -2,7 +2,7 @@
#%%global rcversion RC1
Name: pcre2
Version: 10.21
Release: %{?rcversion:0.}4%{?rcversion:.%rcversion}%{?dist}
Release: %{?rcversion:0.}5%{?rcversion:.%rcversion}%{?dist}
%global myversion %{version}%{?rcversion:-%rcversion}
Summary: Perl-compatible regular expression library
Group: System Environment/Libraries
@ -30,6 +30,8 @@ Patch2: pcre2-10.21-Fix-pcre2test-loop-when-a-callout-is-in-an-initial-l.pat
Patch3: pcre2-10.21-Fix-workspace-overflow-for-deep-nested-parentheses-w.patch
# Fix a typo in pcre2_study(), fixed in upstream after 10.21
Patch4: pcre2-10.21-Fix-typo-in-pcre2_study.patch
# Fix a race in JIT locking condition, fixed in upstream after 10.21
Patch5: pcre2-10.21-A-racing-condition-is-fixed-in-JIT-reported-by-Mozil.patch
# New libtool to get rid of RPATH and to use distribution autotools
BuildRequires: autoconf
@ -112,6 +114,7 @@ Utilities demonstrating PCRE2 capabilities like pcre2grep or pcre2test.
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
# Because of multilib patch
libtoolize --copy --force
autoreconf -vif
@ -207,6 +210,9 @@ make %{?_smp_mflags} check VERBOSE=yes
%{_mandir}/man1/pcre2test.*
%changelog
* Fri Jun 03 2016 Petr Pisar <ppisar@redhat.com> - 10.21-5
- Fix a race in JIT locking condition
* Mon Mar 07 2016 Petr Pisar <ppisar@redhat.com> - 10.21-4
- Ship README in devel as it covers API and build, not general info
- Move UTF-16 and UTF-32 libraries into pcre-ut16 and pcre-32 subpackages