[Bug 2463] New: Conflict with openbsd compat glob() function in shared libraries
bugzilla-daemon at bugzilla.mindrot.org
bugzilla-daemon at bugzilla.mindrot.org
Sat Sep 12 01:38:33 AEST 2015
https://bugzilla.mindrot.org/show_bug.cgi?id=2463
Bug ID: 2463
Summary: Conflict with openbsd compat glob() function in shared
libraries
Product: Portable OpenSSH
Version: 7.1p1
Hardware: Other
OS: Linux
Status: NEW
Severity: enhancement
Priority: P5
Component: Miscellaneous
Assignee: unassigned-bugs at mindrot.org
Reporter: jjelen at redhat.com
Created attachment 2701
--> https://bugzilla.mindrot.org/attachment.cgi?id=2701&action=edit
proof of concept with patch
I am really wondering if nobody ever hit this issue before so I
apologize that this report will be a bit longer, because I would like
to express the state of things and the way how I get to this issue.
Short story is that we should not override this library function in the
same "namespace" where are library functions, if we are not sure the
functions and types are binary compatible (on Linux, glob_t is NOT),
because other shared object can expect structure with different
content.
The long story:
Currently glob function is used only in sftp.c, and sftp-glob.c files
which build together into sftp binary, where is also "packed" compat
function glob making the system glob() function not load (#define
_GLOB_H_). This binary is quite standalone and doesn't issue many calls
to different libraries so the ABI compatibility is not a big deal.
But as I was working in recent time on Include feature, which requires
some globbing, I hit this issue: SSHD started crashing in kerberos
gssapi library after return from glob() call. The returned structure
looked malformed and it took me some time to realize that non system,
but openbsd-compat glob() was called, which is ... suboptimal ...
This didn't appear before, since glob was not used in this binary and
the compat glob() function was optimized out I believe.
This explained the problem, but searching for solution was also
painful. If I am right, openBSD is the only platform with glob with all
these features (GLOB_HAS_GL_MATCHC, GLOB_HAS_GL_STATV are missing on
Linux if I am right):
* Considering writing ifdefs around every usage of these special
features would be possibility, but the result would miss some features
(statvfs at openssh.com, fstatvfs at openssh.com?) and code would be much
more messy
* Modification of glob_t structure that it would be ABI compatible
with system one is also not much portable.
My current solution is to redefine glob and related structures with
some prefix (ex. compat_glob(), COMPAT_GLOB_NOMATCH) and also modify
sftp to use these prefixed functions and constants not to interfere
with system function (see attached patch, currently not portable). The
result builds and works just fine.
For portability reasons (there can be platform supporting all the
extensions) I believe we can create constants (#define _GLOB_PREFIX
compat_ + something for constatns) and use it as a prefix for these
calls. I can elaborate later.
But also I am open to other ideas how you would solve this issue in
portable way. I guess I ran out of ideas at the moment.
--
You are receiving this mail because:
You are watching the assignee of the bug.
More information about the openssh-bugs
mailing list