Fix SIGSEGV on exit when an EAP method is referenced (v3.0.x) #1591

Closed
wants to merge 3 commits into
from

Projects

None yet

3 participants

@lytboris

in multiple eap stansas, e.g.

eap instance1 {
...
md5 {
}
...
}
eap instance2 {
...
md5 {
}
...

}

Sponsored by: Yandex LLC

Boris Lytochkin Fix SIGSEGV on exit when an EAP method is referenced
in multiple eap stansas, e.g.
===========================
eap instance1 {
	...
	md5 {
	}
	...
}
eap instance2 {
	...
	md5 {
	}
	...
}
===========================

Sponsored by: Yandex LLC
e18039e
@lytboris lytboris changed the title from Fix SIGSEGV on exit when an EAP method is referenced to Fix SIGSEGV on exit when an EAP method is referenced (v3.0.x) Apr 25, 2016
Boris Lytochkin apply codestyle fa5d9d4
@alandekok
Member

I don't see why this is necessary. The dlopen / dlclose API takes care of reference counting the handles. From the "man" page for dlopen:

A second call to dlopen() with the same path will return the same handle, but the internal reference
count for the handle will be incremented.  Therefore all dlopen() calls should be balanced with a
dlclose() call.

In this case, if inst->handle == NULL, then something else has gone through and smashed the inst structure.

@alandekok alandekok closed this Apr 25, 2016
@lytboris

I tracked it down. My patch IS correct. Take a look on
https://github.com/FreeRADIUS/freeradius-server/blob/v3.1.x/src/modules/rlm_eap/eap.c#L126

When module is loaded, no dlopen() is invoked and handle is left as 0x0. The only thing to fix for this patch is to fix the comment.

@arr2036 arr2036 reopened this Apr 26, 2016
@arr2036
Member
arr2036 commented Apr 26, 2016

Heh yeah, I guess that was added to support static compilation of EAP methods into rlm_eap.

@arr2036
Member
arr2036 commented Apr 26, 2016

I think we still need to call the detach method though, that's probably per rlm_eap instance. If we don't call it we leak memory on HUP

@lytboris

detach pointer may reference freed memory when real rlm_eap_... method was unloaded previously invalidating type pointer.

@arr2036 arr2036 added a commit that referenced this pull request Apr 26, 2016
@arr2036 arr2036 Remove support for statically compiled EAP methods Closes #1591 cf9cda6
@arr2036 arr2036 closed this Apr 26, 2016
@lytboris lytboris deleted the lytboris:fix-eap-SIGSEGV-on-exit-v3.0.x branch Nov 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment