resolves: bug#810605 Segfault with freeradius-perl threading

This commit is contained in:
John Dennis 2012-04-14 14:13:37 -04:00
parent 75432c6005
commit 03c55b0eab
2 changed files with 71 additions and 1 deletions

65
freeradius-perl.patch Normal file
View File

@ -0,0 +1,65 @@
commit ecb3cd1dbedb764ab98532dae5e0b5bfc9571b00
Author: Alan T. DeKok <aland@freeradius.org>
Date: Thu Dec 1 14:21:03 2011 +0100
Perl clone should be called sequentially, not in parallel.
Adding a mutex fixes this.
Patch from Eike Dehling
diff --git a/src/modules/rlm_perl/rlm_perl.c b/src/modules/rlm_perl/rlm_perl.c
index 5c82e89..4682ba5 100644
--- a/src/modules/rlm_perl/rlm_perl.c
+++ b/src/modules/rlm_perl/rlm_perl.c
@@ -77,6 +77,8 @@ typedef struct perl_inst {
char *perl_flags;
PerlInterpreter *perl;
pthread_key_t *thread_key;
+
+ pthread_mutex_t clone_mutex;
} PERL_INST;
/*
* A mapping of configuration file names to internal variables.
@@ -434,6 +436,8 @@ static int perl_instantiate(CONF_SECTION *conf, void **instance)
*/
#ifdef USE_ITHREADS
+ pthread_mutex_init(&inst->clone_mutex, NULL);
+
inst->thread_key = rad_malloc(sizeof(*inst->thread_key));
memset(inst->thread_key,0,sizeof(*inst->thread_key));
@@ -656,8 +660,10 @@ static int rlmperl_call(void *instance, REQUEST *request, char *function_name)
HV *rad_request_hv;
HV *rad_request_proxy_hv;
HV *rad_request_proxy_reply_hv;
-
+
#ifdef USE_ITHREADS
+ pthread_mutex_lock(&inst->clone_mutex);
+
PerlInterpreter *interp;
interp = rlm_perl_clone(inst->perl,inst->thread_key);
@@ -665,9 +671,12 @@ static int rlmperl_call(void *instance, REQUEST *request, char *function_name)
dTHXa(interp);
PERL_SET_CONTEXT(interp);
}
+
+ pthread_mutex_unlock(&inst->clone_mutex);
#else
PERL_SET_CONTEXT(inst->perl);
#endif
+
{
dSP;
@@ -974,6 +983,7 @@ static int perl_detach(void *instance)
#ifdef USE_ITHREADS
rlm_perl_destruct(inst->perl);
+ pthread_mutex_destroy(&inst->clone_mutex);
#else
perl_destruct(inst->perl);
perl_free(inst->perl);

View File

@ -1,7 +1,7 @@
Summary: High-performance and highly configurable free RADIUS server Summary: High-performance and highly configurable free RADIUS server
Name: freeradius Name: freeradius
Version: 2.1.12 Version: 2.1.12
Release: 6%{?dist} Release: 7%{?dist}
License: GPLv2+ and LGPLv2+ License: GPLv2+ and LGPLv2+
Group: System Environment/Daemons Group: System Environment/Daemons
URL: http://www.freeradius.org/ URL: http://www.freeradius.org/
@ -18,6 +18,7 @@ Patch3: freeradius-man.patch
Patch4: freeradius-unix-passwd-expire.patch Patch4: freeradius-unix-passwd-expire.patch
Patch5: freeradius-radeapclient-ipv6.patch Patch5: freeradius-radeapclient-ipv6.patch
Patch6: freeradius-postgres-sql.patch Patch6: freeradius-postgres-sql.patch
Patch7: freeradius-perl.patch
Obsoletes: freeradius-devel Obsoletes: freeradius-devel
Obsoletes: freeradius-libs Obsoletes: freeradius-libs
@ -154,6 +155,7 @@ This plugin provides the unixODBC support for the FreeRADIUS server project.
%patch4 -p1 -b unix-passwd-expire %patch4 -p1 -b unix-passwd-expire
%patch5 -p1 -b radeapclient-ipv6 %patch5 -p1 -b radeapclient-ipv6
%patch6 -p1 -b postgres-sql %patch6 -p1 -b postgres-sql
%patch7 -p1 -b perl
# Some source files mistakenly have execute permissions set # Some source files mistakenly have execute permissions set
find $RPM_BUILD_DIR/freeradius-server-%{version} \( -name '*.c' -o -name '*.h' \) -a -perm /0111 -exec chmod a-x {} + find $RPM_BUILD_DIR/freeradius-server-%{version} \( -name '*.c' -o -name '*.h' \) -a -perm /0111 -exec chmod a-x {} +
@ -598,6 +600,9 @@ exit 0
%{_libdir}/freeradius/rlm_sql_unixodbc-%{version}.so %{_libdir}/freeradius/rlm_sql_unixodbc-%{version}.so
%changelog %changelog
* Sat Apr 14 2012 John Dennis <jdennis@redhat.com> - 2.1.12-7
- resolves: bug#810605 Segfault with freeradius-perl threading
* Tue Feb 28 2012 John Dennis <jdennis@redhat.com> - 2.1.12-6 * Tue Feb 28 2012 John Dennis <jdennis@redhat.com> - 2.1.12-6
Fixing bugs in RHEL6 rebase, applying fixes here as well Fixing bugs in RHEL6 rebase, applying fixes here as well
resolves: bug#700870 freeradius not compiled with --with-udpfromto resolves: bug#700870 freeradius not compiled with --with-udpfromto